ADVANCED COMPUTER GRAPHIC S Curves and Surfaces CMSC

  • Slides: 23
Download presentation
ADVANCED COMPUTER GRAPHIC S Curves and Surfaces CMSC 635 curves 1/23 January 15, 2013

ADVANCED COMPUTER GRAPHIC S Curves and Surfaces CMSC 635 curves 1/23 January 15, 2013 Spline

ADVANCED COMPUTER GRAPHIC S To do • Continue to work on ray programming assignment

ADVANCED COMPUTER GRAPHIC S To do • Continue to work on ray programming assignment • Start thinking about final project CMSC 635 curves 2/23 January 15, 2013 Spline

ADVANCED COMPUTER GRAPHIC S Curved Surfaces • Motivation – Exact boundary representation for some

ADVANCED COMPUTER GRAPHIC S Curved Surfaces • Motivation – Exact boundary representation for some objects – More concise representation that polygonal mesh – Easier to model with and specify for many man-made objects and machine parts (started with car bodies) CMSC 635 curves 3/23 January 15, 2013 Spline

ADVANCED COMPUTER GRAPHIC S Curve and surface Representations • Curve representation – Function: y

ADVANCED COMPUTER GRAPHIC S Curve and surface Representations • Curve representation – Function: y = f(x) – Implicit: f(x, y) = 0 – Subdivision: (x, y) as limit of recursive process – Parametric: x = f(t), y = g(t) • Curved surface representation – Function: z = f(x, y) – Implicit: f(x, y, z)=0 – Subdivision: (x, y, z) as limit of recursive process – Parametric: x = f(s, t), y=g(s, t), z = h(s, t) CMSC 635 curves 4/23 January 15, 2013 Spline

ADVANCED COMPUTER GRAPHIC S Parametric Surfaces • Boundary defined by parametic function – x

ADVANCED COMPUTER GRAPHIC S Parametric Surfaces • Boundary defined by parametic function – x = f(u, v) – y = f(u, v) – Z = f(u, v) • Example (sphere): – X = sin ( ) cos ( ) – Y = sin ( ) – Z = cos( ) CMSC 635 curves 5/23 January 15, 2013 Spline

ADVANCED COMPUTER GRAPHIC S Parametric Representation • One function vs. many (defined piecewise) •

ADVANCED COMPUTER GRAPHIC S Parametric Representation • One function vs. many (defined piecewise) • Continuity • A parametric polynomial curve of order n: • Advantages of polynomial curves – Easy to compute – Infinitely differentiable everywhere CMSC 635 curves 6/23 January 15, 2013 Spline

ADVANCED COMPUTER GRAPHIC S Spline Constructions • Cubic spline is the most common form

ADVANCED COMPUTER GRAPHIC S Spline Constructions • Cubic spline is the most common form • Common constructions – Bezier: 4 control points – B-splines: approximating C 2, local control – Hermite: 2 points, 2 normals – Natural splines: interpolating, C 2, no local control – Catmull-Rom: interpolating, C 1, local control CMSC 635 curves 7/23 January 15, 2013 Spline

