48
lecture 10 - cubic curves - cubic splines - bicubic surfaces

lecture 10 - cubic curves - cubic splineslanger/557/10-slides.pdf · Convexity property can be useful for clipping and intersections e.g. bounding volume. Catmull-Rom Spline (Motivation)

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: lecture 10 - cubic curves - cubic splineslanger/557/10-slides.pdf · Convexity property can be useful for clipping and intersections e.g. bounding volume. Catmull-Rom Spline (Motivation)

lecture 10

- cubic curves

- cubic splines

- bicubic surfaces

Page 2: lecture 10 - cubic curves - cubic splineslanger/557/10-slides.pdf · Convexity property can be useful for clipping and intersections e.g. bounding volume. Catmull-Rom Spline (Motivation)

We want to define smooth curves:

- for defining paths of cameras or objects

- for defining 1D shapes of objects

We want to define smooth surfaces too.

Page 3: lecture 10 - cubic curves - cubic splineslanger/557/10-slides.pdf · Convexity property can be useful for clipping and intersections e.g. bounding volume. Catmull-Rom Spline (Motivation)

Parametric Equation of a Line

The curve is a linear combination oftwo points. How to generalize this?

Page 4: lecture 10 - cubic curves - cubic splineslanger/557/10-slides.pdf · Convexity property can be useful for clipping and intersections e.g. bounding volume. Catmull-Rom Spline (Motivation)

The curve will be a linear combination ofthe points. How ?

Page 5: lecture 10 - cubic curves - cubic splineslanger/557/10-slides.pdf · Convexity property can be useful for clipping and intersections e.g. bounding volume. Catmull-Rom Spline (Motivation)

Cubic Curves

Each is a polynomial of degree 3 and defined over allt.

Page 6: lecture 10 - cubic curves - cubic splineslanger/557/10-slides.pdf · Convexity property can be useful for clipping and intersections e.g. bounding volume. Catmull-Rom Spline (Motivation)

Choosing the coefficients gives us a curve,but how do we choose the coefficients ?

Page 7: lecture 10 - cubic curves - cubic splineslanger/557/10-slides.pdf · Convexity property can be useful for clipping and intersections e.g. bounding volume. Catmull-Rom Spline (Motivation)

Fitting a cubic function.

(Why are 4 points needed ?)

Page 8: lecture 10 - cubic curves - cubic splineslanger/557/10-slides.pdf · Convexity property can be useful for clipping and intersections e.g. bounding volume. Catmull-Rom Spline (Motivation)
Page 9: lecture 10 - cubic curves - cubic splineslanger/557/10-slides.pdf · Convexity property can be useful for clipping and intersections e.g. bounding volume. Catmull-Rom Spline (Motivation)

Multiplying by B gives solution for coefficients a, b, c, d.

Page 10: lecture 10 - cubic curves - cubic splineslanger/557/10-slides.pdf · Convexity property can be useful for clipping and intersections e.g. bounding volume. Catmull-Rom Spline (Motivation)

We apply the same technique for y(t) and z(t) .

I will walk through the derivation again, but this timesolve for all x(t), y(t), z(t).

Trying to solve for this.

Page 11: lecture 10 - cubic curves - cubic splineslanger/557/10-slides.pdf · Convexity property can be useful for clipping and intersections e.g. bounding volume. Catmull-Rom Spline (Motivation)
Page 12: lecture 10 - cubic curves - cubic splineslanger/557/10-slides.pdf · Convexity property can be useful for clipping and intersections e.g. bounding volume. Catmull-Rom Spline (Motivation)

Now what ?

Page 13: lecture 10 - cubic curves - cubic splineslanger/557/10-slides.pdf · Convexity property can be useful for clipping and intersections e.g. bounding volume. Catmull-Rom Spline (Motivation)

This gives us the 4x4 coefficient matrix (a,b,c,d).

Page 14: lecture 10 - cubic curves - cubic splineslanger/557/10-slides.pdf · Convexity property can be useful for clipping and intersections e.g. bounding volume. Catmull-Rom Spline (Motivation)

geometry

blending

Page 15: lecture 10 - cubic curves - cubic splineslanger/557/10-slides.pdf · Convexity property can be useful for clipping and intersections e.g. bounding volume. Catmull-Rom Spline (Motivation)

A blending matrix is 4 x 1.Each row is a polynomial of degree 3 in t.

The blending matrix B is independent of thegeometry matrix ! It can be precomputed once andstored.

Page 16: lecture 10 - cubic curves - cubic splineslanger/557/10-slides.pdf · Convexity property can be useful for clipping and intersections e.g. bounding volume. Catmull-Rom Spline (Motivation)

Suppose we are given n >> 4 points and we would like asmooth curve through them in given order. How?

