Академический Документы
Профессиональный Документы
Культура Документы
a )
( x xc ) 2 a2 + ( y yc ) 2 b2 = 1 (a )
Where (xc , yc)= center of the ellipse a = length of major axis b = length of minor axis
fig. a
When the polynomial method is used to define an ellipse, the value of .x is incremented from xc to a. For each step of x, each value of y is found by evaluating the expression
y = b 1 ( x xc ) 2 a2 + y c (b)
Because an ellipse shows four way symmetry; we must calculate pixel positions along the elliptical are through one quadrant, then we obtain positions in the remaining three quadrants by symmetry (fig- b)
Fig - b
From fig - (a) if the distance to the two foci from point P = (x, y) on the ellipse are labeled d1 and d2, then the general equation of an ellipse can be stated as d1+d2 = constant
{( x x )
1
+ ( y y1 )
+ ( x x 2 ) 2 + ( y y 2 ) 2 = constant -------------(c)
Where F1=(x1,y1) and F2 = (x2,y2) are the focal coordinates. By squaring the equation -(c), we can rewrite the general ellipse equation in the form Ax2 + B2 + Cxy + Dx + Ey + F = 0 ----------------------------------(d)
The coefficients, A, B, C, D, E and F are evaluated in terms of the focal coordinates and the dimensions of the major and minor axes of the ellipse.
Steps of generating an ellipse using the polynomial method: 1. Set the initial variables: a = length of major axis; b = length of minor axis; (xc, yc) = center of the ellipse; x=0; i=step size; xend = a ;
2. Tests to determine whether the entire ellipse has been scan converted. If x > xend stop. 3. Compute the value of y coordinate; y = b {1 - (x2/a2)}; 4. Plot the four points, found by symmetry, at the current (x, y) coordinates as (fig - b)
P1 (x+
xC , y + yc)
P3 (- x+ xc , -y + yc)
5. Increment x: x = x + i 6. Go to step-2.
Algorithm for trigonometric (Polar) method: 1. Set the initial variables: a = length of major axis; b = length of minor axis; (xc, yc) = center of the ellipse; =0; end = /2; i = step size;
2. Tests to determine whether the entire ellipse has been scan converted. If > end stop. 3. Compute the value of the x and v coordinates as x = a cos and y = b sin . 4. Plot the four points, found by symmetry, at the current (x, y) coordinates as (fig - b)
PI(X+ xc
, y + yc)
5. Go to step-2. Ellipse axix rotation Since the ellipse shows the four ways symmetry, it can be easily rotated 90 by changing a and b.
( x xc ) b
2
( y yc ) a2
=1
b = length of major axis; a = length of minor axis; (xc , yc) = center of the ellipse
Now we start at (0, ry) we take unit step in the 'x' direction until we reach the boundary between region-1 and region-2. Then we switch to unit steps in the 'y' direction over the remainder of the curve in the first quadrant. dy =0 From eq-(a) 2ry2x + 2rx2y dx
Or
At the boundary between region-1 and region-2, dy dx = 1 Thus 2ry2x = 2rx2y --------- (d)
Thererefore we move out of region-1 whenever 2ry2x > 2rx2y -----(e) Consider the position (xk, yk) has been selected in region-1 (Fig-d). In this region decision parameter is P1k- We decide what is the next pixel.
P1k = fellipes(xk+1,yk-1/2)
Next sampling position (xk+1 + 1 =xk + 2 or xk+2), the decision parameter for region- 1 is evaluated as
P1k+1 = fellipse (x k+1+1, y k+1 1/2 )
= r y 2 {(x k + 1)+1} 2 + r x 2 (y k+1 - ) 2 - r x 2 r y 2 + r x 2 (y k - ) 2 - r x 2 (y k - ) = r y 2 (x k + 1) 2 +r x 2 (y k - 1 / 2 ) 2 r x 2 r y 2 + 2r y 2 (x k +1)+r y 2 +r x 2 (y k +1- 1 / 2 ) 2 -r x 2 (y k - 1 / 2 ) 2 = P1 k + 2r y 2 (x k +l)+ r y 2 +r x 2 (y k+1 ) 2 r x 2 (y k ) 2 Plk+1 = P1k + 2ry2xk+1+ ry2+ rx2(yk+1 1/2)2- rx2(yk )2 -------------(g)
In above equation the value of yk+1 = yk or yk - 1 depend upon the sign of Plk. For right choice we consider the followings: * If P1k < 0 then yk+1 = yk and from eq-(g) we get
Plk+1 = P1k + 2ry2xk+1+ ry2+ rx2(yk+1 1/2)2- rx2(yk )2 Plk+1 = P1k + 2ry2xk+1+ ry2 ------------------------------------------------------(h-A)
In region- 1 the initial value of the decision parameter is obtained from (xo, yo) = (0, ry)
P10 = fellips (0,ry - ) P10 = ry2(0+1)2 + rx2(ry )2 rx2ry2 P10 = ry2 +rx2ry2 rx2ry + -rx2ry2 ---------------------------------------------------------- (i) P10 = ry2 rx2ry + rx2
If P2k > 0 , the midpoint is outside the ellipse boundary. In that case next scan converted pixel is
(xk+1 , yk+1 = xk, yk-1) If P2k 0, the midpoint is inside or on the ellipse boundary. In that case next scan converted pixel is (xk+1 , yk+1 = xk+1, yk-1).
For next sampling point, y value is yk+1 -1 whose decision parameter P2k+1 P2k+1 = feillipse(xk+1 + 1/2 , yk+1 1) P2k+1 = ry2(xk+1 + )2 + rx2 {(yk-1)-1}2 rx2ry2 P2k+1 = ry2(xk+1 + )2 + rx2{(yk-1) 1}2 rx2ry2 + ry2(xk + )2 ry2(xk + )2 = ry2(xk+1 + )2 + rx2(yk-1)2 2rx2(yk-1) + rx2 rx2ry2 + ry2(xk + )2 ry2(xk + )2 = ry2(xk+1 +1/2)2 + ry2(xk + )2 + rx2(yk-1)2 rx2ry2 2rx2(yk-1) +rx2 ry2(xk + )2 = P2k + ry2(xk+1 + )2 ry2(xk + )2 -2rx2(yk-1) + rx2 P2k+1 = P2k + ry2{(xk+1 + )2 (xk + )2} 2rx2(yk 1) + rx2 --------------------------(k)
In above equation the value of xk+1 = xk or xk +1 depend upon the sign of P2k, For right choice we consider the followings:
* If P2k > 0 then xk+1 = xk and from eq-(k) we get P2k+1 = P2k + ry2{(xk + )2 (xk + )2} 2rx2(yk-1) + rx2 P2k +1 = P2k 2rx2yk+1 + rx2 ------------------------------------------- (l-A) * lfP2k 0 then xk+1 = xk + 1 and from eq-(k) we get
P2k+1 =P2k+ ry2{(xk+1 + 1/2)2-(xk+ )2} -2rx2(yk - 1)+rx2 P2k+1 =P2k + ry2[{(xk+l)+ }2 -(xk+ 1/2)2]-2rx2(yk- 1)+ rx2
=
= P2k + ry2({xk2+ xk +(1/2 )2+ (xk+1) + (xk+1)} - (xk+ 1/2)2] -2rx2 (yk- 1)+ rx2 = P2k + ry2[(xk+1/2)2+ 2(xk+1) - (xk+ 1/2)2]-2rx2yk+1+ rx2 = P2k + 2ry2 xk+1 -2rx2yk+1+ rx2 P2k+1 ,=P2k + 2(ry2xk+1 , -rx2yk+1) + rx2 For initial parameter P2,P20 (l-B) , we conider the last point of
region -1as(x0,y0) P20= fellips e(x0+ 1/2 , y0 1) = ry2{(x0 + )2 + ry2 (y0 1)2} rx2 ry2 Or simply the equation as consider the first point of region -2 as (rx ,0).The more positive y-direction up to the last position selected region-1
1 Input rx, ry and ellipse center (xc, yc) and obtain the first point on an ellipse centered on the origin as (x0, y0) = (0, ry). 2. Calculate the initial value of decision parameter in region -1 as Plo = ry2-rx2ry + rx2. 3. At each 'xk ' position in region-1 , starting at k = 0, perform the following test:
.
* If P1k < 0, then next point is (xk+1, yk+1) = (xk + 1, yk) and next decision parameter is P1 k+1 P1 k + 2r y 2 x k+1 + r y 2 * If P1k 0 then next point is (xk+1, y k+1) = (x k + 1, y k) and next decision parameter is P1k+1 - Pl k + 2(ry2x k+1-rx2y k+1) + ry2 4. Cotinue step -3 until 2ry2x 2rx2 y. 5 Calculate the initial value of decision parameter in region -2 using the last point at region -1 as (X0, y0) as P2 0 = r y 2 (x 0 + ) 2 + r x 2 (y 0 -1) 2 - r x 2 r y 2 6. At each 'yk 'position in region-2, starting at k = 0, perform the following test: * If P2k > 0, then next point (xk+1, yk+1) = (xk + 1, yk -1)and next decision parameter is P2k+1 = P2k -2rx2yk+1+ rx2 * If P2k 0, then next point is (xk+1 yk+1)= (xk+1, yk -1) and next decision parameter is P2k+1 =P2k + 2(ry2Xk+1 - rx2yk+1)+ rx2 7 Determine symmetry points in other three quadrants as [fig - b] P1 (x+ xc , y + yc)
P3 (- x+ xc , -y + yc)
P2 (x + xc , - y + yc)
P4 (-x+ xc , y + yc)
8. Repeat the steps for region -2. *** See the books Hearn & Backer