Lecture 05: Mid-point Ellipse algorithm Dr. Manal Helal – Fall 2014

Slides:



Advertisements
Similar presentations
Circle Drawing Asst. Prof. Dr. Ahmet Sayar Kocaeli University
Advertisements

CS 450: COMPUTER GRAPHICS DRAWING ELLIPSES AND OTHER CURVES SPRING 2015 DR. MICHAEL J. REALE.
CS 376 Introduction to Computer Graphics 02 / 02 / 2007 Instructor: Michael Eckmann.
Computer Graphics 4: Bresenham Line Drawing Algorithm, Circle Drawing & Polygon Filling By:Kanwarjeet Singh.
CS 450: COMPUTER GRAPHICS REVIEW: DRAWING LINES AND CIRCLES SPRING 2015 DR. MICHAEL J. REALE.
+ CPCS 391 Computer Graphics 1 Instructor: Dr. Sahar Shabanah Lecture 3.
Larry F. Hodges (modified by Amos Johnson) 1 Design of Line, Circle & Ellipse Algorithms.
Raster conversion algorithms for line and circle
Graphics Output Primitives Pixel Addressing and Fill Area Dr. M. Al-Mulhem Feb. 1, 2008.
Rasterization Foley, Ch: 3. Pixels are represented as disjoint circles centered on uniform grid Each (x,y) of the grid has a pixel Y X (1,1) (1,2) (0,0)
Circle Drawing algo..
CGMB214: Introduction to Computer Graphics
Rasterizing primitives: know where to draw the line Dr Nicolas Holzschuch University of Cape Town Modified.
1 CS 430/536 Computer Graphics I Circle Drawing and Clipping Week 3, Lecture 6 David Breen, William Regli and Maxim Peysakhov Geometric and Intelligent.
Dr. S.M. Malaek Assistant: M. Younesi
WHERE TO DRAW A LINE?? Line drawing is accomplished by calculating intermediate positions along the line path between specified end points. Precise definition.
Scan Conversion Line and Circle
CS 450: COMPUTER GRAPHICS REVIEW: DRAWING ELLIPSES AND OTHER CURVES SPRING 2015 DR. MICHAEL J. REALE.
1 Circle Drawing Algorithms Pictures snagged from
Graphics Output Primitives
ELLIPSE GENERATING ALGORITHMS 1. DEFINITION Ellipse is an elongated circle. Elliptical curves can be generated by modifying circle-drawing procedures.
MIDPOINT CIRCLE & ELLIPSE GENERARTING ALGORITHMS
November 18, We could solve for y in terms of x ( x 0, y 0 ) are the origin points A Simple Circle Drawing Algorithm The equation for a circle.
Midpoint Circle Algorithm
CS 325 Introduction to Computer Graphics 02 / 03 / 2010 Instructor: Michael Eckmann.
Double Integrals in Polar Coordinates. Sometimes equations and regions are expressed more simply in polar rather than rectangular coordinates. Recall:
Bresenham’s Line Algorithm
Instructor: Dr. Shereen Aly Taie If (P>0)
Computer Graphics : Bresenham Line Drawing Algorithm, Circle Drawing
Computer Graphics CC416 Lecture 04: Bresenham Line Algorithm & Mid-point circle algorithm Dr. Manal Helal – Fall 2014.
Write Bresenham’s algorithm for generation of line also indicate which raster locations would be chosen by Bresenham’s algorithm when scan converting.
Computer Graphics Inf4/MSc Computer Graphics Lecture 4 Line & Circle Drawing.
10/10/2006TCSS458A Isabelle Bichindaritz1 Line and Circle Drawing Algorithms.
Computer Graphics Lecture 07 Ellipse and Other Curves Taqdees A. Siddiqi
WARM UP 1.Find the equation of the circle with center at (9, 2) and radius 2. 2.Find the center and radius of the circle 3.Find the center and radius of.
Computer Graphics Lecture 06 Circle Drawing Techniques Taqdees A. Siddiqi
Objectives Understand Bresenhams line drawing algorithm. Apply the algorithm to plot a line with the end points specified.
Primitive graphic objects
Scan Conversion or Rasterization
Graphics PRIMITIVES Chapter- 3 & Unit-2.
MID-POINT CIRCLE ALGORITHM
Lecture 5 Basic geometric objects
Parametric equations Parametric equation: x and y expressed in terms of a parameter t, for example, A curve can be described by parametric equations x=x(t),
Concept.
In other words, at time t, the particle is located at the point Sketch the curve with parametric equations.
Lecture 31 – Conic Sections
Lecture 9 Line Drawing Algorithms (Bresenham’s Line Algorithm)
Scan Conversion or Rasterization
IT- 601: Computer Graphics Lecture-03 Scan Conversion
Lecture 8 Shear and Line Drawing Algorithms
Chapter Three Part I Output Primitives CS 380.
Anti Aliasing.
Section 13.2 The Ellipse.
Topics in Analytic Geometry
Scan Conversion of Circles
Chapter 3 Conics 3.4 The Ellipse MATHPOWERTM 12, WESTERN EDITION
THE HYPERBOLA.
Allah says Say, "Allah created cattle for you. In them you find warmth and benefit and from them you eat. In them there is beauty for you when you bring.
Scan Conversion Line(DDA Line and Bresenham Line)
Line Drawing Algorithms
9.3 Graph and Write Equations of Circles
Chapter 3 Conics 3.4 The Ellipse MATHPOWERTM 12, WESTERN EDITION
Scan Conversion (From geometry to pixels)
Chapter 3 Graphics Output Primitives
Primitive Drawing Algorithm
THE ELLIPSE Week 17.
Primitive Drawing Algorithm
Line Drawing Algorithms
OUTPUT PRIMITIVES / DISPLAY TECHNIQUES
Presentation transcript:

Lecture 05: Mid-point Ellipse algorithm Dr. Manal Helal – Fall 2014 Computer Graphics CC416 Lecture 05: Mid-point Ellipse algorithm Dr. Manal Helal – Fall 2014

Ellipse Generation Algorithm An ellipse is an elongated circle Therefore, elliptical curves can be generated by modifying circle-drawing procedures to take into account the different dimensions of an ellipse along the major and minor axes CC416 Computer Graphics

Start with the basic equation of a circle Divide both sides by r2 The general equation of an ellipse can be stated as rx ry xc yc (x,y) CC416 Computer Graphics

Properties of Ellipses An ellipse is defined as the set of points such that the sum of the distances from two fixed positions (foci) is the same for all points d1 d2 CC416 Computer Graphics

So Expressing distances d1, and d2, in terms of the focal coordinates F1 = (x1, y1) and F2 = (x2, y2), we have d1 d2 CC416 Computer Graphics

Symmetry considerations can be used to further 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 we obtain positions in the remaining three quadrants by symmetry CC416 Computer Graphics

Mid-Point Ellipse Algorithm The approach is similar to that used in displaying a circle Given parameters rx, ry, and (xc, yc), we determine points (x, y) for an ellipse in standard position centered on the origin Then the points are shifted so the ellipse is centered at (xc, yc) CC416 Computer Graphics

This is done according to the slope of the tangent The mid-point ellipse method is applied throughout the first quadrant in two parts This is done according to the slope of the tangent When slope < -1, take unit steps in the x direction When slope > -1, take unit steps in the y direction CC416 Computer Graphics

the decision parameter will be according to From equation When (xc, yc) = (0,0) the decision parameter will be according to CC416 Computer Graphics

So, the next pixel along the ellipse path according to the sign of the ellipse function evaluated at the midpoint between the two candidate pixels CC416 Computer Graphics

Starting at (0,ry) take unit steps in the x direction until reaching the boundary between region 1 and region 2 switch to unit steps in the y direction over the remainder of the curve in the first quadrant At each step, test the value of the slope using CC416 Computer Graphics

At the boundary between region 1 and region 2, dy/dx = - 1 and Therefore, we move out of region 1 whenever CC416 Computer Graphics

Assuming position (xk, yk) has been selected at the previous step Recall Assuming position (xk, yk) has been selected at the previous step the next position along the ellipse path is determined by evaluating the decision parameter CC416 Computer Graphics