Page 17: lecture 10 - cubic curves - cubic splineslanger/557/10-slides.pdf · Convexity property can be useful for clipping and intersections e.g. bounding volume. Catmull-Rom Spline (Motivation)

We could take

[ p0, p1, p2, p3 ]

[ p3, p4, p5, p6 ]

[ p6, p7, p8, p9 ]

and make cubic curve segments for each, and putthem together at "knot" points.

Q: Does that work ?

A: No, we might have tangent discontinuities.

Page 18: lecture 10 - cubic curves - cubic splineslanger/557/10-slides.pdf · Convexity property can be useful for clipping and intersections e.g. bounding volume. Catmull-Rom Spline (Motivation)

There is no reason why the resulting curve should besmooth at the knots.

Page 19: lecture 10 - cubic curves - cubic splineslanger/557/10-slides.pdf · Convexity property can be useful for clipping and intersections e.g. bounding volume. Catmull-Rom Spline (Motivation)

SplinesIn general, curves used for interpolating between points arecalled 'splines'.

Page 20: lecture 10 - cubic curves - cubic splineslanger/557/10-slides.pdf · Convexity property can be useful for clipping and intersections e.g. bounding volume. Catmull-Rom Spline (Motivation)

In mathematics, a spline is a piecewise polynomialfunction.

It should satisfy some continuity condition at theplaces (called "knots") where the polynomial piecesjoin.An example is that the "tangent" is continuous ...

Page 21: lecture 10 - cubic curves - cubic splineslanger/557/10-slides.pdf · Convexity property can be useful for clipping and intersections e.g. bounding volume. Catmull-Rom Spline (Motivation)

Tangent Vector

Page 22: lecture 10 - cubic curves - cubic splineslanger/557/10-slides.pdf · Convexity property can be useful for clipping and intersections e.g. bounding volume. Catmull-Rom Spline (Motivation)

How to reformulate the problem toconsider tangents?

Page 23: lecture 10 - cubic curves - cubic splineslanger/557/10-slides.pdf · Convexity property can be useful for clipping and intersections e.g. bounding volume. Catmull-Rom Spline (Motivation)

How can we use these data to choose matrices asfollows ?

Hermite Curvehttp://en.wikipedia.org/wiki/Charles_Hermite

Given this:

Page 24: lecture 10 - cubic curves - cubic splineslanger/557/10-slides.pdf · Convexity property can be useful for clipping and intersections e.g. bounding volume. Catmull-Rom Spline (Motivation)

Hermite Curvehttp://en.wikipedia.org/wiki/Charles_Hermite

Page 25: lecture 10 - cubic curves - cubic splineslanger/557/10-slides.pdf · Convexity property can be useful for clipping and intersections e.g. bounding volume. Catmull-Rom Spline (Motivation)

Multiply both sides by the following.

This gives us the coefficient matrix.

Page 26: lecture 10 - cubic curves - cubic splineslanger/557/10-slides.pdf · Convexity property can be useful for clipping and intersections e.g. bounding volume. Catmull-Rom Spline (Motivation)
Page 27: lecture 10 - cubic curves - cubic splineslanger/557/10-slides.pdf · Convexity property can be useful for clipping and intersections e.g. bounding volume. Catmull-Rom Spline (Motivation)

Q: What are the weights at time t = 0, 1 ?

A:

Page 28: lecture 10 - cubic curves - cubic splineslanger/557/10-slides.pdf · Convexity property can be useful for clipping and intersections e.g. bounding volume. Catmull-Rom Spline (Motivation)

Hermite Cubic Spline

How do we fit a curve to n point + tangent pairs ?

Page 29: lecture 10 - cubic curves - cubic splineslanger/557/10-slides.pdf · Convexity property can be useful for clipping and intersections e.g. bounding volume. Catmull-Rom Spline (Motivation)

The tangents are equal at the knots (good).

Page 30: lecture 10 - cubic curves - cubic splineslanger/557/10-slides.pdf · Convexity property can be useful for clipping and intersections e.g. bounding volume. Catmull-Rom Spline (Motivation)

Bézier Curve

Page 31: lecture 10 - cubic curves - cubic splineslanger/557/10-slides.pdf · Convexity property can be useful for clipping and intersections e.g. bounding volume. Catmull-Rom Spline (Motivation)
Page 32: lecture 10 - cubic curves - cubic splineslanger/557/10-slides.pdf · Convexity property can be useful for clipping and intersections e.g. bounding volume. Catmull-Rom Spline (Motivation)

"Bernstein polynomials"

for t in [0, 1], they lie in [0,1]and they sum to 1.(convexity property)

Page 33: lecture 10 - cubic curves - cubic splineslanger/557/10-slides.pdf · Convexity property can be useful for clipping and intersections e.g. bounding volume. Catmull-Rom Spline (Motivation)

