Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 450: COMPUTER GRAPHICS REVIEW: DRAWING ELLIPSES AND OTHER CURVES SPRING 2015 DR. MICHAEL J. REALE.

Similar presentations


Presentation on theme: "CS 450: COMPUTER GRAPHICS REVIEW: DRAWING ELLIPSES AND OTHER CURVES SPRING 2015 DR. MICHAEL J. REALE."— Presentation transcript:

1 CS 450: COMPUTER GRAPHICS REVIEW: DRAWING ELLIPSES AND OTHER CURVES SPRING 2015 DR. MICHAEL J. REALE

2 OVERVIEW OF DRAWING CURVES Explicit form  y = f(x) Parametric form  y = f(s), x = g(s) Implicit form  F(x,y) = 0 Two approaches: Use explicit or parametric form  approximate curve with line segments Parametric form  evenly-spaced points along curve path Can connect points OR use best-fitting line Use implicit form  derive incremental midpoint method Take advantage of any curve symmetry

3 ELLIPSES Symmetric only for quadrants Circles  symmetric in all octants Equations: Two foci  for point on ellipse, sum of distances from foci is constant: General ellipse equation: Axis-aligned (standard) ellipse: Two axes: Major axis = line passing through both foci Minor axis = line perpendicular to major axis Semimajor/semiminor axes  radii aligned with major/minor axes, respectively http://commons.wikimedia.org/wiki/File:Drawing_an_e llipse_via_two_tacks_a_loop_and_a_pen.jpg#mediavie wer/File:Drawing_an_ellipse_via_two_tacks_a_loop_an d_a_pen.jpg

4 MIDPOINT ELLIPSE ALGORITHM Align ellipse with x/y axes Start at (0,r y ) Use two separate midpoint algorithms: 1) Increment x  choose y UNTIL slope < -1.0 2) Then, decrement y  choose x Use symmetry to copy points to other 3 quadrants

5 IMPLICIT ELLIPSE FORMULA …which has the following properties:

6 NONSTANDARD ELLIPSES For ellipses not aligned with coordinate axes: 1) Adapt formulas to work over ENTIRE ellipse path 2) Use standard ellipse  use transformation to rotate ellipse points

7 MIDPOINT ELLIPSE ALGORITHM: REGION 1 1. Input r x, r y, and ellipse center (x c, y c ); get first point for ellipse centered on origin: 2. Get initial decision variable for region 1: 3. While (2r y 2 x < 2r x 2 y) If p1 k < 0  choose (x k + 1, y k )  Otherwise  choose (x k + 1, y k – 1) 

8 MIDPOINT ELLIPSE ALGORITHM: REGION 2 4. Get initial value of decision variable for region 2 from last position (x 0, y 0 ) calculated in region 1: 5. While (y != 0) If p2 k > 0  choose (x k, y k – 1)  Otherwise  choose (x k + 1, y k – 1)  6. For both regions, define symmetry points: (x,y), (-x,y), (x,-y), and (-x,-y) 7. For each position (x,y), plot:

9 CONIC SECTIONS Equation: Intersection of plane with double cone Does not include “degenerate” conics  point, line http://mathworld.wolfram.com/ConicSection.html

10 DRAWING CONIC SECTIONS Use symmetry: Circles  across 8 octants Ellipses/Hyperbolas  across 4 quadrants Parabolas  across vertical axis Compute decision variable formulas for areas where slope is less than 1.0 and greater than 1.0 Go through midpoint algorithm, checking when to switch because of slope

11 POLYNOMIALS AND SPLINE CURVES Use parametric form Example: Parameter u  [0,1]  start/end of curve Approximate with line segments (small increments of u) Spline curve (splines) = continuous curve formed with polynomial pieces


Download ppt "CS 450: COMPUTER GRAPHICS REVIEW: DRAWING ELLIPSES AND OTHER CURVES SPRING 2015 DR. MICHAEL J. REALE."

Similar presentations


Ads by Google