Computer Graphics: Circle Generating Algorithm: Week 6 Session 2
Computer Graphics: Circle Generating Algorithm: Week 6 Session 2
Week 6 Session 2
By
Razia Nisar Noorani
Assistant professor
FYP(IT) COORdinator
SSUET, Karachi, Pakistan
OBJECTIVE:
Circle Generating Algorithm
• Circle
• Properties of circle
• Circle Generating Algorithm
• Example: Centre of circle at origin
• Example: Centre of circle not at origin
• Advantages of circle generating Algorithm
• Disadvantages of circle generating Algorithm
CIRCLE
A circle is a closed curve consisting of all points in a plane
which are at the same distance (equidistant) from a fixed point
inside it.
This fixed point is called “Centre”.
Properties of Circle
A circle has only one centre
A line segment that joins any point on the
circle to its centre is called “Radius”
Half of a Circle is called “Semi-Circle”
A line segment that joins any two points on the circle is called a chord.
Set of points that are all given at distance “r” from the centre position (Xc , Yc)
The points for other octants are generated using the eight symmetry property (X – Xc)2
(Xc , Yc)
(Mirror Technique)
2nd Quadrant ( -X , Y ) 1st Quadrant ( X , Y )
5th Octant
8th Octant
3rd Quadrant ( -X , -Y )
4th Quadrant ( X , -Y )
Mid Point Circle Generating Algorithm
STEPS:
If P < 0
k
X = X +1 Y = Y P = P + 2(X ) + 1
k+1 k k+1 k k+1 k k+1
If P > = 0
k
X = X Y = Y – 1 P = P - 2(Y ) + 2(X ) + 1
k+1 k k+1 k k+1 k k+1 k+1
Example : When Circle is on origin ( 0 , 0 )
Given the centre point coordinates (0, 0) and radius as 10, generate all the points to form a circle.
Given:
Centre Coordinates of Circle (Xc, Yc) = (0, 0) Radius of Circle = r = 10
For octant 2
• Reverse and swaps octant 1 points
Quadrant 1:
• Combining the points of Octant 1 and octant 2 will result the complete points of quadrant 1
To the points of remaining quadrant are obtained using the mirror effect by changing X and Y coordinates.
That is:
Mid Point Circle Generating Algorithm (Centre not at
origin)
-- 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
+ (Xc , Yc)
Note: For Quadrant 2 3 and 4