If p1k < 0, the midpoint is inside the ellipse and the pixel on scan line y, is closer to the ellipse boundary. Otherwise, the mid position is outside or on the ellipse boundary, and we select the pixel on scan line yk - 1. CC416 Computer Graphics

where yk+1 is either yk or yk - 1, depending on the sign of p1k At the next sampling position (xk+1+1 = xk + 2), the decision parameter for region 1 is evaluated as [(xk+1) + 1]2 = (xk+1)2 + 2(xk+1) + 1 [(Yk+1-(1/2))]2 = Yk+12 - Yk+1 + (1/4) P1k+1 = ry2(xk+1)2 + 2ry2 (xk+1) + ry2 +(rx2 Yk+12 - rx2Yk+1 + rx2 (1/4)) - rx2ry2 where yk+1 is either yk or yk - 1, depending on the sign of p1k P1k CC416 Computer Graphics

So decision parameters are incremented by the following amounts: CC416 Computer Graphics

In region 1, the initial value of the decision parameter is obtained by evaluating the ellipse function at the start position (x, y) = (0, ry) or CC416 Computer Graphics

In region 2, we sample at unit steps in the negative y direction The midpoint is now taken between horizontal pixels at each step The decision parameter is evaluated as CC416 Computer Graphics

If p2k > 0, the mid-position is outside the ellipse boundary, and we select the pixel at xk If p2k ≤ 0, the midpoint is inside or on the ellipse boundary, and we select pixel position xk+1 CC416 Computer Graphics

When we enter region 2, the initial position (x0, y0) is taken as the last position selected in region 1 and the initial decision parameter in region 2 is then CC416 Computer Graphics

To simplify the calculation of p20, we could select pixel positions in counterclockwise order starting at (rx, 0). Unit steps would then be taken in the positive y direction up to the last position selected in region 1 CC416 Computer Graphics

Where transformation methods can be used to reorient the ellipse The midpoint algorithm can be adapted to generate an ellipse in nonstandard position Where transformation methods can be used to reorient the ellipse Non Standard position Standard position CC416 Computer Graphics

Midpoint Ellipse Algorithm Input rx, ry and ellipse center (xc, yc), 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 CC416 Computer Graphics

At each x position in region 1, starting at k = 0, perform the following test: If p1k < 0, the next point along the ellipse centered on (0, 0) is (xk+1, yk) and Otherwise, the next point along the circle is (xk + 1, yk – 1) CC416 Computer Graphics

With and continue until CC416 Computer Graphics

Calculate the initial value of the decision parameter in region 2 using the last point (x0, y0) calculated in region 1 as CC416 Computer Graphics

using the same incremental calculations for x and y as in region 1. At each yk position in region 2, starting at k = 0, perform the following test: If p2k> 0, the next point along the ellipse centered on (0, 0) is (xk, yk - 1) and Otherwise, the next point along the circle is (xk + 1, yk - 1) and using the same incremental calculations for x and y as in region 1. CC416 Computer Graphics

Determine symmetry points in the other three quadrants. Move each calculated pixel position (x, y) onto the elliptical path centered on (xc, yc) and plot the coordinate values: x = x + xc y = y + yc CC416 Computer Graphics

Example Given rx = 8 and ry = 6, rx2 = 64 and ry2 = 36 Initial values and increments for the decision parameter calculations are 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 Applying the following when p1k < 0 Otherwise: Loop until CC416 Computer Graphics

We now move out of region 1, since Successive decision parameter values and positions along the ellipse path are calculated using the midpoint method as We now move out of region 1, since CC416 Computer Graphics

For region 2 rx = 8 and ry = 6, rx2 = 64 and ry2 = 36 the initial point is (x0, y0) = (7,3) and the initial decision parameter is The remaining positions along the ellipse path in the first quadrant are then calculated as: If If p2k> 0: Else: k p2k Xk+1 Yk+1 2r2yXk+1 2r2xYk+1 -23 8 2 72*8 = 576 128*2 = 256 1 (-23+256+64)= 297 576 128 (297+576-128+64) = 809 - CC416 Computer Graphics

CC416 Computer Graphics

More about ellipses Source: http://en.wikipedia.org/wiki/Ellipse CC416 Computer Graphics