40
Advanced Computer Graphics Advanced Computer Graphics (Spring 2005) (Spring 2005) COMS 4162, Lecture 12: Spline Curves (review) Ravi Ramamoorthi http://www.cs.columbia.edu/~cs4162 Most material taken from COMS 4160 lectures 6

Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 12: Spline Curves (review) Ravi Ramamoorthi cs4162 Most material

  • View
    222

  • Download
    1

Embed Size (px)

Citation preview

Page 1: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 12: Spline Curves (review) Ravi Ramamoorthi cs4162 Most material

Advanced Computer Graphics Advanced Computer Graphics (Spring 2005) (Spring 2005)

COMS 4162, Lecture 12: Spline Curves (review) Ravi Ramamoorthi

http://www.cs.columbia.edu/~cs4162

Most material taken from COMS 4160 lectures 6 and 7

Page 2: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 12: Spline Curves (review) Ravi Ramamoorthi cs4162 Most material

To Do / MotivationTo Do / Motivation

One of written questions in assignment deals with material in this (actually next) lecture

Otherwise, mainly intended for completeness, since splines are very common modeling tool

This lecture reviews spline curves (from 4160). Next lecture discusses extensions to NURBs and surfaces

Page 3: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 12: Spline Curves (review) Ravi Ramamoorthi cs4162 Most material

Curved SurfacesCurved Surfaces

Motivation Exact boundary representation for some objects More concise representation than polygonal mesh Easier to model with and specify for many man-made

objects and machine parts (started with car bodies)

H&B Figure 10.46H&B Figure 10.46

Page 4: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 12: Spline Curves (review) Ravi Ramamoorthi cs4162 Most material

Curve RepresentationsCurve Representations

Function: y = f(x)

Implicit: f(x,y) = 0

Subdivision: (x,y) as limit of recursive process

Parametric: x = f(t), y = g(t)

Page 5: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 12: Spline Curves (review) Ravi Ramamoorthi cs4162 Most material

Curved Surface RepresentationsCurved Surface Representations

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)

Page 6: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 12: Spline Curves (review) Ravi Ramamoorthi cs4162 Most material

Parametric SurfacesParametric Surfaces

Boundary defined by parametric function:x = f(u,v)y = f(u,v)z = f(u,v)

Example (sphere):x = sin() cos()y = sin() sin()z = cos()

Page 7: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 12: Spline Curves (review) Ravi Ramamoorthi cs4162 Most material

Parametric RepresentationsParametric Representations

One function vs. many (defined piecewise)

Continuity

How specified?

Page 8: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 12: Spline Curves (review) Ravi Ramamoorthi cs4162 Most material

Parametric Polynomial CurvesParametric Polynomial Curves

A parametric polynomial curve of order n:

Advantages of polynomial curves Easy to compute Infinitely differentiable everywhere

n

i

iiuaux

