Professional Documents
Culture Documents
8
• Now, we will see how to calculate the next pixel
location from a previously known pixel location (x, y).
• In Bresenham’s algorithm at any point (x, y) we have
two option either to choose the next pixel in the east
i.e. (x+1, y) or in the south east i.e. (x+1, y-1).
9
• And this can be decided by using the decision
parameter d as:
• If d > 0, then (x+1, y-1) is to be chosen as the next pixel
as it will be closer to the arc.
• else (x+1, y) is to be chosen as next pixel.
WHERE
d=3–2xR
10
• Thus the points generated using Bresenham Circle
Drawing Algorithm involves the following steps:
Step 1 : Set initial values of (xc, yc) and (x, y)
Step 2 : Calculate decision parameter d to d = 3 – (2 * r).
Step 3 : call displayBresenhmCircle(int xc, int yc, int x, int y) method to display
initial(0,r) point.
11
Problems
1. Given the centre point coordinates (0, 0) and radius as 8, generate all
the points to form a circle.
2. Given the centre point coordinates (10, 10) and radius as 10,
generate all the points to form a circle.
12
Solution for Problem 1
• Given-
Centre Coordinates of Circle (X0, Y0) = (0, 0)
Radius of Circle = 8
• Step-01:
Assign the starting point coordinates (X0, Y0) as-
X0 = 0
Y0 = R = 8
13
• Step-02:
Calculate the value of initial decision parameter d as-
d0 = 3 – 2 x R
d0 = 3 – 2 x 8
d0 = -13
14
• Step-03:
As d0 < 0, so case-01 is satisfied.
Thus,
X = X + 1 = 0 + 1 = 1
k+1 k
Y = Y = 8
k+1 k
d = d + 4 x X + 6
k+1 k k+1
d1 = d0 + 4( X1 )+ 6
= -13 + 4(1) + 6 = -3
15
dk dk+1 (Xk+1, Yk+1)
(0, 8)
-13 -3 (1, 8)
Step-04:
This step is not applicable here as the given centre
point coordinates is (0, 0).
Repeat step-05 until xk+1 >=yk+1.
16
• Step-05:
Since d1 < 0, case - 01 is applied.
So, X2 = X1+1 = 1 + 1 = 2
Y2 = Y 1 = 8
d2 = d1 + 4(X2) + 6
= -3 + 4(2) + 6
= 11
17
dk dk+1 (Xk+1, Yk+1)
(0, 8)
-13 -3 (1, 8)
-3 11 (2, 8)
Algorithm Terminates
These are all points for Octant-1.
18
• Step-05(repeat):
Since d2 >= 0, case - 02 is applied.
So, X3 = X2+1 = 2 + 1 = 3
Y3 = Y2 -1 = 8 – 1 = 7
d3 = d2 + 4(X3 – Y3) + 10
= 11 + 4(3 - 7) + 10
=5
19
Advantages and Disadvantages
• Advantages
• The Bresenhem’s circle drawing algorithm uses integer arithmetic which
makes the implementation less complex.
• Due to its integer arithmetic, it is less time-consuming.
• This algorithm is more accurate than any other circle drawing algorithm as it
avoids the use of round off function.
• Disadvantages
• This algorithm does not produce smooth results due to its integer arithmetic
as it fails to diminish the zigzags completely.