0% found this document useful (0 votes)
39 views18 pages

Lec 8 - Scan Converting An Ellipse

Uploaded by

Shafqat Ullah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views18 pages

Lec 8 - Scan Converting An Ellipse

Uploaded by

Shafqat Ullah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 18

Scan Converting an Ellipse

By: Riaz Oad


Lecturer IMCB H-9, Islamabad
What is Ellipse?
 Ellipse is an elongated circle.
 It generalizes a circle, which is the special type of ellipse in which the two focal
points are the same
 A circle is also an ellipse, where the foci are at the same point, which is the
center of the circle
 The ellipse is also a symmetric figure
like a circle but is four-way symmetry
rather than eight-way.
Major and Minor Axis
 Ellipse is defined by its two-axis along x and y-axis:
 Major axis:
 The major axis is the longest diameter of the ellipse.
 Denoted by ‘a’. (0,y2)
 Going through the center from one end to the other, at the broad part of the
ellipse.
 Minor Axis:
 The minor axis is the shortest diameter of ellipse. (x2,0)
 Denoted by ‘b’.
 Crossing through the center at the narrowest part.
 Half of major axis is called semi-major axis and half of minor axis is called
semi-minor axis.
Standard Equations of Ellipse
 When the center of the ellipse is at
the origin (0,0) and the foci are on
the x-axis and y-axis, then we can
easily derive the ellipse equation.
 The equation of the ellipse is given
by;
 1- For Horizontal ellipse
 x2/a2 + y2/b2 = 1 Or
b2x2 + a2y2 - a2b2 = 0
x2b2+y2a2/a2b2 = 1
b2x2 + a2y2 = a2b2
 b2x2 + a2y2 - a2b2 = 0
 Where a = rx2 & b = ry2
 Above eq can be written as:
ry2 x2 + rx2 y2 - rx2 ry2 = 0
 2- For vertical ellipse
 x2/b2 + y2/x2 = 1
Cases
 If we put any point in equation of ellipse we have three cases:

 Case 1: If x2/a2 + y2/b2 = 0


 Point lies on ellipse

 Case 2: If x2/a2 + y2/b2 < 0


 Point lies inside ellipse

 Case 3: If x2/a2 + y2/b2 > 0


 Point lies outside ellipse
Methods of defining an Ellipse

 There two mathematical methods of defining an Ellipse:

 1- Polynomial Method of defining an Ellipse


 2- Trigonometric method of defining an Ellipse
1- Polynomial Method

 The ellipse has a major and minor axis.


 If a1 and b1are major and minor axis respectively.
 The centre of ellipse is (i, j).
 The value of x will be incremented from i to a1 and
value of y will be calculated using the following
formula

j
Drawback of Polynomial Method

 It requires squaring of values. So floating point calculation is required.


 Routines developed for such calculations are very complex and slow.
2- Trigonometric Method

 The following equation defines an ellipse trigonometrically as shown in fig:


 x = a * cos (θ) +h and
 y = b * sin (θ)+k
 Where:
 (x, y) = the current coordinates
 a = length of major axis
 b = length of minor axis
 Θ = current angle
 (h, k) = ellipse center
 In this method, the value of θ is varied from 0 to
Trignometric Method radians.
The remaining points are found by symmetry.
Drawback of trigonometric method

 This is an inefficient method.


 It is not an interactive method for generating ellipse.
 The table is required to see the trigonometric value.
 Memory is required to store the value of θ.
Midpoint Ellipse Algorithm
 In computer graphics, the mid-point ellipse algorithm is an incremental
method of drawing an ellipse.
 The mid-point ellipse drawing algorithm is used to calculate all the
perimeter points of an ellipse.
 In this algorithm, the mid-point between the two pixels is calculated which
helps in calculating the decision parameter.
 The value of the decision parameter determines whether the mid-point lies
inside, outside, or on the ellipse boundary and the then position of the mid-
point helps in drawing the ellipse.
 It is very similar to the midpoint circle algorithm. Because of the four-way
symmetry property we need to consider the entire elliptical curve in the first
quadrant.
 Midpoint ellipse algorithm plots(finds) points of an ellipse on the first
quadrant by dividing the quadrant into two regions.
 Each point(x, y) is then projected into other three quadrants (-x, y), (x, -y),
(-x, -y) i.e. it uses 4-way symmetry.
Slope of ellipse
 In the ellipse each quadrant is divided into two regions: R1 and R2 respectively.
 We know that the slope of an ellipse is given by:
 m = dx / dy = - (2 ry2 x /2 rx2 y ) = -1
 The region R1 has the value of slope as m <-1 while R2 has the value of slope as m
> -1.
 The starting point for R1 will be (0, ry) and for R2, the initial points will become
the ending points of R1, where the slope becomes greater than -1.
 That's why we need to keep in check the value of slope while plotting the points
for R1 to know whether we have reached R2 or not.
Function of ellipse and decision parameter
 Function of ellipse:
fellipse(x, y) = ry2x2 + rx2y2 - rx2ry2
fellipse(x, y)<0 then (x, y) is inside the ellipse.
fellipse(x, y)>0 then (x, y) is outside the ellipse.
fellipse(x, y)=0 then (x, y) is on the ellipse.

 Decision parameter:
 Initially, we have two decision parameters p1 0 in region 1 and p20 in region 2.
 These parameters are defined as : p1 0 in region 1 is given as :
 P10 = ry2 + 1 / 4rx2 - rx2ry
Mid-Point Ellipse Algorithm
 Step 1: Start
 Step 2: Declare rx , ry , x , y , m , dx , dy , P , P2.
 Step 3: Initialize initial point of region1 as
 x = 0 , y = ry
 Step 4: Calculate P= ry2 + rx2 / 4 - ry rx2
 dx = 2 ry2 x
 dy = 2 rx2 y
 Step 5: Update values of dx and dy after each iteration.
 Step 6: Repeat steps while (dx < dy):
 Plot (x,y)
 if(P < 0)
 Update x = x+1 ;
 P += ­ry2 [2x + 3 ]
 Else
 Update x = x + 1
 y= y - 1
 Step 7: When dx ≥ dy, plot region 2:
 Step 8: Calculate P2 = ry2 ( x+1 / 2)2 + rx2 (y -1)2- rx2ry2
 Step 9: Repeat till (y > 0)
 If (P2 > 0)
 Update y = y-1 (x will remain same)
 P2 =­P2 -2 y rx2 + rx2
 else
 x = x+1
 y = y-1
 P2=­P2+ 2 ry2 [2x] -2 y rx2 + rx2
 Step 10: End
Advantages & Disadvantages
 Advantages:
 The mid-point ellipse algorithm has simple and easy implementation as it
only includes addition operations.

 Disadvantages:
 This algorithm is time consuming.
EXAMPLE 3 Midpoint Ellipse Drawing
 Given input ellipse parameters rx = 8 and ry = 6, we illustrate the steps in the
midpoint ellipse algorithm by determining raster positions along the ellipse
path in the first quadrant.
 Initial values and increments for the decision parameter calculations are
 2ry2 x = 0 (with increment 2ry2 = 72)
 2rx2 y = 2rx2 ry (with increment −2rx2 = −128)
 For region 1, the initial point for the ellipse centered on the origin is (x0, y0)
= (0, 6), and the initial decision parameter value is
 p10 = ry2 − rx2 ry + 1/4 rx2 = −332
 Successive midpoint decision-parameter values and the pixel positions along
the ellipse are listed in the following table:

You might also like