Upload
mary-ramsey
View
213
Download
0
Embed Size (px)
Citation preview
CS 450: COMPUTER GRAPHICS
REVIEW: DRAWING ELLIPSES AND OTHER CURVES
SPRING 2015
DR. MICHAEL J. REALE
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
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
cdd 21
http://commons.wikimedia.org/wiki/File:Drawing_an_ellipse_via_two_tacks_a_loop_and_a_pen.jpg#mediaviewer/File:Drawing_an_ellipse_via_two_tacks_a_loop_and_a_pen.jpg
022 FEyDxCxyByAx
1
22
y
c
x
c
r
yy
r
xx
MIDPOINT ELLIPSE ALGORITHM
• Align ellipse with x/y axes
• Start at (0,ry )
• 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
IMPLICIT ELLIPSE FORMULA
0),( 222222 yxxy rryrxryxF
boundary ellipse theOUTSIDE is y)(x, if 0,
boundary ellipse theON is y)(x, if 0,
boundary ellipse theINSIDE is y)(x, if 0,
),( yxF
…which has the following properties:
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
MIDPOINT ELLIPSE ALGORITHM: REGION 1
• 1. Input rx, ry, and ellipse center (xc, yc); get first point for ellipse centered on origin:
• 2. Get initial decision variable for region 1:
• 3. While (2ry2x < 2rx
2y)
• If p1k < 0 choose (xk + 1, yk)
• Otherwise choose (xk + 1, yk – 1)
),0(),( 00 yryx
2220 4
11 xyxy rrrrp
21
21 211 ykykk rxrpp
122
12
1 2211 kxykykk yrrxrpp
MIDPOINT ELLIPSE ALGORITHM: REGION 2
• 4. Get initial value of decision variable for region 2 from last position (x0, y0) calculated in region 1:
• 5. While (y != 0)
• If p2k > 0 choose (xk, yk – 1)
• Otherwise choose (xk + 1, yk – 1)
• 6. For both regions, define symmetry points: (x,y), (-x,y), (x,-y), and (-x,-y)
• 7. For each position (x,y), plot:
2220
22
02
0 12
12 yxxy rryrxrp
21
21 222 xkxkk ryrpp
21
21
21 2222 ykxkxkk rxryrpp
c
c
yyy
xxx
CONIC SECTIONS
• Equation:
• Intersection of plane with double cone
• Does not include “degenerate” conics point, line
022 FEyDxCxyByAx
http://mathworld.wolfram.com/ConicSection.html
hyperbola ,0
parabola ,0
circle)(or ellipse ,0
42 ACB
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
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
33
2210
33
2210
uauauaay
uauauaax
yyyy
xxxx