Scan
Converting a circle
A circle is a geometric figure
which is round, and can be divided into 360 degrees. A circle is a symmetrical
figure which follows 8-way symmetry.
8-Way symmetry: Any circle follows 8-way
symmetry. This means that for every point (x,y) 8 points can be plotted. These
(x,y), (y,x), (-y,x), (-x,y), (-x,-y), (-y,-x), (y,-x),
(x,-y).
For any point (x+a, y+b), points
(x ± a, y ± b) and (y ± a, x ± b) also lie on the same circle. So it is
sufficient to compute only 1/8 of a circle, and all the other points can be
computed from it.
Drawing a circle: To draw a circle we need two
things, the coordinates of the centre and the radius of the circle.
Radius:
The
radius of a circle is the length of the line from the centre to any point on its
edge.
Equation of the
circle: For any
point on the circle (x,y) and the centre at point (xc,yc),
the equation of the circle is
(x-xc)2+ (y-yc) 2-
r2 =
0
Here
r is the radius of the circle. If
the circle has origin (0,0) as its centre then the above equation can be reduced
to
x2 + y2 =
r2
Using polar coordinate system the
point on the circle can be represented as:
x = r * cos
θ
y = r * sin θ
y = r * sin θ
θ is
the angle which the point makes With x-axis.
Direct
Method
(Polynomial method)
of Scan converting a
circle :
From
equation of the circle x2 +
y2 = r2 we
can derive that the value of y.
If we increment the value of x
from 0 to r, and find the corresponding value of y
for each x, we can draw a circle
very easily, by plotting the pixels (x,y), (-x,y), (-x,-y),
(x,-y).
Advantages :
- · This method is easy to understand.
- · Fairly easy to implement.
Disadvantages:
- · Inefficient method as time required for calculation of square and square root is very large.
- · Does not take full advantage of 8-way symmetry.
- · Value of y needs to be converted to integer every time.
- · The resulting circle has large gaps where the slope approaches the vertical. i.e. Increase in x direction is uniform but the gap in y is not uniform, it increases as the circle approaches the x-axis.
Polar
Equations method :
The
polar equations of the circle are
x = r * cos θ
y = r * sin θ
In this method we increment the
value of θ from
0 to 2π , and we find the corresponding values of x and y. For every
value of (x,y) thus calculated we can plot 7 other points taking advantage of
8-way symmetry.
Disadvantages:
·
The
main issue with this method is that calculation of cos and sin at each step take
a lot of time.
·
This
method is also inefficient, as it takes a lot of time.
Bresenham’s
Algorithm :
This is a circle drawing algorithm,
in which the value of x is incremented from 0 to