Week 3 Circle Generating Algorithm
Week 3 Circle Generating Algorithm
-y,x y,x
-x,y x,y
-x,-y x,-y
y,-x
-y,-x
Scan Converting a Circle using Polynomial method:-
This method defines a circle with second order
polynomial equation
y2 = r2 – x2
where x, y = x & y coordinates, r = radius
y r
x
0 x
• However, unsurprisingly this is not a brilliant
solution!
• Firstly, the resulting circle has large gaps
where the slope approaches the vertical
• Secondly, the calculations are not very
efficient
– The square (multiply) operations
– The square root operation – try really hard to
avoid these!
• We need a more efficient, more accurate
solution
Scan Convert a Circle using trigonometric
method:-
This second method of defining a circle uses
functions : x = r cos θ, y = r sin θ
y
P(r cos θ,r sin θ)
r sin θ
θ
x
r cos θ
θ = current angle, r = circle radius
By this method θ is stepped from θ to π /4
& each value of x & y is calculated.
Computation of values of sin θ & cos θ are
very time consuming
Bresenham’s Circle Algorithm
Working: If the eight-way symmetry of a circle is used
to generate a circle, points will have to be
generated through 45º angle. And, if points are
generated from 90º to 45º, moves will be made
only in the +x and –y directions.
T (xi+1,yi)
yi
(xi+1,yi-1)
yi -1
S
xi xi + 1 x
• Assume that (xi, yi) are the coordinates of the
last scan-converted pixel upon entering step i.
• Let the distance from the origin to pixel T
squared minus the distance to the true circle
squared = D(T) = t2 – r2.
• And let the distance from the origin to pixel S
squared minus the distance to the true circle
squared = D(S) = s2 – r2.
• Coordinates of T are (xi +1, yi)
S are (xi +1, yi – 1)
• Following expressions can be developed:
D(T) = (xi + 1)2 + yi2 – r2
D(S) = (xi + 1)2 + (yi – 1)2 – r2
18
Consider origin centered circle with radius 8
(-y, x) (y, x)
R
2
(-y, -x) (y, -x)
31