Bresenhams Circle Algorithm
Bresenhams Circle Algorithm
Bresenham'
s Circle
Algorithm:
Procedure-
Scan-Converting a circle using
Bresenham's algorithm works as
follows: Points are generated from 90°
to 45°, moves will be made only in the
+x & -y directions as shown in fig:
The best approximation of the true circle will be
described by those pixels in the raster that falls
the least distance from the true circle. We want to
generate the points from
90° to 45°. Assume that the last scan-converted pixel is P1 as
shown in fig. Each new point closest to the true circle can be
found by taking either of two actions.
Let D (Si) is the distance from the origin to the true circle
squared minus the distance to point P3 squared. D (Ti) is the
distance from the origin to the true circle squared minus the
distance to point P2 squared. Therefore, the following
expressions arise.
D (Si)=(xi-1+1)2+ yi-12 -r2
D (Ti)=(xi-1+1)2+(yi-1 -1)2-r2
Since D (Si) will always be +ve & D (Ti) will always
be -ve, a decision variable d may be defined as
follows:
di=D (Si )+ D (Ti)
Therefore,
di=(xi-1+1)2+ yi-12 -r2+(xi-1+1)2+(yi-1 -1)2-r2
If it is assumed that the circle is centered at the origin, then at the first step x = 0 & y = r.
Therefore,
di=(0+1)2+r2 -r2+(0+1)2+(r-1)2-r2
=1+1+r2-2r+1-r2
= 3 - 2r
di+1=di+ 4xi+6
di+1=di+ 4 (xi-yi)+10
Procedure-
Given-
•Centre point of Circle = (X0, Y0)
•Radius of Circle = R
Step-02:
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 Pk.
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:
Solution-
Given-
•Centre Coordinates of Circle (X0, Y0) = (0, 0)
•Radius of Circle = 8
Step-01:
Step-02:
Thus,
•Xk+1 = Xk + 1 = 0 + 1 = 1
•Yk+1 = Yk = 8
•Pk+1 = Pk + 4 x Xk+1 + 6 = -13 + (4 x 1) + 6 = -3
Step-04:
(0, 8)
-13 -3 (1, 8)
-3 11 (2, 8)
11 5 (3, 7)
5 7 (4, 6)
7 (5, 5)
Algorithm Terminates
These are all points for Octant-1.
(0, 8) (5, 5)
(1, 8) (6, 4)
(2, 8) (7, 3)
(3, 7) (8, 2)
(4, 6) (8, 1)
(5, 5) (8, 0)
These are all points for Quadrant-1.
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-
Given the centre point coordinates (10, 10) and radius as 10,
generate all the points to form a circle.
Solution-
Given-
•Centre Coordinates of Circle (X0, Y0) = (10, 10)
•Radius of Circle = 10
Step-01:
Step-02:
Thus,
•Xk+1 = Xk + 1 = 0 + 1 = 1
•Yk+1 = Yk = 10
•Pk+1 = Pk + 4 x Xk+1 + 6 = -17 + (4 x 1) + 6 = -7
Step-04:
This step is applicable here as the given centre point coordinates is (10, 10).
Xplot = Xc + X0 = 1 + 10 = 11
Yplot = Yc + Y0 = 10 + 10 = 20
Step-05:
Step-03 and Step-04 are executed similarly until Xplot => Yplot as follows-