comp.lang.idl-pvwave archive - RDF feed
type: channel
description: Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado
items: Circle drawing request.
items: Re: Circle drawing request.

Circle drawing request.
type: item
description: 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!
creator: D.Kennedy
date: 1997-01-28T08:00:00-00:00

Re: Circle drawing request.
type: item
description: David Kennedy wrote: > > 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. > David, You might want to look at the procedure TVCIRCLE available from http://idlastro.gsfc.nasa.gov/ftp/pro/tv/tvcircle.pro, which includes a /FILL option for using POLYFILL. It uses a more sophisticated circle drawing algorithm that was shown to me a few years back by Allyn Saroyn. A possible problem with the simple-minded algorithm where the X,Y coordinates of the circle are calculated at a preset number of values (25*4 = 100 for David Fanning's sample code) is that the circle might sometimes be smooth, and sometimes spiky, depending on the circle size and the graphics device. TVCIRCLE gets around this problem by always calculating the positions internally in device coordinates, and calculating all positions where the X,Y device coordinates differ by an integral amount. Thus, the circle is guarenteed (in principle) to come out smooth on all graphics devices. --Wayne Landsman landsman@mpb.gsfc.nasa.gov
creator: Wayne Landsman
date: 1997-01-28T08:00:00-00:00