Circle drawing request. [message #7981] |
Tue, 28 January 1997 00:00  |
D.Kennedy
Messages: 26 Registered: January 1997
|
Junior Member |
|
|
This must be a FAQ - anyone got a good circle drawing sub-routine?
Input - x, y, radius
Output - [x,y] vectors for POLYFILL etc.
I have been using one (shown below) but I find it produces fine lines
shooting off to small y values from the left and right edges of each
circle. And my fiddling with it has made it worse I'm afraid.
FUNCTION CIRCLE, xcenter, ycenter, radius
; Emailed by Dfanning 27th Jan
step = (radius/24.0)
x = FLTARR(25)
y = FLTARR(25)
; Construct a circle
FOR j=0,24 DO BEGIN
x(j) = j*step
y(j) = SQRT(radius^2 - x(j)^2)
ENDFOR
x = [x, Reverse(x)]
y = [y, -Reverse(y)]
x = [-Reverse(x), x]
y = [y,y]
; Center the circle at the specified coordinates.
x = x + xcenter
y = y + ycenter
points = FLTARR(2, 100)
points(0,*) = x
points(1,*) = y
RETURN, points
END
--
David Kennedy, Dept. of Pure & Applied Physics, Queen's University of Belfast
Email: D.Kennedy@Queens-Belfast.ac.uk | URL: http://star.pst.qub.ac.uk/~dcjk/
Hi! I'm a .signature virus! Copy me into yours and join the fun!
|
|
|