Midpoint Circle Drawing Algorithm
Midpoint Circle Drawing Algorithm
o Bresenham’s algorithm
The firstthing we can notice to make our circle drawing algorithm more
efficient isthat circles centred at (0,0)have eight-waysymmetry
9
Circle exhibit octant symmetry.
A circle is symmetric about its octants.
•Start at (0,r)
•End at (x,y) such that x>=y i.e. whenever x becomes >=y we
can stop the algorithm.
•Because the shape of the circle in this region is more flat, we
can sample it along X-axis at unit intervals, and compute the
corresponding y-values
Principle behind Midpoint Circle Algorithm
•Equation of circle with centre at origin, and having a radius of r
units is given by 𝑥 2 + 𝑦 2 = 𝑟 2
• Decision parameter 𝑝𝑘 = 𝑥 2 + 𝑦 2 − 𝑟 2
Principle behind Midpoint Circle Algorithm
At each point:
Plot ( xk + 1, yk )
If pk < 0:
pk +1 = pk + 2 ( xk + 1) + 1
Plot ( xk + 1, yk − 1)
If pk >= 0:
pk +1 = pk + 2 ( xk + 1) + 1 − 2 ( yk − 1)
Problem
Find the points on a circle on its octants with the circle centered
at (5,5) and has radius of 8 units
𝑝0 = 1 − 𝑟
Mid-Point Circle Algorithm
10
General Principle Consider only
The circle function: 45° ≤ ≤ 90°
f circle (x, y) = x 2 + y 2 − r 2
and
11
p1 p3
yi
D(s i)
yi - 1 D(ti)
p2
xi xi + 1
12
Bresenham’s Circle Algorithm
13
Assume that we have
(xi+1, yi)
just plotted point (x i, y i) (xi, yi)
= ( x i + 2 ) 2 + ( y i +1 − 1
2
)2 − r 2
OR
p = p + 2 ( x + 1) 2 + ( y 2 − y 2 ) − ( y − yi ) + 1
i +1 i i i+1 i i+1
p0 = 5 4 − r 1− r = 1−10 = −9
24
10
k pk (xk+1,yk+1) 2xk+1 2yk+1
9
8 0 -9 (1,10) 2 20
7
1 -6 (2,10) 4 20
6
5 2 -1 (3,10) 6 20
4 3 12 (4, 9) 8 18
3
2 4 3 (5, 8) 10 16
1 -2 (6, 8) 12 16
5
0
6 5 (7, 7)
0 1 2 3 4 5 6 7 8 9 10