Re: Inside rectangle [message #31518 is a reply to message #31342] |
Mon, 22 July 2002 11:55  |
JD Smith
Messages: 850 Registered: December 1999
|
Senior Member |
|
|
On Tue, 02 Jul 2002 09:53:03 -0700, Neil Talsania wrote:
> I am relatively new to IDL , and am wondering how to do the following. I
> want to be able to have user input 4 corner coordiates, then check to
> see if a particular point is inside the rectangle. That is pretty easy,
> i think. But then I want to be able to add additional sets of
> coordinates to check. I want this to be unlimited. Basically allowing
> the user to add rectangles to check until he is ready to stop.
>
> Now I think I want to make a structure to hold the 4 corner coordinates.
> Then I need to create an array of these structures, but I want that
> array to be able to grow. Then I will loop through that array (For loop)
> calling a function that will check to see if the point is inside the
> coordinates.
>
> So the crux of my problem ( I think) is that I need the array size to
> increase every time the user adds a set. But I dont know ho to do this.
>
> Any clues would be greatly appreciated.
On a related note, you can get much better performance by doing your
test without a loop, ala:
rect=replicate({ll:[0.,0.],ur:[1.,1.]},100) ;; fill this list however
in=where(x gt rect.ll[0,*] AND $
x lt rect.ur[0,*] AND $
y gt rect.ll[1,*] AND $
y lt rect.ur[1,*],cnt)
|
|
|