0% found this document useful (0 votes)
8 views

Circle Drawing Algorithms

Uploaded by

asm.shafi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Circle Drawing Algorithms

Uploaded by

asm.shafi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Circle Drawing Algorithms

In computer graphics, popular algorithms used to generate circle are-


1. Bresenham Circle Drawing Algorithm
2. Mid Point Circle Drawing Algorithm
Bresenham Circle Drawing Algorithm
Given the starting point and radius of circle, Bresenham Circle Drawing Algorithm attempts to
generate the points of one octant. The points for other octacts are generated using the eight
symmetry property.
Procedure
Given-
• Starting point of Circle = (XC, YC)
• Radius of Circle = r
The points generation using Bresenham Circle Drawing Algorithm involves the following steps-
Step 1: Set the initial value
X0 = 0
Y0 = r
Step 2: Calculate the value of initial decision parameter P0 as-
PK = 3 – 2 r
Step 3: 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 4: 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
Here, (Xc, Yc) denotes the current value of X and Y coordinates.
Step 5: Keep repeating Step-03 and Step-04 until Xplot => Yplot.
Step 6: 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-

Problem 1

Given the centre point coordinates (0, 0) and radius as 8, generate all the points to form a circle.

Solution 1

Given,

Centre Coordinates of Circle (X0, Y0) = (0, 0)

Radius of Circle = 8

X0 = 0
Y0 = r = 8
PK = 3 – 2 x r = 3 - 2(8) = -13
Here, PK < 0
Pk Pk+1 (Xk+1, Yk+1)

(0, 8)

-13 -13 + (4 x 1) + 6 = -3 (1, 8)

-3 -3 + (4 x 2) + 6 = 11 (2, 8)

11 11 + 4 (3 -7) + 10 = 5 (3, 7)

5 5 + 4 (4 - 6) + 10 = 7 (4, 6)

7 (5, 5)

Algorithm Terminates

These are all points for Octant-1.

Now, the points of octant-2 are obtained using the mirror effect by swapping X and Y coordinates.

Octant-1 Points Octant-2 Points

