06-07-2012, 03:46 PM
MIDPOINT CIRCLE DRAWING ALGORITHM
To write a C program to draw a circle using Bresenham’s algorithm.
Algorithm
Step 1:Input radius r and circle center(Xc, Yc)and obtain the first point on the circumference of a circle centered on the origin as (X0, Y0) = (0, r)
Step 2: Calculate the initial values of the decision parameter as
P0 = 5/4 – r
Step 3: At each position starting at k perform the following test:
If Pk < 0, the next point to plot is (Xk+1, Yk) and
Pk+1 = Pk+2 Xk+1 + 1
Otherwise the next point is (Xk+1, Yk-1) and
Pk+1 = Pk+2 Xk+1 + 1- 2Yk+1
where 2Xk+1=2Xk+2 and 2Yk+1=2Yk-2
Step 4: Determine symmetry points in the other seven octants
Step 5: Move each pixel position(X, Y) onto the circular path centered on(Xc, Yc) and plot the coordinate values as
X = X + Xc Y = Y + Yc
Step 6: Repeat steps 3 through until X>=Y