Have a look at it this way:

The x,y coordinates of a circle are:

x= r*cos(n)

y= r*sin(n)

where n is the angle and r the radius (I stick to the variable

naming given in your code); so

n= acos(x/r)

and

y= r*sin(acos(x/r)

This is basically what happens in function 'circle'. The

angle 'n' is incremented by 1/r (i.e. 'invradius') at every

iteration of the loop. Variable 'x' is adjusted directly 'dx++'

and variable 'dy' is adjusted by looking up the appropriate

sin(acos(x/r)) value in the table.

FYI, this is not a very efficient circle drawing algorithm

(and it has nothing to do with Bresenham either).

The original Bresenham alogirhm just needs a couple

of additions and a few shifts per iteration; no precomputed

table of arccosines and sines is needed ...

kind regards,

Jos aka jos@and.nl

The x,y coordinates of a circle are:

x= r*cos(n)

y= r*sin(n)

where n is the angle and r the radius (I stick to the variable

naming given in your code); so

n= acos(x/r)

and

y= r*sin(acos(x/r)

This is basically what happens in function 'circle'. The

angle 'n' is incremented by 1/r (i.e. 'invradius') at every

iteration of the loop. Variable 'x' is adjusted directly 'dx++'

and variable 'dy' is adjusted by looking up the appropriate

sin(acos(x/r)) value in the table.

FYI, this is not a very efficient circle drawing algorithm

(and it has nothing to do with Bresenham either).

The original Bresenham alogirhm just needs a couple

of additions and a few shifts per iteration; no precomputed

table of arccosines and sines is needed ...

kind regards,

Jos aka jos@and.nl