Page 91 - DCAP313_LAB_ON_COMPUTER_GRAPHICS
P. 91
Unit 5: Implementing Ellipse Algorithm
do if (|r[2][i]| < EPS)48 then nychk ← nychk + 1 Notes
ychk[nychk] ← r[1][i]*B1
for j ← 2 to nychk by 1
tmp0 ← ychk[j]
for k ← (j – 1) to 1 by –1
do if (ychk[k] ≤ tmp0)
then break
else ychk[k+1] ← ychk[k]56 ychk[k+1] ← tmp0
nintpts
then x1 ← 0
else x1 ← A 1 *sqrt (1.0 – ychk[i]2/B 12 )
x 2 ← –x 1
do if (|ellipse2tr (x1,ychk[i],AA,BB,CC,DD,EE,FF)| < EPS/2)
then nintpts ← nintpts + 1
do if (nintpts > 4)
then return (–1, ERROR_INTERSECTION_PTS)
xint[nintpts] ← x 1
yint[nintpts] ← ychk[i]
do if ((|ellipse2tr (x2, ychk[i],AA,BB,CC,DD,EE,FF)| < EPS/2)
and (|x 2 – x 1 | > EPS/2))
then nintpts ← nintpts + 1
do if (nintpts > 4)
then return (–1, ERROR_INTERSECTION_PTS)76 xint[nintpts] ← x1
yint[nintpts] ← ychk[i]
switch (nintpts) : HANDLE ALL CASES FOR # OF INTERSECTION PTS
case 0:
case 1:
(OverlapArea,Code) ← NOINTPTS (A 1 ,B 1 ,A 2 ,B 2 ,H 1 ,K 1 ,H 2 ,K 2 ,AA,BB,CC,DD,EE,FF)
return (OverlapArea,Code)
case 2:
Code ← istanpt (xint[1],yint[1],A1,B1,AA,BB,CC,DD,EE,FF)
do if (Code == TANGENT_POINT)
then (OverlapArea,Code) ← NOINTPTS (A 1 ,B 1 ,A 2 ,B 2 ,H 1 ,K 1 ,H 2 ,K 2 ,AA,BB,CC,DD,EE,FF)
else (OverlapArea,Code) ← TWOINTPTS (xint[],yint[],A1,
PHI_1,A 2 ,B 2 ,H 2 _TR,K 2 _TR,PHI_2,AA,BB,CC,DD,EE,FF)
LOVELY PROFESSIONAL UNIVERSITY 85