0% found this document useful (0 votes)
258 views15 pages

Ellipse Algorithms in Computer Graphics

This document discusses algorithms for generating ellipses in computer graphics. It describes the properties of ellipses and gives their general equation. It then explains the midpoint ellipse algorithm, which uses incremental steps to determine the pixel positions along an ellipse. The algorithm is applied separately over two regions in each quadrant by calculating a decision parameter at each step to determine whether the midpoint is inside or outside the ellipse boundary. Examples are given to illustrate the steps and calculations involved.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
258 views15 pages

Ellipse Algorithms in Computer Graphics

This document discusses algorithms for generating ellipses in computer graphics. It describes the properties of ellipses and gives their general equation. It then explains the midpoint ellipse algorithm, which uses incremental steps to determine the pixel positions along an ellipse. The algorithm is applied separately over two regions in each quadrant by calculating a decision parameter at each step to determine whether the midpoint is inside or outside the ellipse boundary. Examples are given to illustrate the steps and calculations involved.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Higher Technological Institute

Computer Science Department

Computer Graphics

Dr Osama Farouk
Dr Ayman Soliman
Dr Adel Khaled
Lecture Four
Graphics Output Primitives
ELLIPSE-GENERATING ALGORITHMS
Properties of Ellipses
A precise definition of an ellipse can be given in terms of the distances from
any point on the ellipse to two fixed positions, called the foci of the ellipse.

(1)
Expressing distances d1 and d2

The general ellipse equation in the form


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.
The equation for the ellipse

(1)

Using polar coordinates r and 𝜃

(2)

If rx > ry, the radius of the bounding circle is r = rx .


Otherwise, the bounding circle has radius r = ry.

As with the circle algorithm, symmetry considerations can be


used to reduce computations. An ellipse in standard position is
symmetric between quadrants, but, unlike a circle, it is not
symmetric between the two octants of a quadrant. Thus, we
must calculate pixel positions along the elliptical arc throughout
one quadrant, then use symmetry to obtain curve positions in
the remaining three quadrants
Midpoint Ellipse Algorithm
Given parameters rx , ry, and (xc , yc ), we determine curve positions (x, y) for an ellipse
in standard position centered on the origin, then we shift all the points using a fixed
offset so that the ellipse is centered at (xc , yc ). If we wish also to display the ellipse in
nonstandard position, we could rotate the ellipse about its center coordinates to
reorient the major and minor axes in the desired directions.
The midpoint ellipse method is applied throughout the first quadrant in two parts.
Regions 1 and 2 (Figure) can be processed in various ways.
We can 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.0.
Alternatively, we could start at (rx , 0) and select points in a
counterclockwise order, shifting from unit steps in y to unit
steps in x when the slope becomes greater than -1.0. With
parallel processors, we could calculate pixel positions in the
two regions simultaneously. As an example of a sequential
implementation of the midpoint algorithm, we take the start
position at (0, ry) and step along the ellipse path in clockwise
order throughout the first quadrant.
We define an ellipse function from Equation ( 2 ) with (xc , yc) = (0, 0) as

(3)
which has the following properties:

(4)

Starting at (0, ry), we take unit steps 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. At each step we
need to test the value of the slope of the curve. The ellipse slope is calculated
from Equation ( 3 ) as
(5)

At the boundary between region -1 and region 2


and
(6)
Therefore, we move out of region 1 whenever
The decision parameter (that is, the ellipse function 3) at this midpoint:

(7)

If p1k < 0, the midpoint is inside the ellipse and the pixel on scan line yk is closer to the
ellipse boundary. Otherwise, the midposition is outside or on the ellipse boundary, and
we select the pixel on scan line yk − 1.
At the next sampling position (xk+1 + 1 = xk + 2), the decision parameter for region 1 is
evaluated as

(8)

where yk+1 is either yk or yk − 1, depending on the sign of p1k.


Decision parameters are incremented by the following amounts:

(9)

At the initial position (0, ry), these two terms evaluate to

( 10)

In region 1, the initial value of the decision parameter is obtained by evaluating the
ellipse function at the start position (x , y ) = (0, r ):
0 0 y

( 11)
Over region 2, we sample at unit intervals in the negative y direction, and the midpoint is now taken
between horizontal pixels at each step (Figure ). For this region, the decision parameter is evaluated as
Example: Midpoint Ellipse Drawing (Textbook P114-115)
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
P2k
QUIZ
Given input ellipse parameters rx = 12 and ry = 9, 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

