A totally bitchin' circle algorithm
Last revised: 2/20/97 SLJ
With a revision! The old algorithm ignored one small detail -- the plot8
8-fold plotter, which can be a real pain! One thing to do is to make the
algorithm draw a quarter of a circle instead of an eighth, and the
way to do that is to attempt to reverse the procedure that drew the
first eighth of the circle.
BLARG does exactly this; in the process, I also experimented with how the
order of statements below makes a difference in the way the circles
look. So the algorithm below is now the best version I know of, i.e.
makes the most beautiful circles at all radii.
This is the entire algorithm:
Y = Radius
X = 0
A = Radius/2
:loop
Plot4(x,y) ;Could just use Plot8
X = X + 1
A = A - X
if A<0 then A=A+Y : Y=Y-1
if X < Y then :loop
; Now more or less reverse the above to get the other eighth
A = -R/2 - 1
:loop2
Plot4(x,y)
A = A + Y
Y = Y - 1
if A<0 then X=X+1:A=A-X
if Y>=0 then :loop2
Neat!
The other possibility is to use the first half of this algorithm with
an 8-fold symmetric plot, and be sure to plot the last point X=Y.
See C=Hacking Issue #9 for more details, but note that A=R/2 above, which
will make the circle correct for small R (it just rounds numbers).