HTI - Computer Graphics Course - Lec
HTI - Computer Graphics Course - Lec
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
(1)
(2)
(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)
(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)
(9)
( 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