Circle Drawing Algorithm
Circle Drawing Algorithm
y1 202 12 20 y2 202 22 20
Bresenham to Midpoint
Bresenham's line algorithm for raster displays is adapted to circle generation by setting up decision parameters for finding the closest pixel to the circumference at each sampling step. Bresenham's circle algorithm avoids square-root calculations by comparing the squares of the pixel separation distances.
(xk+1, yk-1)
yk
midpoint
yk
midpoint
yk-1
yk-1
3 1 2 3 4
3 1 2 3 4
M
5
3 1 2 3 4
yk
yk-1
x2+y2-r2=0 Midpoint between candidate pixels at sampling position xk+1 along a circular path
Midpoint
xk xk+1 xk+3
P0 = 5/4 - r
3: At each xk position starting at k = 0 , perform the following test: If pk < 0 , the next point along the circle centered on (0,0) is (xk+1, yk) and pk+1 = pk + 2xk+1 + 1
The algorithm
Otherwise the next point along the circle is (xk+1, yk-1) and pk+1 = pk + 2xk+1 +1 -2yk+1 Where 2xk+1 = 2xk+2 and 2yk+1 = 2yk-2 4: Determine symmetry points in the other seven octants 5: Move each calculated pixel position (x,y) onto the circular path centered on (xc ,yc) and plot the coordinate values
x = x+ xc , y= y+ yc
6: Repeat steps 3 through 5 until x >= y
Blank Grid
Blank Grid
10 9 8 7 6 5 4
3
2 1 0 0 1 2 3 4 5 6 7 8 9 10
Blank Grid