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

Home » Public Forums » archive » Re: circles
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: circles [message #9500] Fri, 11 July 1997 00:00
Kevin Reardon is currently offline  Kevin Reardon
Messages: 2
Registered: July 1995
Junior Member
lady of the elves wrote:
>
> I would really like to have a circularly-filled array; if anyone has
> better knowledge, please let me know :)
> Thanks.

The most direct way get an array of distances from some central point in IDL is:

;for a circle centered at (150,50)
xx = rebin(findgen(201,201) - 150,201,201)
yy = rebin(findgen(1,201) - 50,201,201)

radial_distance = sqrt(xx^2 - yy^2)

tvscl,radial_distance le 50 ; displays a white filled circular mask


The previous suggestion by Peter Suetterlin (pit@uni-sw.gwdg.de) of:
img = (shift(dist(X,Y),x0,y0)) LT R
doesn't seem to work if x0 and y0 are not equal to X/2 and Y/2 (i.e. the
circle is not centerted) because of wrapping problems when the array is shifted.

kevin
kreardon@na.astro.it
Re: circles [message #9512 is a reply to message #9500] Thu, 10 July 1997 00:00 Go to previous message
pit is currently offline  pit
Messages: 92
Registered: January 1996
Member
In article <33C3DE74.356F@mad.scientist.com>,
lady of the elves <galadriel@mad.scientist.com> writes:
> [incidentally, I'm new to this language :)]
>
> I'm trying to create a two-dimensional array, such that tvscl of the
> array will show a filled circle. So far, my best idea has not

Hm, maybe the easiest way to create an array of dimension
(X,Y) with a circle of radius R at location x0,y0) would be:

img = (shift(dist(X,Y),x0,y0)) LT R

DIST: creates an array (X,Y) (in FFT-segmented form, but thats not
important for the moment) where each element contains the distance
from (0,0)
SHIFT -> Shift (0,0) to desired center of circle

array LT value will result in an byte array that is 1 where the value
(=distance) is lower than the radius, and 0 everywhere else.

TVSCLing img will show the circle

Peter

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~
Peter "Pit" Suetterlin http://www.uni-sw.gwdg.de/~pit
Universitaets-Sternwarte Goettingen
Tel.: +49 551 39-5048 pit@uni-sw.gwdg.de
-- * -- * ...-- * -- * ...-- * -- * ...-- * -- * ...-- * -- * ...-- * --
Come and see the stars! http://www.kis.uni-freiburg.de/~ps/SFB
Sternfreunde Breisgau e.V. Tel.: +49 7641 3492
____________________________________________________________ ______________
Re: circles [message #9513 is a reply to message #9512] Thu, 10 July 1997 00:00 Go to previous message
Joseph M Zawodny is currently offline  Joseph M Zawodny
Messages: 24
Registered: March 1996
Junior Member
lady of the elves wrote:
>
> [incidentally, I'm new to this language :)]
>
> I'm trying to create a two-dimensional array, such that tvscl of the
> array will show a filled circle. So far, my best idea has not
> worked--but here it is:
>
> x and y are one-D arrays of 200 elements such that plot,x,y produces a
> circular shape, but not filled.
>
> for round1=0,199 do begin
> for round2=0,199 do begin
> if (y(round1) eq y(round2)) then begin
> circle(y(round1),x(round1):x(round2))=2
> endif
> endfor
> endfor
>
> A circle is composed of boundary points such that: for each x, there are
> two y's and for each y, there are two x's--right? If I fill between the
> y's, I should have a circle....right?
>
> I would really like to have a circularly-filled array; if anyone has
> better knowledge, please let me know :)
> Thanks.
> -gzb

Select the center coordinates (xc,yc) for the circle in pixels (these
need not be integers). If your array is (201,201) and you want the
circle centered set the center values each to 100.

Select the raduis of the circle in pixels (again, need not be integer).

For every element in the array (x,y) check to see if
((x-xc)^2)+(y-yc)^2) is less than or equal to the radius.

If it is, then set it to the "filled" value.

Naturally, this process can be done without loops.

Have fun,

JMZ



--

Work: Dr. Joseph M. Zawodny Play: Joe Zawodny
NASA Langley Research Center KO4LW@amsat.org
E-mail: J.M.Zawodny@LaRC.NASA.gov zawodny@exis.net
(757) 864-2681 (757) 864-2671 FAX http://wwwp.exis.net/~zawodny
Re: circles [message #9516 is a reply to message #9512] Wed, 09 July 1997 00:00 Go to previous message
Martin Lizak (NEI) is currently offline  Martin Lizak (NEI)
Messages: 1
Registered: July 1997
Junior Member
lady of the elves wrote:
>
> [incidentally, I'm new to this language :)]
A simpler way to to that is as follows

function makecircle
im=bytarr(200,200)

; if you make the angular resolution too small, you'll have blank lines
theta=findgen(1000)*!pi/1000. - !pi/2.

for i=0,999 do begin
y=fix(99.*sin(theta(i)))+100
xmin=-fix(99.*cos(theta(i)))+100
xmax=fix(99.*cos(theta(i)))+100
im(xmin:xmax,y)=2
endfor
return,im
end

>
> I'm trying to create a two-dimensional array, such that tvscl of the
> array will show a filled circle. So far, my best idea has not
> worked--but here it is:
>
.
.
> I would really like to have a circularly-filled array; if anyone has
> better knowledge, please let me know :)
> Thanks.
> -gzb
Re: circles [message #9517 is a reply to message #9516] Wed, 09 July 1997 00:00 Go to previous message
David Foster is currently offline  David Foster
Messages: 341
Registered: January 1996
Senior Member
lady of the elves wrote:
>
> [incidentally, I'm new to this language :)]
>
> I'm trying to create a two-dimensional array, such that tvscl of the
> array will show a filled circle. So far, my best idea has not
> worked--but here it is:
>
> x and y are one-D arrays of 200 elements such that plot,x,y produces a
> circular shape, but not filled.
>

You can use the POLYFILLV to get the subscripts of the circular region
defined by vectors X and Y:

circle = polyfillv(x,y,xarray_size,y_array_size)
if (circle(0) ne -1 ) then array(circle) = 2

or you can use the POLYFILL procedure to fill the circle directly
on the graphics device.

Dave

--

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
David S. Foster Univ. of California, San Diego
Programmer/Analyst Brain Image Analysis Laboratory
foster@bial1.ucsd.edu Department of Psychiatry
(619) 622-5892 8950 Via La Jolla Drive, Suite 2200
La Jolla, CA 92037
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~

"I have this theory that if we're told we're bad,
then that's the only idea we'll ever have.
But maybe if we are surrounded in beauty,
someday we will become what we see." - Jewel Kilcher
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: .Free Cash Grants
Next Topic: Are IDL functions callable from C++ programs under Win-NT

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

Current Time: Wed Oct 08 16:01:10 PDT 2025

Total time taken to generate the page: 0.00553 seconds