ellipse generating algorithms 1. definition ellipse is an elongated circle. elliptical curves can be...
TRANSCRIPT
ELLIPSE GENERATING ALGORITHMS
1
DEFINITION
Ellipse is an elongated circle.
Elliptical curves can be generated by
modifying circle-drawing procedures to
take into account the different dimensions of
an ellipse along the major and minor axes.
2
PROPERTIES OF ELLIPSES
Distances from any point on the ellipse to two
fixed positions called the foci of the ellipse.
Sum of these two distances is the same values
for all points on the ellipse. d1+d2=constant
3
Expressing distances d1 and d2 in terms of the focal coordinates F1=(x1,y2) and F2=(x2,y2)
sqrt((x-x1)2+(y-y1)2)+sqrt((x-x2)2+(y-y2)2)=constant
The general ellipse equation in the form Ax2+By2+Cxy+Dx+Ey+F=0
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.
4
The major axis is the straight line segment extending from one side of the ellipse to the other through the foci.
The minor axis spans the shorter dimension of the ellipse, perpendicularly bisecting the major axis at the halfway position (ellipse center) between the two foci.
5
((x-xc)/rx)2+((y-yc)/ry)2=1
Polar coordinates r and θx=xc+rxcos θ y=yc+rxsin θ
6
MIDPOINT ELLIPSE ALGORITHM
The Ellipse function isfellipse (x,y)=ry
2x2+rx2y2 –rx
2 ry2
which has the following properties: fellipse (x,y)
<0, if (x,y) is inside the ellipse boundary =0, if(x,y) is on ellipse boundary >0, if(x,y) is outside the ellipse boundary
7
REGION 1 AND 2 CAN BE PROCESSED IN VARIOUS WAYS
STEP 1 : Start at position (0,ry) and step clockwise along the elliptical path in the first quadrant shifting from unit steps in x to unit steps in y when the slope becomes less than -1 STEP2 : Start at (rx,0) and select points in a counter clockwise order. Shifting from unit steps in y to unit steps in x when the slope becomes greater than -1.0 2.2 Using parallel processors calculate pixel positions in the two regions simultaneouslySTEP 3: Start at (0,ry) step along the ellipse path in clockwise order throughout the first quadrant ellipse function (xc,yc)=(0,0)
fellipse (x,y)=ry2x2+rx
2y2 –rx2 ry
2 8
STEP 4: Check the properties
Ellipse function fellipse (x,y) serves as the decision parameter in the midpoint algorithm. Starting at (0,ry)
The ellipse slope is calculated dy/dx= -(2ry2x/2rx
2y) At the boundary between region 1 and region 2 dy/dx
= -1.0 2ry
2x=2rx2y
Move out of region 1 ; 2ry2x>=2rx
2y
9
To determine the next position along the ellipse path by evaluating the decision parameter at this mid point
P1k = fellipse (xk+1,yk - 1/2)
= ry2 (xk+1)2 + rx
2 (yk-1/2)2 – rx2 ry
2
if P1k <0,
Midpoint is inside the ellipse Otherwise the midpoint is outside
Next sampling position (xk+1+1=xk+2) the decision parameter for region 1 is calculated as
p1k+1 = fellipse(xk+1 +1,yk+1 -½ )
=ry2[(xk +1) + 1]2 + rx
2 (yk+1 -½)2 - rx2 ry
2
OR p1k+1 = p1k +2 ry2(xk +1) + ry
2 + rx2 [(yk+1 -½)2 - (yk -
½)2] Where yk+1 is yk or yk-1 depending on the sign of P1k. 10
Decision parameters are incremented by the following amounts increment
= { 2 ry2(xk +1) + ry
2 if p1k <0 }
{ 2 ry2(xk +1) + ry
2 - 2rx2 yk+1 if p1k ≥ 0 }
Increments for the decision parameters can be calculated using only addition and subtraction as in the circle algorithm.
The terms 2ry2x and 2rx2y can be obtained incrementally. At the initial position (0,ry) these two terms evaluate to 2 ry
2x = 0
2rx2 y =2rx
2 ry
11
Decision parameter is evaluated as
p10 = fellipse(1,ry -½ )
= ry2 + rx
2 (ry -½)2 - rx2 ry
2
Or p10 = ry
2 - rx2 ry + ¼ rx
2
12
REGION 2 For this region, the decision parameter is evaluated
as
p2k = fellipse(xk +½ ,yk - 1)
= ry2 (xk +½ )2 + rx
2 (yk - 1)2 - rx2 ry
2
P2k+1 = fellipse(xk+1 +½,yk+1 -1 )
= ry2(xk +½) 2 + rx
2 [(yk+1 -1) -1]2 - rx2 ry
2
or p2k+1 = p2k -2 rx
2(yk -1) + rx2 + ry
2 [(xk+1 +½)2 - (xk +½)2]
Decision parameter for region 2 p20 = fellipse(x0 +½ ,y0 - 1)
= ry2 (x0 +½ )2 + rx
2 (y0 - 1)2 - rx2 ry
2 13
ALGORITHM
14