Professional Documents
Culture Documents
SRI LAXMI
2
of
39 Contents
KSL
y0 20 2 0 2 20
y1 20 2 12 20
y2 20 2 2 2 20
y19 20 2 19 2 6
y20 20 2 20 2 0
6
of A Simple Circle Drawing Algorithm
39
KSL
(cont…)
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
7
of
39 Eight-Way Symmetry
KSL
(-y, x) (y, x)
R
2
(-y, -x) (y, -x)
pk 1 f circ xk 1 1, yk 1 1 2
or:
[( xk 1) 1] yk 1
2
1
2
r
2
2
pk 1 pk 2( xk 1) ( yk21 yk2 ) ( yk 1 yk ) 1
where yk+1 is either yk or yk-1 depending on the
sign of pk
13
of
39
KSL
(ii) If Pk >0 then the next point along the circle is (xk+1,
yk-1) and:
pk 1 pk 2 xk 1 1 2 yk 1
where 2 xk 1 = 2Xk+2 and 2 yk 1 = 2Yk – 2
• Identify the symmetry points in the other seven
octants
• Move (x, y) according to:
x x xc y y yc
10 pk
k (xk+1,yk+1) 2xk+1 2yk+1
9
8 0 -9 (1,10) 2 20
7 1 -6 (2,10) 4 20
6
5 2 -1 (3,10) 6 20
4 3 6 (4,9) 8 18
3
2 4 -3 (5,9) 10 18
1
5 8 (6,8) 12 16
0
6 5 (7,7) 14 14
0 1 2 3 4 5 6 7 8 9 10
20
of
39 Mid-Point Circle Algorithm Exercise
KSL
1 2 3 4
24
of
39 Mid-Point Circle Algorithm (cont…)
KSL
1 2 3 4
25
of
39 Mid-Point Circle Algorithm (cont…)
KSL
M
5
1 2 3 4
26
of
39 Mid-Point Circle Algorithm (cont…)
KSL
6
M
5
1 2 3 4
27
of
39 Mid-Point Circle Algorithm (cont…)
KSL
6
M
5
3
28
of
39 Blank Grid
KSL
29
of
39 Blank Grid
KSL
30
of
39 Blank Grid
KSL
10
9
8
7
6
5
4
3
2
1
0
0 1 2 3 4 5 6 7 8 9 10
31
of
39 Blank Grid
KSL