(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.

Quadrant-1 Quadrant-2 Quadrant-3 Quadrant-4

Octant Octant 2- Octant Octant Octant Octant Octant Octant


1-Points Points 3-Points 4-Points 5-Points 6-Points 7-Points 8-Points
(X, Y) (Y, X) (-X, Y) (Y, -X) (-X, -Y) (-Y, -X) (X, -Y) (-Y, X)

(0, 8) 5, 5 (0, 8) 5, -5 (0, -8) -5, -5 (0, -8) -5, 5

(1, 8) 6, 4 (-1, 8) 6, -4 (-1, -8) -6, -4 (1, -8) -6, 4

(2, 8) 7, 3 (-2, 8) 7, -3 (-2, -8) -7, -3 (2, -8) -7, 3

(3, 7) 8, 2 (-3, 7) 8, -2 (-3, -7) -8, -2 (3, -7) -8, 2

(4, 6) 8, 1 (-4, 6) 8, -1 (-4, -6) -8, -1 (4, -6) -8, 1

(5, 5) 8, 0 (-5, 5) 8, 0 (-5, -5) -8, 0 (5, -5) -8, 0

These are all points of the Circle.

Problem 2

Given the centre point coordinates (2, 2) and radius as 8, generate all the points to form a circle.

Solution 2

Given,

Centre Coordinates of Circle (XC, YC) = (2, 2)

Radius of Circle = 8

X0 = 0
Y0 = r = 8
PK = 3 – 2 x r = 3 - 2(8) = -13
Here, PK < 0
Pk Pk+1 (Xk+1, Yk+1) (Xplot, Yplot)

(0, 8) (2, 10)

-13 -13 + (4 x 1) + 6 = -3 (1, 8) (3, 10)

-3 -3 + (4 x 2) + 6 = 11 (2, 8) (4, 10)

11 11 + 4 (3 -7) + 10 = 5 (3, 7) (5, 9)

5 5 + 4 (4 - 6) + 10 = 7 (4, 6) (6, 8)

7 (5, 5) (7, 7)

Algorithm Terminates

These are all points for Octant-1.

Now, the points of octant-2 are obtained using the mirror effect by swapping X and Y coordinates.

Octant-1 Points Octant-2 Points

(2, 10) (7, 7)

(3, 10) (8, 6)

(4, 10) (9, 5)

(5, 9) (10, 4)

(6, 8) (10, 3)

(7, 7) (10, 2)

These are all points for Quadrant-1.


Now, the points for rest of the part are generated by following the signs of other quadrants.

Quadrant-1 Quadrant-2 Quadrant-3 Quadrant-4

Octant Octant 2- Octant Octant Octant Octant Octant Octant


1-Points Points 3-Points 4-Points 5-Points 6-Points 7-Points 8-Points
(X, Y) (Y, X) (-X, Y) (Y, -X) (-X, -Y) (-Y, -X) (X, -Y) (-Y, X)

(2, 10) (7, 7) (-2, 10) (7, -7) (-2, -10) (-7, -7) (2, -10) (-7, 7)

(3, 10) (8, 6) (-3, 10) (8, -6) (-3, -10) (-8, -6) (3, -10) (-8, 6)

(4, 10) (9, 5) (-4, 10) (9, -5) (-4, -10) (-9, -5) (4, -10) (-9, 5)

(5, 9) (10, 4) (-5, 9) (10, -4) (-5, -9) (-10, -4) (5, -9) (-10, 4)

(6, 8) (10, 3) (-6, 8) (10, -3) (-6, -8) (-10, -3) (6, -8) (-10, 3)

(7, 7) (10, 2) (-7, 7) (10, -2) (-7, -7) (-10, -2) (7, -7) (-10, 2)

These are all points of the Circle.

Mid Point Circle Drawing Algorithm


Given the starting point and radius of circle, Mid Point Circle Drawing Algorithm attempts to
generate the points of one octant. The points for other octacts are generated using the eight
symmetry property.
Procedure
Given-
• Starting point of Circle = (XC, YC)
• Radius of Circle = r
The points generation using Mid Point Circle Drawing Algorithm involves the following steps-
Step 1: Set the initial value
X0 = 0
Y0 = r
Step 2: Calculate the value of initial decision parameter P0 as-
PK = 1 – r
Step 3: 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 4: 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
Here, (Xc, Yc) denotes the current value of X and Y coordinates.
Step 5: Keep repeating Step-03 and Step-04 until Xplot => Yplot.
Step 6: 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-
Problem 3

Given the center point coordinates (0, 0) and radius as 10, generate all the points to form a circle.

Solution 3

Given,

Starting Coordinates of Circle (X0, Y0) = (0, 0)

Radius of Circle = 10

X0 = 0
Y0 = r = 10
PK = 1 - r = 1 - 10 = -9
Here, PK < 0
Pk Pk+1 (Xk+1, Yk+1)

(0, 10)

-9 -9 + 2(1) + 1 = -6 (1, 10)


-6 -6 + 2(2) + 1 = -1 (2, 10)

-1 -1 + 2(3) + 1 = 6 (3, 10)

6 6 - 2(9) + 2(4) + 1 = -3 (4, 9)

-3 -3 + 2(5) + 1 = 8 (5, 9)

8 8 – 2(8) + 2(6) + 1 = 5 (6, 8)

5 (7, 7)

Algorithm Terminates

These are all points for Octant-1.

Now, the points of octant-2 are obtained using the mirror effect by swapping X and Y coordinates.

Octant-1 Points Octant-2 Points

(0, 10) (7, 7)

(1, 10) (8, 6)

(2, 10) (9, 5)

(3, 10) (9, 4)

(4, 9) (10, 3)

(5, 9) (10, 2)

(6, 8) (10, 1)

(7, 7) (10, 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.

Quadrant-1 Quadrant-2 Quadrant-3 Quadrant-4

Octant Octant 2- Octant Octant Octant Octant Octant Octant


1-Points Points 3-Points 4-Points 5-Points 6-Points 7-Points 8-Points
(X, Y) (Y, X) (-X, Y) (Y, -X) (-X, -Y) (-Y, -X) (X, -Y) (-Y, X)

(0, 10) (7, 7) (0, 10) (7, -7) (0, -10) (-7, -7) (0, -10) (-7, 7)

(1, 10) (8, 6) (-1, 10) (8, -6) (-1, -10) (-8, -6) (1, -10) (-8, 6)

(2, 10) (9, 5) (-2, 10) (9, -5) (-2, -10) (-9, -5) (2, -10) (-9, 5)

(3, 10) (9, 4) (-3, 10) (9, -4) (-3, -10) (-9, -4) (3, -10) (-9, 4)

(4, 9) (10, 3) (-4, 9) (10, -3) (-4, -9) (-10, -3) (4, -9) (-10, 3)

(5, 9) (10, 2) (-5, 9) (10, -2) (-5, -9) (-10, -2) (5, -9) (-10, 2)

(6, 8) (10, 1) (-6, 8) (10, -1) (-6, -8) (-10, -1) (6, -8) (-10, 1)

(7, 7) (10, 0) (-7, 7) (10, 0) (-7, -7) (-10, 0) (7, -7) (-10, 0)

These are all points of the Circle.

Problem 4

Given the starting point coordinates (4, -4) and radius as 10, generate all the points to form a circle.

Solution 4

Given,

Starting Coordinates of Circle (XC, YC) = (4, -4)

Radius of Circle = 10

X0 = 0
Y0 = r = 10
PK = 1 - r = 1 - 10 = -9
Here, PK < 0
Pk Pk+1 (Xk+1, Yk+1) (Xplot, Yplot)

(0, 10) (4, 6)

-9 -9 + 2(1) + 1 = -6 (1, 10) (5, 6)

-6 -6 + 2(2) + 1 = -1 (2, 10) (6, 6)

-1 -1 + 2(3) + 1 = 6 (3, 10) (7, 6)

6 6 - 2(9) + 2(4) + 1 = -3 (4, 9) (8, 5)

-3 -3 + 2(5) + 1 = 8 (5, 9) (9, 5)

8 8 – 2(8) + 2(6) + 1 = 5 (6, 8) (10, 4)

5 (7, 7) (11, 3)

Algorithm Terminates

These are all points for Octant-1.

Now, the points of octant-2 are obtained using the mirror effect by swapping X and Y coordinates.

Octant-1 Points Octant-2 Points

(4, 6) (3, 11)

(5, 6) (4, 10)

(6, 6) (5, 9)

(7, 6) (5, 8)

(8, 5) (6, 7)

(9, 5) (6, 6)

(10, 4) (6, 5)

(11, 3) (6, 4)

These are all points for Quadrant-1.


Now, the points for rest of the part are generated by following the signs of other quadrants.

Quadrant-1 Quadrant-2 Quadrant-3 Quadrant-4

Octant Octant 2- Octant Octant Octant Octant Octant Octant


1-Points Points 3-Points 4-Points 5-Points 6-Points 7-Points 8-Points
(X, Y) (Y, X) (-X, Y) (Y, -X) (-X, -Y) (-Y, -X) (X, -Y) (-Y, X)

(4, 6) (3, 11) (-4, 6) (3, -11) (-4, -6) (-3, -11) (4, -6) (-3, 11)

(5, 6) (4, 10) (-5, 6) (4, -10) (-5, -6) (-4, -10) (5, -6) (-4, 10)

(6, 6) (5, 9) (-6, 6) (5, -9) (-6, -6) (-5, -9) (6, -6) (-5, 9)

(7, 6) (5, 8) (-7, 6) (5, -8) (-7, -6) (-5, -8) (7, -6) (-5, 8)

(8, 5) (6, 7) (-8, 5) (6, -7) (-8, -5) (-6, -7) (8, -5) (-6, 7)

(9, 5) (6, 6) (-9, 5) (6, -6) (-9, -5) (-6, -6) (9, -5) (-6, 6)

(10, 4) (6, 5) (-10, 4) (6, -5) (-10, -4) (-6, -5) (10, -4) (-6, 5)

(11, 3) (6, 4) (-11, 3) (6, -4) (-11, -3) (-6, -4) (11, -3) (-6, 4)

These are all points of the Circle.

You might also like