Re: sorting points or rectangles
- Posted by euman at bellsouth.net Feb 21, 2002
- 564 views
Hey Tone/all My question is how you might fit 10,000 rectangles on screen at the same time....and expect some kind of interaction. Are these rectangle going to be pushbuttons or have mouse function that could occur while a pointer is over them? Or is this an elaborate way to paint a screen? What is it? Euman euman at bellsouth.net Q: Are we monetarily insane? A: YES ----- Original Message ----- From: <tone.skoda at siol.net> To: "EUforum" <EUforum at topica.com> Sent: Thursday, February 21, 2002 7:31 PM Subject: Re: sorting points or rectangles > > ----- Original Message ----- > From: "Dan Moyer" <DANIELMOYER at prodigy.net> > > > ... if the edges of the rectangles are all vertical and horizontal with > respect to > > the coordinate system (the screen). > > I don't understand this quite. Rectangles allways have two horizontal and > two vertical edges. If edges are not horizontal or vertical then that would > be paralelogram or whatever, no? > > > Do you need to handle conditions other > > than that? > > No. You all responded with functions how to find out if (and how) rectangle > is inside rectangle. > I have around 10.000 rectangles and I have to get all rectangles which have > at least one of their four points inside a big rectangle. > I want to be able to use binary search on sorted rectangles for speed. > > If I do it like this it is too slow: > > function get_rects_inside_rect (sequence rectangles, sequence big_rect) > sequence rects_inside > sequence rect > rects_inside = {} > for int i = 0 to length (rects) do > rect = rects [i] > if is_rect_partially_inside_rect (rect, big_rect) then > rects_inside = append (rects_inside, rect) > end if > end for > return rects_inside > end function > > A little faster it would be if I woluld somehow sort them by their left-x, > or something similar. Unclear to me right now. > > > >