comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Index of a sector
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Index of a sector [message #24614 is a reply to message #24564] Thu, 05 April 2001 11:42 Go to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
"Pavel A. Romashkin" <pavel.romashkin@noaa.gov> writes:
> Hi,
>
> I tried to solve this yesterday, but it gave me a headache. I tried
> again today, but the headache is back and I did not get any closer to
> the solution. It is very simple. Well after all, what can you ask from a
> Mac user.
>
> If you have a (square) 2D array, let's say, DIST(200, 200), how to
> obtain the index of points enclosed by a sector of a given radius, drawn
> from the corner of the array (point [0, 0])? Foe instance, radius 50?
> So, I will have
>
> 0,1,2,...50
> 101,102,...,149 (or so)
> 201,202,...
> ...
> 501,...?

Complex geometric selections can be easy if you do the right thing.
Pavel, I'm sure that Med's suggestion can work for you but I thought I
would expand on it a little more for the general case.

You start by labelling your pixels in X and Y. You might have
physical labels attached to each pixel, or they could just be pixel
numbers.

x = findgen(200) & y = findgen(200) ;; Just an example here!

Now expand these vectors into matrices along their respective axes:

xx = x # (fltarr(200)+1) ;; Now XX labels every pixel in image
yy = (fltarr(200)+1) # y ;; as does YY

Now compute anything you want in this coordinate system, say radius:

rr = sqrt(xx^2 + yy^2) ;; could compute theta as, th = atan(yy, xx)

And then do your selection:

wh = where(rr LE 50 AND xx GE 0 AND yy GE 0)

You are done. As you can see you can form very complex expressions
involving the radius and angle, and if you have multiple centers this
can be accomodated too. The above expansions of X into XX and Y into
YY are also the basis of fitting images in MPFIT2DFUN.

Good luck,
Craig

--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Re: IDLanROI Confusion
Next Topic: spherical gridding problem

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 12:43:46 PDT 2025

Total time taken to generate the page: 0.24145 seconds