Midpoint Ellipse Eq of ellipse is given by
Midpoint Ellipse
Eq. of ellipse is given by x 2/r 2 x + y 2/r 2 y = 1 Which gives f(x, y)= x 2 r 2 y + y 2 r 2 x – r 2 xr 2 y =0 And dy/dx= -2 x r 2 y/2 y r 2 x Region 1: in region 1 “for a small change in y in –ve direction leads to big change in x in +ve direction” i. e dy/dx > -1 so 2 x r 2 y/2 y r 2 x <1 2 x r 2 y<2 y r 2 x Region 2: in region 2 “for a small change in x in –ve direction leads to big change in y in +ve direction” i. e dy/dx < -1 so 2 x r 2 y/2 y r 2 x >1 2 x r 2 y>2 y r 2 x
We start the generation of ellipse from the point (0, ry) i. e a point on the y axis and continue to find the points on the ellipse in region 1 under the condition given by 2 x r 2 y<2 y r 2 x A point where 2 x r 2 y=2 y r 2 x is the point which divides the ellipse into 2 regions (0, ry) R 1 R 2 (rx, 0)
(0, ry) R 1 R 2 (rx, 0)
Midpoint Ellipse Algorithm • Input and ellipse center and obtain the first point on an ellipse centered on the origin as • Calculate the initial value of the decision parameter in region 1 as
Midpoint Ellipse. . • At each position in region 1, starting at k = 0, perform the following test. if , the next point along the ellipse centered on (0, 0) is and • Otherwise, the next point along the ellipse is and with and continue until
Midpoint Ellipse Contd. • Calculate the initial value of the decision parameter in region 2 as where is the last position calculated in region 1 • At each position in region 2, starting at k=0, perform the following test. if , the next point along the ellipse centered on (0, 0) is and • Otherwise, the next point along the ellipse is and • Using the same incremental calculations for x and y as in region 1. Continue until y=0
Midpoint Ellipse • For both regions, determine symmetry points in the other three quadrants • Move each calculated pixel position (x, y) onto the elliptical path that is centered on and plot the coordinate values
1. Input xr, yr and ellipse center (xc, yc) and obtain the first point on an ellipse 2. centered on the origin as (x 0, y 0)=(0, rx) 3. 2. Calculate the initial value of the decision parameter in region 1 as 4. P 10=r 2 y-r 2 xry+1/4 r 2 x 3. At each xk position in r 1, starting at k=0, perform the following test: if P 10 < 0, then next point along the ellipse centered on (0. 0) is (xk+1, yk) and p 1 k+1=p 1 k+2 r 2 yxk+1+r 2 y Otherwise the next point along the ellipse is (xk+1, y-1) and the p 1 k+1=p 1 k+2 r 2 yxk+1 -2 r 2 xyk+1+r 2 y With x. K+1 is xk+1 and yk+1 is yk-1 Continue the above step until 2 r 2 yx>=2 r 2 xy
4. Calculate the initial value of the decision parameter in region 2 using the last Point (x 0, y 0) calculated in region 1 as P 20=r 2 y(x 0+1/2)2+r 2 x(y 0 -1)2 -r 2 xr 2 y 5. At each yk position in region 2, starting at k=0, perform the following test: if P 2 k>0 , the next point along the ellipse is (xk, yk-1) and P 2 k+1=P 2 k-2 r 2 xyk+1 + r 2 x Otherwise P 2 k+1=P 2 k + 2 r 2 y xk+1 – 2 r 2 x yk+1 + r 2 x
- Slides: 12