You are on page 1of 5

Bresenham’s Circle Algorithm

Define: D(si) = distance of p3 from circle


D(ti) = distance of p2 from circle

i.e. D(si) = (xi + 1)2 + yi2 – r2 [always +ve]


D(ti) = (xi + 1)2 + (yi – 1)2 – r2 [always -ve]

• Decision Parameter pi = D(si) + D(ti)


so if pi < 0 then the circle is closer to p3 (point above)
if pi ≥ 0 then the circle is closer to p2 (point below)

1
The Algorithm
x0 = 0
y0 = r
p0 = [12 + r2 – r2] + [12 + (r-1)2 – r2] = 3 – 2r

if pi < 0 then
yi+1 = yi
pi+1 = pi + 4xi + 6
xi+1 = xi + 1
else if pi ≥ 0 then
yi+1 = yi – 1
pi+1 = pi + 4(xi – yi) + 10

• Stop when xi ≥ yi and determine symmetry


points in the other octants 2
Example
r = 10
p0 = 3 – 2r = -17
Initial point (x0, y0) = (0, 10)
10    

i pi xi, yi 9  
0 -17 (0, 10) 8 
7 
1 -11 (1, 10)
6 
2 -1 (2, 10)
5 
3 13 (3, 10) 4 
4 -5 (4, 9) 3 
5 15 (5, 9) 2 
1 
6 9 (6, 8)
0 
7 (7,7)
0 1 2 3 4 5 6 7 8 9 10
3
p0 = -17+ 4*0 + 6 = -11

p1 = -11+ 4*1 + 6 = -1

p2 = -1+ 4*2 + 6 = 13

p3 = 13 + 4(3 – 10) + 10 = -5
Exercises
• Draw the circle with r = 12 using the
Bresenham algorithm.

• Draw the circle with r = 14 and center at (15,


10).

You might also like