Convexity property can be useful for clipping andintersections e.g. bounding volume.

Page 34: lecture 10 - cubic curves - cubic splineslanger/557/10-slides.pdf · Convexity property can be useful for clipping and intersections e.g. bounding volume. Catmull-Rom Spline (Motivation)

Catmull-Rom Spline (Motivation)

With Bezier, we avoided specifying tangent vectors butnow the curve passes through only half the points.(Essentially, we are still specifying tangents.)

We would like to interpolate ALL points (unlike Bezier !)but also have the nice Hermite property of continuoustangent vector at knots.

Page 35: lecture 10 - cubic curves - cubic splineslanger/557/10-slides.pdf · Convexity property can be useful for clipping and intersections e.g. bounding volume. Catmull-Rom Spline (Motivation)

Catmull-Rom Spline

Exercise: what are the geometry and blending matrices?

Page 36: lecture 10 - cubic curves - cubic splineslanger/557/10-slides.pdf · Convexity property can be useful for clipping and intersections e.g. bounding volume. Catmull-Rom Spline (Motivation)

lecture 10

- cubic curves

- bicubic surfaces

Page 37: lecture 10 - cubic curves - cubic splineslanger/557/10-slides.pdf · Convexity property can be useful for clipping and intersections e.g. bounding volume. Catmull-Rom Spline (Motivation)

Suppose we are given a 4x4 "grid" of 3Dpoints.We would like to interpolate a surface. How ?

Page 38: lecture 10 - cubic curves - cubic splineslanger/557/10-slides.pdf · Convexity property can be useful for clipping and intersections e.g. bounding volume. Catmull-Rom Spline (Motivation)

Start by fitting 4 cubic curves, corresponding to s = 0, 1, 2, 3. Use the vanilla method at start of lecture.

Then, for each t, fit a cubic curve as a function of s.

Page 39: lecture 10 - cubic curves - cubic splineslanger/557/10-slides.pdf · Convexity property can be useful for clipping and intersections e.g. bounding volume. Catmull-Rom Spline (Motivation)

The solution is:

... and similarly for y(s,t) and z(s,t).

I will derive it over the next several slides.

Page 40: lecture 10 - cubic curves - cubic splineslanger/557/10-slides.pdf · Convexity property can be useful for clipping and intersections e.g. bounding volume. Catmull-Rom Spline (Motivation)

For each

s = 0, 1, 2, 3

Page 41: lecture 10 - cubic curves - cubic splineslanger/557/10-slides.pdf · Convexity property can be useful for clipping and intersections e.g. bounding volume. Catmull-Rom Spline (Motivation)

Stacking them gives:

Page 42: lecture 10 - cubic curves - cubic splineslanger/557/10-slides.pdf · Convexity property can be useful for clipping and intersections e.g. bounding volume. Catmull-Rom Spline (Motivation)

For any t, we have four points which we write as arow vector. This gives us our vanilla problem.

Note: We're only keeping track of x values here,but there are y and z values too.

Page 43: lecture 10 - cubic curves - cubic splineslanger/557/10-slides.pdf · Convexity property can be useful for clipping and intersections e.g. bounding volume. Catmull-Rom Spline (Motivation)

For any t, we fit a cubic of parameter s.

Page 44: lecture 10 - cubic curves - cubic splineslanger/557/10-slides.pdf · Convexity property can be useful for clipping and intersections e.g. bounding volume. Catmull-Rom Spline (Motivation)

Taking the transpose...

... and replacing the right column with ...

... gives the answer.

Page 45: lecture 10 - cubic curves - cubic splineslanger/557/10-slides.pdf · Convexity property can be useful for clipping and intersections e.g. bounding volume. Catmull-Rom Spline (Motivation)

Surface tangents and surface normals

Page 46: lecture 10 - cubic curves - cubic splineslanger/557/10-slides.pdf · Convexity property can be useful for clipping and intersections e.g. bounding volume. Catmull-Rom Spline (Motivation)

surface tangents

Any linear combination of these is also a tangent.

Page 47: lecture 10 - cubic curves - cubic splineslanger/557/10-slides.pdf · Convexity property can be useful for clipping and intersections e.g. bounding volume. Catmull-Rom Spline (Motivation)

surface normal

surface tangents

Page 48: lecture 10 - cubic curves - cubic splineslanger/557/10-slides.pdf · Convexity property can be useful for clipping and intersections e.g. bounding volume. Catmull-Rom Spline (Motivation)

Summary

- cubic curve vs cubic spline

- 'vanilla', Hermite, Bézier, Catmull-Rom

- geometry (control points) versus blending

- defining tangents in terms of differences of point positions

- lots of algebra that you should understand but not memorize