0% found this document useful (0 votes)
60 views

HTI - Computer Graphics Course - Lec

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)
60 views

HTI - Computer Graphics Course - Lec

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
You are on page 1/ 15

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

You might also like