ADVANCED COMPUTER GRAPHIC S Bezier Curve • Motivation: Draw a smooth intuitive curve (or

ADVANCED COMPUTER GRAPHIC S Bezier Curve • Motivation: Draw a smooth intuitive curve (or surface) given a few key user-specified control points Contr ol po lygon Control point Smooth Bezier curve (drawn automatically) • Properties: – Interpolates is tangent to end points – Curve within convex hull of control polygon CMSC 635 curves 8/23 January 15, 2013 Spline

ADVANCED COMPUTER GRAPHIC S Linear Bezier Curve • Just a simple linear combination or

ADVANCED COMPUTER GRAPHIC S Linear Bezier Curve • Just a simple linear combination or interpolation (easy to code up, very numerically stable) P 1 F(1) P 0 F(0) Linear (Degree 1, Order 2) F(0) = P 0, F(1) = P 1 F(u) = ? P 0 1 -u P 1 u F(u) = (1 -u) P 0 + u P 1 CMSC 635 curves 9/23 January 15, 2013 Spline

ADVANCED COMPUTER GRAPHIC S de. Castljau: Quadratic Bezier Curve Quadratic Degree 2, Order 3

ADVANCED COMPUTER GRAPHIC S de. Castljau: Quadratic Bezier Curve Quadratic Degree 2, Order 3 F(0) = P 0, F(1) = P 2 F(u) = ? P 1 P 2 P 0 P 1 P 2 u 1 -u 1 -u u F(u) = (1 -u)2 P 0 + 2 u(1 -u) P 1 + u 2 P 2 CMSC 635 curves 10/23 January 15, 2013 Spline

ADVANCED COMPUTER GRAPHIC S Geometric Interpretation: Quadratic u 1 -u u CMSC 635 curves

ADVANCED COMPUTER GRAPHIC S Geometric Interpretation: Quadratic u 1 -u u CMSC 635 curves 11/23 January 15, 2013 Spline

ADVANCED COMPUTER GRAPHIC S Geometric Interpolation: Cubic u u u CMSC 635 curves 12/23

ADVANCED COMPUTER GRAPHIC S Geometric Interpolation: Cubic u u u CMSC 635 curves 12/23 January 15, 2013 Spline

ADVANCED COMPUTER GRAPHIC S Summary: de. Casteljau Algorithm • A recursive implementation of curves

ADVANCED COMPUTER GRAPHIC S Summary: de. Casteljau Algorithm • A recursive implementation of curves at different orders P 1 P 0 Linear Degree 1, Order 2 F(0) = P 0, F(1) = P 1 P 0 1 -u P 1 u F(u) = (1 -u) P 0 + u P 1 CMSC 635 curves 13/23 P 2 Quadratic Degree 2, Order 3 F(0) = P 0, F(1) = P 2 P 0 P 1 1 -u u 1 -u P 2 u u F(u) = (1 -u)2 P 0 + 2 u(1 -u) P 1 + u 2 P 2 January 15, 2013 Spline

ADVANCED COMPUTER GRAPHIC S Summary: de. Casteljau Algorithm • A recursive implementation of curves

ADVANCED COMPUTER GRAPHIC S Summary: de. Casteljau Algorithm • A recursive implementation of curves at different orders • Further consideration: polar coordinates P 1 P 2 P 3 P 0 Cubic Degree 3, Order 4 F(0) = P 0, F(1) = P 3 P 0 P 1 P 2 P 3 1 -u u 1 -u u u F(u) = (1 -u)3 P 0 +3 u(1 -u)2 P 1 +3 u 2(1 -u) P 2 + u 3 P 3 CMSC 635 curves 14/23 January 15, 2013 Spline

ADVANCED COMPUTER GRAPHIC S Bezier: disadvantages • Single piece, no local control (move a

ADVANCED COMPUTER GRAPHIC S Bezier: disadvantages • Single piece, no local control (move a control point, whole curve changes) • Complex shapes: can be very high degree, difficult to deal with • In practice: combine many Bezier curve segments – But only position continuous at the joint points since Bezier curves interpolate end-points (which match at segment boundaries) – Unpleasant derivative (slope) discontinuities at end-points CMSC 635 curves 15/23 January 15, 2013 Spline

ADVANCED COMPUTER GRAPHIC S Piecewise polynomial curves • Ideas: – Use different polynomial functions

ADVANCED COMPUTER GRAPHIC S Piecewise polynomial curves • Ideas: – Use different polynomial functions for different parts of the curve • Advantage: – Flexibility – Local control • Issue – Smoothness at joints (G: geometry continuity: C: derivative continuity) CMSC 635 curves 16/23 January 15, 2013 Spline

ADVANCED COMPUTER GRAPHIC S Continuity • Continuity Ck indicates adjacent curves have the same

ADVANCED COMPUTER GRAPHIC S Continuity • Continuity Ck indicates adjacent curves have the same kth derivative at their joints • C 0 continuity: Adjacent curves share – Same endpoints: Qi(1) = Qi+1(0) • C-1: discontinuous curves CMSC 635 curves 17/23 January 15, 2013 Spline

ADVANCED COMPUTER GRAPHIC S Continuity • C 1 continuity: Adjacent curves share – Same

ADVANCED COMPUTER GRAPHIC S Continuity • C 1 continuity: Adjacent curves share – Same endpoints: Qi(1) = Qi+1(0) and – Same derivative: Qi’(1) = Qi+1’(0) • C 2 continuity: – Must have C 1 continuity, and – Same second derivatives: Qi ’’(1) = Qi+1 ’’(0) • Most engineering applications (e. g. , those in car and airplane industry) require at least C 1 continuity CMSC 635 curves 18/23 January 15, 2013 Spline

ADVANCED COMPUTER GRAPHIC S Splines • • • More useful form of representation compared

ADVANCED COMPUTER GRAPHIC S Splines • • • More useful form of representation compared to the Bezier curve How they work: Parametric curves governed by control points Mathematically: Several representations to choose from. More complicated than vertex lists. See chapter 22 of the book for more information. Simple parametric representation: Advantage: Smooth with just a few control point Disadvantage: Can be hard to control Uses: – representation of smooth shapes. Either as outlines in 2 D or with Patches or Subdivision Surfaces in 3 D – animation Paths – approximation of truncated Gaussian Filters CMSC 635 curves 19/23 January 15, 2013 Spline

ADVANCED COMPUTER GRAPHIC S A Simple Animation Example • Problem: create a car animation

ADVANCED COMPUTER GRAPHIC S A Simple Animation Example • Problem: create a car animation that is driving up along the y-axis with velocity [0, 3], and arrive at the point (0, 4) at time t=0. Animate its motion as it turns and slows down so that at time t=1, it is at position (2, 5) with velocity [2, 0]. • Solution – First step: generate a mathematical description. – Second step: choose the curve representation • Hermite curve: r(t)=GMT(t) • Exercise: Bezier curve representation? CMSC 635 curves 20/23 January 15, 2013 Spline

ADVANCED COMPUTER GRAPHIC S Catmull Rom Spline • Can be used to solve the

ADVANCED COMPUTER GRAPHIC S Catmull Rom Spline • Can be used to solve the following problem. • Solution: – Math representation – Curve construction • Catmull Rom spline to construct the vectors from the two or three neighbors take home exercise: read chap 22 in the book and construct the curve and the B-spline using the Chen code. CMSC 635 curves 21/23 January 15, 2013 Spline

ADVANCED COMPUTER GRAPHIC S Subdivision curves • A simple idea – Using the midpoint

ADVANCED COMPUTER GRAPHIC S Subdivision curves • A simple idea – Using the midpoint of the edge from one point to the next, replace that point with a new one to create a new polygon to construct a new curve. – problem with this? • Further readings: – Laplacian interpolation and smoothing (Gabriel Taubin @ Brown) – Joe Warren@ Rice (on mesh) CMSC 635 curves 22/23 January 15, 2013 Spline

ADVANCED COMPUTER GRAPHIC S Surfaces • Curves -> Surfaces • Bezier patch: – 16

ADVANCED COMPUTER GRAPHIC S Surfaces • Curves -> Surfaces • Bezier patch: – 16 points – Check out the Chen code for surface construction CMSC 635 curves 23/23 January 15, 2013 Spline