0

)(

n

i

iiuaux

0

)(

n

i

iiubuy

0

)(

n

i

iiubuy

0

)(

Page 9: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 12: Spline Curves (review) Ravi Ramamoorthi cs4162 Most material

(Cubic) Spline Constructions(Cubic) Spline Constructions

Bézier: 4 control points

B-splines: approximating, C2, local control

Hermite: 2 points, 2 normals

Natural splines: interpolating, C2, no local control

Catmull-Rom: interpolating, C1, local control

Book chapter 11 covers some spline constructionsBut material is hard to read, doesn’t follow formathere. I recommend following lecture.

Page 10: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 12: Spline Curves (review) Ravi Ramamoorthi cs4162 Most material

Bezier Curve (with 4160-HW2 demo)Bezier Curve (with 4160-HW2 demo)

Motivation: Draw a smooth intuitive curve (or surface) given a few key user-specified control points

hw2.exe

Control points (all that user specifies, edits)

Smooth Bezier curve(drawn automatically)

Controlpolygon

Page 11: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 12: Spline Curves (review) Ravi Ramamoorthi cs4162 Most material

Bezier Curve: (Desirable) propertiesBezier Curve: (Desirable) properties

Interpolates, is tangent to end points

Curve within convex hull of control polygon

Control points (all that user specifies, edits)

Smooth Bezier curve(drawn automatically)

Controlpolygon

hw2.exe

Page 12: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 12: Spline Curves (review) Ravi Ramamoorthi cs4162 Most material

deCasteljau: Linear Bezier CurvedeCasteljau: Linear Bezier Curve

Just a simple linear combination or interpolation (easy to code up, very numerically stable)

Linear (Degree 1, Order 2)F(0) = P0, F(1) = P1

F(u) = ?P0

P1

P0 P1

1-u u

F(u) = (1-u) P0 + u P1

F(0)

F(u)

F(1)

Page 13: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 12: Spline Curves (review) Ravi Ramamoorthi cs4162 Most material

deCasteljau: Quadratic Bezier CurvedeCasteljau: Quadratic Bezier Curve

P0

P1

P2

QuadraticDegree 2, Order 3

F(0) = P0, F(1) = P2F(u) = ?

F(u) = (1-u)2 P0 + 2u(1-u) P1 + u2 P2

P0 P1 P2

1-u 1-uu u

1-u u

Page 14: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 12: Spline Curves (review) Ravi Ramamoorthi cs4162 Most material

Geometric interpretation: QuadraticGeometric interpretation: Quadratic

u

u

u

1-u

1-u

Page 15: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 12: Spline Curves (review) Ravi Ramamoorthi cs4162 Most material

Geometric Interpretation: Cubic

u

u

u

u

u

u

Page 16: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 12: Spline Curves (review) Ravi Ramamoorthi cs4162 Most material

Summary: deCasteljau AlgorithmSummary: deCasteljau Algorithm

Linear Degree 1, Order 2

F(0) = P0, F(1) = P1

P0

P1

P0 P1

1-u u

F(u) = (1-u) P0 + u P1

P0

P1

P2Quadratic

Degree 2, Order 3F(0) = P0, F(1) = P2

P0 P1 P2

F(u) = (1-u)2 P0 + 2u(1-u) P1 + u2 P2

1-u 1-uu u

1-u u

P0

P1 P2

P3Cubic

Degree 3, Order 4F(0) = P0, F(1) = P3

P0 P1 P2 P31-u

1-u

1-u

u

u

u u

u

u

1-u

1-u

F(u) = (1-u)3 P0 +3u(1-u)2 P1 +3u2(1-u) P2 + u3 P3

1-u

Page 17: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 12: Spline Curves (review) Ravi Ramamoorthi cs4162 Most material

Idea of Blossoms/Polar FormsIdea of Blossoms/Polar Forms

(Optional) Labeling trick for control points and intermediate deCasteljau points that makes thing intuitive

E.g. quadratic Bezier curve F(u) Define auxiliary function f(u1,u2) [number of args = degree] Points on curve simply have u1=u2 so that F(u) = f(u,u) And we can label control points and deCasteljau points not

on curve with appropriate values of (u1,u2 )

f(0,0) = F(0) f(1,1) = F(1)

f(0,1)=f(1,0)

f(u,u) = F(u)

Page 18: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 12: Spline Curves (review) Ravi Ramamoorthi cs4162 Most material

Idea of Blossoms/Polar FormsIdea of Blossoms/Polar Forms

Points on curve simply have u1=u2 so that F(u) = f(u,u)

f is symmetric f(0,1) = f(1,0)

Only interpolate linearly between points with one arg different f(0,u) = (1-u) f(0,0) + u f(0,1) Here, interpolate f(0,0) and

f(0,1)=f(1,0)

00 01 11

F(u) = f(uu) = (1-u)2 P0 + 2u(1-u) P1 + u2 P2

1-u 1-uu u

1-u u

0u 1u

uuf(0,0) = F(0) f(1,1) = F(1)

f(0,1)=f(1,0)

f(u,u) = F(u)

Page 19: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 12: Spline Curves (review) Ravi Ramamoorthi cs4162 Most material

Geometric interpretation: Quadratic Geometric interpretation: Quadratic

u

u

u

1-u

1-u

00

01=10

11

0u

1u

uu

Page 20: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 12: Spline Curves (review) Ravi Ramamoorthi cs4162 Most material

Polar Forms: Cubic Bezier CurvePolar Forms: Cubic Bezier Curve

000

001 011

111

000 001 011 1111-u u u u1-u 1-u

00u 01u 11u

1-u u u1-u

0uu 1uu

1-u u

uuu

Page 21: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 12: Spline Curves (review) Ravi Ramamoorthi cs4162 Most material

Geometric Interpretation: Cubic

00u

0u1

u11

0uu

uu1

uuu

000 111

001 011

Page 22: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 12: Spline Curves (review) Ravi Ramamoorthi cs4162 Most material

Why Polar Forms?Why Polar Forms?

Simple mnemonic: which points to interpolate and how in deCasteljau algorithm

Easy to see how to subdivide Bezier curve (next) which is useful for drawing recursively

Generalizes to arbitrary spline curves (just label control points correctly instead of 00 01 11 for Bezier)

Easy for many analyses (beyond scope of course)

Page 23: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 12: Spline Curves (review) Ravi Ramamoorthi cs4162 Most material

Subdividing Bezier CurvesSubdividing Bezier Curves

Drawing: Subdivide into halves (u = ½) Demo: hw2.exe Recursively draw each piece At some tolerance, draw control polygon Trivial for Bezier curves (from deCasteljau algorithm): hence

widely used for drawing

Why specific labels/ control points on left/right? How do they follow from deCasteljau?

000 001 011 111

000 00u 0uu uuu uuu uu1 u11 111

Page 24: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 12: Spline Curves (review) Ravi Ramamoorthi cs4162 Most material

Geometrically

00½

0½1

½11

0½½ ½½1½½½

000 111

001 011

Page 25: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 12: Spline Curves (review) Ravi Ramamoorthi cs4162 Most material

Geometrically

00½

0½1

½11

0½½ ½½1½½½

000 111

001 011

Page 26: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 12: Spline Curves (review) Ravi Ramamoorthi cs4162 Most material

Subdivision in deCasteljau diagramSubdivision in deCasteljau diagram

000

001 011

111

000 001 011 1111-u u u u1-u 1-u

00u 01u 11u

1-u u u1-u

0uu 1uu

1-u u

uuu

Left part of Bezier curve(000, 00u, 0uu, uuu)Always left edge of deCasteljau pyramid

Right part of Bezier curve(uuu, 1uu, 11u, 111)

Always right edge of deCasteljau pyramid

These (interior) points don’t appear in subdivided curves at all

Page 27: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 12: Spline Curves (review) Ravi Ramamoorthi cs4162 Most material

Properties (brief discussion)Properties (brief discussion)

Demo:

Interpolation: End-points, but approximates others

Single piece, moving one point affects whole curve (no local control as in B-splines later)

Invariant to translations, rotations, scales etc. That is, translating all control points translates entire curve

Easily subdivided into parts for drawing. Hence, Bezier curves easiest for drawing (4160-HW2)

hw2.exe

Page 28: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 12: Spline Curves (review) Ravi Ramamoorthi cs4162 Most material

Bezier: DisadvantagesBezier: Disadvantages

Single piece, no local control (move a control point, whole curve changes) hw2.exe

Complex shapes: can be very high degree, difficult

In practice, combine many Bezier curve segments But only position continuous at join since Bezier curves

interpolate end-points (which match at segment boundaries)

Unpleasant derivative (slope) discontinuities at end-points Can you see why this is an issue?

Page 29: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 12: Spline Curves (review) Ravi Ramamoorthi cs4162 Most material

Piecewise Polynomial CurvesPiecewise Polynomial Curves

Idea: Use different polynomial functions

for different parts of the curve

Advantage: Flexibility Local control

Issue: Smoothness at “joints” (continuity)

Page 30: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 12: Spline Curves (review) Ravi Ramamoorthi cs4162 Most material

ContinuityContinuity

Continuity Ck indicates adjacent curves have the same kth derivative at their joints

Page 31: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 12: Spline Curves (review) Ravi Ramamoorthi cs4162 Most material

CC00 Continuity Continuity

Adjacent curves share … Same endpoints: Qi(1) = Qi+1(0)

Aside: discontinuous curves sometimes called “C-1”

Page 32: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 12: Spline Curves (review) Ravi Ramamoorthi cs4162 Most material

CC11 Continuity Continuity

Adjacent curves share … Same endpoints: Qi(1) = Qi+1(0) Same derivatives: Qi ’(1) = Qi+1 ’(0)

Page 33: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 12: Spline Curves (review) Ravi Ramamoorthi cs4162 Most material

CC22 Continuity Continuity

Adjacent curves share … Same endpoints: Qi(1) = Qi+1(0) Same derivatives: Qi ’(1) = Qi+1 ’(0) Same second derivatives: Qi ’’(1) = Qi+1 ’’(0)

Page 34: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 12: Spline Curves (review) Ravi Ramamoorthi cs4162 Most material

(Cubic) Spline Constructions(Cubic) Spline Constructions

Bézier: 4 control points

B-splines: approximating, C2, local control

Hermite: 2 points, 2 normals

Natural splines: interpolating, C2, no local control

Catmull-Rom: interpolating, C1, local control

Book chapter 11 covers some spline constructionsBut material is hard to read, doesn’t follow formathere. I recommend following lecture.

Page 35: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 12: Spline Curves (review) Ravi Ramamoorthi cs4162 Most material

B-SplinesB-Splines

Cubic B-splines have C2 continuity, local control

4 segments / control point, 4 control points/segment

Knots where two segments join: Knotvector

Knotvector uniform/non-uniform (we only consider uniform cubic B-splines, not general NURBS)

Knot: C2 continuity

deBoor points

Demo: hw2.exe

Page 36: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 12: Spline Curves (review) Ravi Ramamoorthi cs4162 Most material

Polar Forms: Cubic Bspline CurvePolar Forms: Cubic Bspline Curve

-2 –1 0

–1 0 1 0 1 2

1 2 3

Labeling little different from in Bezier curve

No interpolation of end-points like in Bezier

Advantage of polar forms: easy to generalize

Uniform knot vector:-2, -1, 0, 1, 2 ,3

Labels correspond to this

Page 37: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 12: Spline Curves (review) Ravi Ramamoorthi cs4162 Most material

deCasteljau: Cubic B-SplinesdeCasteljau: Cubic B-Splines

Easy to generalize using polar-form labels

Impossible remember without

-2 –1 0

–1 0 1 0 1 2

1 2 3

-2 -1 0 -1 0 1 0 1 2 1 2 3

-1 0 u 0 1 u 1 2 u

? ? ????

Page 38: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 12: Spline Curves (review) Ravi Ramamoorthi cs4162 Most material

deCasteljau: Cubic B-SplinesdeCasteljau: Cubic B-Splines

Easy to generalize using polar-form labels

Impossible remember without

-2 –1 0

–1 0 1 0 1 2

1 2 3

-2 -1 0 -1 0 1 0 1 2 1 2 3

-1 0 u 0 1 u 1 2 u1-u/3

(1-u)/3 (2+u)/3(2-u)/3 (1+u)/3 u/3

0 u u 1 u u? ? ? ?

Page 39: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 12: Spline Curves (review) Ravi Ramamoorthi cs4162 Most material

deCasteljau: Cubic B-SplinesdeCasteljau: Cubic B-Splines

Easy to generalize using polar-form labels

Impossible remember without

-2 –1 0

–1 0 1 0 1 2

1 2 3

-2 -1 0 -1 0 1 0 1 2 1 2 3

-1 0 u 0 1 u 1 2 u1-u/3

(1-u)/3 (2+u)/3(2-u)/3 (1+u)/3 u/3

0 u u 1 u u

(1-u)/2 (1+u)/21-u/2 u/2

u u u1-u u

Page 40: Advanced Computer Graphics (Spring 2005) COMS 4162, Lecture 12: Spline Curves (review) Ravi Ramamoorthi cs4162 Most material

Explicit Formula (derive as exercise)Explicit Formula (derive as exercise)

-2 -1 0 -1 0 1 0 1 2 1 2 3

-1 0 u 0 1 u 1 2 u1-u/3

(1-u)/3 (2+u)/3(2-u)/3 (1+u)/3 u/3

0 u u 1 u u

(1-u)/2 (1+u)/21-u/2 u/2

u u u1-u u

3 2

0

1( ) [ 1]

2

3

P

PF u u u u

P

P

M

1 3 3 1

3 6 3 0

3 0 3 0

1 4 1 0

16

M

P0 P1 P2 P3