Mid Point Circle Drawing Derivation & Algorithm
Mid Point Circle Drawing Derivation & Algorithm
(Algorithm)
The mid point circle algorithm is used to determine the pixels needed
for rasterizing a circle while drawing a circle on a pixel screen.
In this technique algorithm determines the mid point between the
next 2 possible consecutive pixels and then checks whether the mid
point in inside or outside the circle and illuminates the pixel
accordingly.
Radius = OR = r
Radius = x intercept = y intercept
At point R
coordinate of x = coordinate of y or we can say x=y
let us take Octet 2 of quadrant 1
here first pixel would be (0,y)
here value of y intercept = radius (r)
as circle’s center is at origin
DERIVATION
let us assume we have plotted Pixel P whose coordinates are
Now we need to determine the next pixel.
For that decision Mid Point circle drawing technique will us decide our
next pixel whether it will be N or S.
x2 + y2 = r2 (Pythagoras theorem)
Function of Circle Equation
F(C) = x2 + y2 - r2
Function of Midpoint M (xk+1 , yk -1/2) in circle equation
Now,
Pk+1- Pk = (xk+1+1)2 + (yk+1 -1/2)2 - r2
-[(xk+1)2 + (yk -1/2)2 - r2]
Credit: www.getsetcg.com
Mid Point Circle Drawing Algorithm
The points for other octets are generated using the eight-symmetry property.
Procedure-
Given-
• Centre point of Circle = (X0, Y0)
• Radius of Circle = R
The points generation using Mid-Point Circle Drawing Algorithm involves the following
steps-
Step-01:
Assign the starting point coordinates (X0, Y0) as-
• X0 = 0
• Y0 = R
Step-02:
Calculate the value of initial decision parameter P0 as-
P0 = 1 – R
Step-03:
Suppose the current point is (Xk, Yk) and the next point is (Xk+1, Yk+1).
Find the next point of the first octant depending on the value of decision parameter P k.
Follow the below two cases-
Step-04:
If the given centre point (X0, Y0) is not (0, 0), then do the following and plot the point-
• Xplot = Xc + X0
• Yplot = Yc + Y0
Step-05:
Keep repeating Step-03 and Step-04 until Xplot >= Yplot.
Step-06:
Step-05 generates all the points for one octant.
To find the points for other seven octants, follow the eight-symmetry property of circle.
This is depicted by the following figure-
PRACTICE PROBLEMS BASED ON MID POINT CIRCLE DRAWING
ALGORITHM-
Problem-01:
Given the centre point coordinates (0, 0) and radius as 10, generate all the points to form
a circle.
Solution-
Given-
• Centre Coordinates of Circle (X0, Y0) = (0, 0)
• Radius of Circle = 10
Step-01:
Assign the starting point coordinates (X0, Y0) as-
• X0 =0
• Y0 = R = 10
Step-02:
Calculate the value of initial decision parameter P0 as-
P0 = 1 – R
P0 = 1 – 10
P0 = -9
Step-03:
As Pinitial < 0, so case-01 is satisfied.
Thus,
• Xk+1 = Xk + 1 = 0 + 1 = 1
• Yk+1 = Yk = 10
• Pk+1 = Pk + 2 x Xk+1 + 1 = -9 + (2 x 1) + 1 = -6
Step-04:
This step is not applicable here as the given centre point coordinates is (0, 0).
Step-05:
Step-03 is executed similarly until Xk+1 >= Yk+1 as follows-
(0, 10)
-9 -6 (1, 10)
-6 -1 (2, 10)
-1 6 (3, 10)
6 -3 (4, 9)
-3 8 (5, 9)
8 5 (6, 8)
Algorithm Terminates
These are all points for Octant-1.
Algorithm calculates all the points of octant-1 and terminates.
Now, the points of octant-2 are obtained using the mirror effect by swapping X and Y
coordinates.
(4, 9) (10, 2)
(5, 9) (10, 1)
(6, 8) (10, 0)
Now, the points for rest of the part are generated by following the signs of other quadrants.
The other points can also be generated by calculating each octant separately.
Here, all the points have been generated with respect to quadrant-1-
Quadrant-1 (X, Y) Quadrant-2 (-X, Y) Quadrant-3 (-X, -Y) Quadrant-4 (X, -Y)
Problem-02:
Given the centre point coordinates (4, -4) and radius as 10, generate all the points to form
a circle.
Solution-
Given-
• Centre Coordinates of Circle (X0, Y0) = (4, -4)
• Radius of Circle = 10
(9, 5) (13, 9)
(9, 4) (13, 8)
(10, 3) (14, 7)
(10, 2) (14, 6)
(10, 1) (14, 5)
(10, 0) (14, 4)
The following table shows the points for all the quadrants-
Quadrant-1 (X, Y) Quadrant-2 (-X, Y) Quadrant-3 (-X, -Y) Quadrant-4 (X, -Y)
Important Points