Common questions

Powered by AI

The shape of the ellipse, determined by the radii rx and ry, dictates how the midpoint algorithm processes regions 1 and 2. In region 1, which is the area where the ellipse is wider, the algorithm starts by taking unit steps in the x-direction. As the slope of the boundary becomes less than -1, it transitions to taking steps in the y-direction when entering region 2. This transition ensures that the raster positions follow the precise curvature of the ellipse, minimizing error between the computed points and the actual boundary of the ellipse .

Choosing different starting points affects computational efficiency and the path taken to traverse the ellipse. Starting at (0, ry) and stepping clockwise takes advantage of symmetry in simple calculations along the widely spaced portion of the ellipse. Alternatively, starting at (rx, 0) and proceeding counterclockwise might present challenges when transitioning slopes, requiring careful recalibration of decision parameters. The starting point choice impacts the ease of algorithm implementation and potential computational optimizations .

Ellipse algorithms use symmetry considerations similar to circle algorithms but in a more limited capacity. Circle algorithms can use symmetry in all directions due to the uniform radius, allowing calculations in one-eighth of a circle's circumference to apply to the entire figure. In contrast, an ellipse is not symmetrical in all octants due to differing radii, so symmetry can only apply within quadrants. This difference influences the complexity and computation demands of the algorithms, as ellipses require more careful handling of symmetry between quadrants .

Parallel processing can enhance the performance of the midpoint ellipse algorithm by simultaneously calculating pixel positions in both identified regions of the first quadrant. Instead of processing sequentially, which takes more time as each decision parameter is updated one by one, parallel processing allows for computations of region 1 and region 2 to occur independently but simultaneously, thereby speeding up the overall ellipse drawing process significantly, as complex calculations are distributed across processors .

Evaluating the ellipse function at the start position is crucial for initializing the decision parameter that guides the drawing path. It determines whether subsequent points will increment x or y based on their proximity to the true ellipse boundary. This is accomplished by inputting initial coordinates, typically (0, ry), into the ellipse equation to determine its initial deviation from the boundary and guide the direction of steps to closely trace the ellipse .

The midpoint ellipse algorithm is based on calculating pixel positions along the elliptical arc in one quadrant by starting at a known position and using decision parameters to iteratively determine the next point. It leverages the symmetry properties of the ellipse by calculating positions only in the first quadrant and then applying these positions to the remaining quadrants. This is because an ellipse in a standard position is symmetric between quadrants, allowing the computed quadrant to be mirrored over the axes to complete the ellipse. This symmetry reduces computational effort as calculations are not repeated for each quadrant .

Transitioning from unit steps in the x-direction to the y-direction is critical for maintaining the accuracy of the ellipse drawn, particularly around steep curvature regions. If managed improperly, errors in transitioning can lead to noticeable deviations from the ideal ellipse path, particularly at the junction between regions 1 and 2. Proper calibration of the decision parameters and careful monitoring of slope values ensure minimal deviation from the ellipse boundary, preserving the desired elliptical shape .

The transition from region 1 to region 2 in the midpoint ellipse algorithm occurs when the slope of the ellipse path becomes less than -1. In region 1, unit steps are taken in the x-direction, but as these steps approach the boundary where the slope changes, the algorithm shifts to taking steps in the y-direction, which corresponds to region 2. This change ensures the remaining part of the ellipse in the first quadrant is accurately traced by adapting to the steeper slope of the edge .

The major axis of an ellipse is the longest straight-line segment extending through the ellipse's center and both foci, while the minor axis is the shortest segment perpendicular to the major axis through the center. These axes are significant in ellipse generation algorithms as they determine the ellipse's proportions and orientation. The algorithm uses these axes to establish start points and orientations, ensuring that the ellipse is accurately plotted in its correct position and dimensions .

Decision parameters in ellipse generation determine the midpoint's position relative to the ellipse boundary, which influences which pixel is chosen to accurately plot the ellipse path. Initial values for these parameters are set by evaluating the ellipse function at the starting position, typically (0, ry) for the midpoint algorithm. This initial evaluation determines if the next pixel should continue in the current direction or transition, ensuring that the plotted path closely represents the intended ellipse shape .

You might also like