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

Home » Public Forums » archive » Re: Routine to return indices for circle in R2
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: Routine to return indices for circle in R2 [message #9929 is a reply to message #9927] Mon, 08 September 1997 00:00 Go to previous message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
David Foster writes:

> Has someone written, seen or heard of a routine that will return
> the indices of a circle within an image of given dimensions,
> given the radius and center coordinate of the circle? I vaguely
> remember seeing this in a newsgroup post some time ago.
>
> For an image of size NX x NY, with the circle at coordinate (Cx,Cy)
> and radius R, I came up with:
>
> indices = lindgen(long(NX)*NY)
> yc = indices / NY
> xc = indices - (yc * NY)
> circle = where( sqrt( (xc - Cx)^2 + (yc-Cy)^2 ) le R )
>
> Can anyone suggest a method that is (a) faster, (b) more clever,
> (c) more elegant, or (d) uses less memory. I'd be willing to settle
> for just one of the above!

There is an article on this very topic (with code) on my web page. ;-)

http://www.dfanning.com/tips/make_circle.html

The best program for circles I've used is Wayne Landsman's TVCircle.
You can find a link to it from the page, but here it is:

http://idlastro.gsfc.nasa.gov/ftp/pro/tv/tvcircle.pro

Cheers,

David

-----------------------------------------------------------
David Fanning, Ph.D.
Fanning Software Consulting
Customizable IDL Programming Courses
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com
[Message index]
 
Read Message
Read Message
Previous Topic: HDF Browser for Win 95
Next Topic: Best ORB for Java and C/C++

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

Current Time: Sat Oct 11 05:18:50 PDT 2025

Total time taken to generate the page: 0.16003 seconds