1
Symmetry of circles
Polar Coordinates y
(-2, 8)
(-y, x) (2, 8)
9 (y, x)
(-8, 2) (8, 2)
(-x, y) (x, y)
x
9
(x, -y)
(-x, -y)
(8, -2)
(-8, -2) Generate pixel
positions around a
circle by calculating
(-y, -x) (y, -x) points within the
(-2, -8) (2, -8) sector x = 0 to x = y
2
Circle function
• fcircle (x,y) = x2 + y2 – r2
– fcircle (x,y) < 0, if (x,y) is inside the circle
boundary.
– fcircle (x,y) = 0, if (x,y) is on the circle
boundary.
– fcircle (x,y) > 0, if (x,y) is outside the circle
boundary.
W E
SE
S
3
Next Increments
• pk+1 = fcircle(xk+1+1,yk+1-1/2) Initial Decision parameter
• pk+1= pk+2(xk + 1)+(y2k+1 – y2k)–(yk+1 – yk)+1 • Taking the point (0,r)
• If pk < 0, yk+1 = yk • p0 = 1 + (r-1/2)2 – r2
– pk+1 = pk + 2(xk + 1) + 1
• [as xk+1 = xk+1]
• p0 = 5/4 – r
– pk+1 = pk + 2xk+1 + 1 • Round the value to make it an
• If pk >= 0, yk+1 = yk-1 integer
– pk+1 = pk + 2(xk + 1) + 1 – 2(yk – 1) • p0 = 1 - r
• [as xk+1 = xk+1]
4
Selected pixel positions
Example: r = 10 y=x
p0 = 1-
1-10 = -9, 2x0 = 0, 2y0 = 0
10
9
k pk (xk+1, yk+1) 2xk+1 2yk+1
8
0 -9 (1, 10) 2 20
7
1 -6 (2, 10) 4 20
6
2 -1 (3, 10) 6 20
5
3 6 (4, 9) 8 18
4
4 -3 (5, 9) 10 18
3
5 8 (6, 8) 12 16
2
6 5 (7, 7) 14 14
1
0
0 1 2 3 4 5 6 7 8 9 10
5
Major & Minor Axes
Simple case:
• Major axis is the
straight line y semi-major and • Is when the major and minor axes
segment extending semi-minor axes
from one side of the
are oriented to align with the
ellipse to the other. coordinate axes.
• Minor axis spans ry • rx semi-major axis.
the shorter
dimension of the
yc rx • ry semi-minor axis.
ellipse, bisecting the • Equation of the ellipse:
major axis at the – (x – xc/rx)2 + (y – yc/ry)2 = 1 . . . . . . . eq (1)
halfway position xc x
between the foci.
6
Midpoint ellipse algorithm
• Given parameters rx, ry and (xc, yc),
Midpoint algorithm (contd)
we determine points (x, y) for an • The algorithm is applied throughout
ellipse in a standard position the 1st quadrant in two stages.
centered at the origin. • The algorithm is devised for ellipses
• Once we have done that, we can do with rx < ry, although it can be
two things: generalized for all ellipses.
– Add xc and yc to translate the origin to • What do we do?
(xc, yc). – Divide the quadrant in 2 regions.
– If the ellipse was not aligned with the x- – Unit increment in x and once we have
reached the region boundary, we switch
y coordinates, then we can rotate about and unit increment in y.
the center to re-orient the major and
minor axes.