Circle Algorithm

BlitzPlus Forums/BlitzPlus Programming/Circle Algorithm

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

A fast circle algorithm with limited precision would be to just draw a line from x+a,y+b to x+u,y+v for N loops where x,y is the centre of the circle (Keeping in mind what Grey Alien said), and a=radius*cos(A), b=radius*sin(A), u=radius*cos(A+ 360°/N), v=radius*sin(A+ 360°/N), where A increases by 360°/N each loop.
The limitation is obviously that it is not a circle but a polygon, but depending on the radius you should be able to calculate the minimum value for N such that it would appear as such.
As for drawing a line by plotting directly into an array, you could take the vector of say, point x1,y1 to point x2,y2 to be vector v1,v2, then normalise it ie magnitude 1, and then store a coordinate as floats, draw a pixel there, and then increase the coordinate by unit/normalised vector of(v1,v2) and then draw a pixel at the integer of there, and so on until as many pixels as the length of the initial v1,v2 have been plotted.