Circle
Circle
What is a circle?
A circle is defined as a set of points that all are the same distance from a common point known as the center
and the distance from the center of the circle to any point on its circumference is called a radius.
It is an eight-way symmetric figure which can be divided into four quadrants and each quadrant has two
octants. This symmetry helps in the implementation of any circle drawing algorithm.
The midpoint circle drawing algorithm helps us to calculate the complete perimeter points of a circle for
the first octant. We can quickly find and calculate the points of other octants with the help of the first octant
points. The remaining points are the mirror reflection of the first octant points.
Let us assume we have a point a (p, q) on the boundary of the circle and with r radius satisfying the
equation fc (p, q) = 0
Now, the initial decision parameter (d0) at the position (p, q) = (0, r)
We put (0, r) in circle equation and we get-
d0 = (1, r – 1/2)
= (1 + (r –1/2)2 –r2)
= 5/4 –r
We only take integer value = 1 – r
Case 1: If
dk < 0
then
pk+1 =pk + 1
qk+1 =qk
dk+1 = dk + 2 pk+1 + 1
Case 2: If
dk >= 0
then
pk+1 =pk + 1
qk+1 =qk –1
dk+1 = dk - 2 (qk+1 + 2 pk+1)+ 1
Step 6: If the center coordinate point (p0, q0) is not at the origin (0, 0) then we will draw the points as
follow-
For x coordinate = xc + p0
For y coordinate = yc + q0 {xc and yc contains the current value of x and y coordinate}
Step 7: We repeat step 5 and 6 until we get x>=y.
Step 8: Stop.