07 - Designing Interpolating Curves

58
CSCI-GA.2270-001 - Computer Graphics - Daniele Panozzo 07 - Designing Interpolating Curves Acknowledgement: Olga Sorkine-Hornung, Alexander Sorkine-Hornung, Ilya Baran

Transcript of 07 - Designing Interpolating Curves

Page 1: 07 - Designing Interpolating Curves

CSCI-GA.2270-001 - Computer Graphics - Daniele Panozzo

07 - Designing Interpolating Curves

Acknowledgement: Olga Sorkine-Hornung, Alexander Sorkine-Hornung, Ilya Baran

Page 2: 07 - Designing Interpolating Curves

CSCI-GA.2270-001 - Computer Graphics - Daniele Panozzo

How do we model shapes?

Delcam Plc. [CC BY-SA 3.0 (http://creativecommons.org/licenses/by-sa/3.0) or GFDL (http://www.gnu.org/copyleft/fdl.html)], via Wikimedia Commons

Page 3: 07 - Designing Interpolating Curves

CSCI-GA.2270-001 - Computer Graphics - Daniele Panozzo

Building blocks: curves and surfaces

By Wojciech mula at Polish Wikipedia, CC BY-SA 3.0, https://commons.wikimedia.org/w/index.php?curid=9853555

Page 4: 07 - Designing Interpolating Curves

CSCI-GA.2270-001 - Computer Graphics - Daniele Panozzo

A modeling session

• Demo with Keynote for 2D

• Demo with Blender for 3D

Page 5: 07 - Designing Interpolating Curves

CSCI-GA.2270-001 - Computer Graphics - Daniele Panozzo

Modeling curves

• We need mathematical concepts to characterize the desired curve properties

• Notions from curve geometry help with designing user interfaces for curve creation and editing

Page 6: 07 - Designing Interpolating Curves

CSCI-GA.2270-001 - Computer Graphics - Daniele Panozzo

2D parametric curve• must be continuous

Page 7: 07 - Designing Interpolating Curves

CSCI-GA.2270-001 - Computer Graphics - Daniele Panozzo

A curve can be parameterized in many different ways

Page 8: 07 - Designing Interpolating Curves

CSCI-GA.2270-001 - Computer Graphics - Daniele Panozzo

Tangent vector

Parametrizat

ion-indepen

dent!

Page 9: 07 - Designing Interpolating Curves

CSCI-GA.2270-001 - Computer Graphics - Daniele Panozzo

Arc length• How long is the curve between and ? How far does the particle

travel?

• Speed is , so:

• Speed is nonnegative, so is non-decreasing

Page 10: 07 - Designing Interpolating Curves

CSCI-GA.2270-001 - Computer Graphics - Daniele Panozzo

Arc length parameterization• Every curve has a natural parameterization:

Page 11: 07 - Designing Interpolating Curves

CSCI-GA.2270-001 - Computer Graphics - Daniele Panozzo

Arc length parameterization• Every curve has a natural parameterization:

• Isometry between parameter domain and curve

• Tangent vector is unit-length:

Page 12: 07 - Designing Interpolating Curves

CSCI-GA.2270-001 - Computer Graphics - Daniele Panozzo

Curvature• How much does the curve turn per unit ?

Page 13: 07 - Designing Interpolating Curves

CSCI-GA.2270-001 - Computer Graphics - Daniele Panozzo

Curvature• How much does the curve turn per unit ?

Page 14: 07 - Designing Interpolating Curves

CSCI-GA.2270-001 - Computer Graphics - Daniele Panozzo

Curvature profile

• Given , we can get up to a constant by integration. Integrating

reconstructs the curve up to rigid motion.

Page 15: 07 - Designing Interpolating Curves

CSCI-GA.2270-001 - Computer Graphics - Daniele Panozzo

Curvature of a circle• Curvature of a circle:

Osculating circle

= Unit Normal

Page 16: 07 - Designing Interpolating Curves

CSCI-GA.2270-001 - Computer Graphics - Daniele Panozzo

Frenet Frame

Page 17: 07 - Designing Interpolating Curves

CSCI-GA.2270-001 - Computer Graphics - Daniele Panozzo

Curvature normal• Points inward

• useful for evaluating curve quality

Page 18: 07 - Designing Interpolating Curves

CSCI-GA.2270-001 - Computer Graphics - Daniele Panozzo

SmoothnessTwo kinds, parametric and geometric:

Parametrization-Independent

Page 19: 07 - Designing Interpolating Curves

CSCI-GA.2270-001 - Computer Graphics - Daniele Panozzo

Smoothness example

Page 20: 07 - Designing Interpolating Curves

CSCI-GA.2270-001 - Computer Graphics - Daniele Panozzo

Recap on parametric curves

Page 21: 07 - Designing Interpolating Curves

CSCI-GA.2270-001 - Computer Graphics - Daniele Panozzo

Turning• Angle from start tangent to end tangent:

• If curve is closed, the tangent at the beginning is the same as the tangent at the end

Page 22: 07 - Designing Interpolating Curves

CSCI-GA.2270-001 - Computer Graphics - Daniele Panozzo

Turning numbers

• measures how many full turns the tangent makes.

1 –1 2 0

Page 23: 07 - Designing Interpolating Curves

CSCI-GA.2270-001 - Computer Graphics - Daniele Panozzo

Space curves (3D)• In 3D, many vectors are orthogonal to T

• are the “Frenet frame”

• is torsion: non-planarity

N

T

B

Page 24: 07 - Designing Interpolating Curves

CSCI-GA.2270-001 - Computer Graphics - Daniele Panozzo

Designing Curves:Polynomials and Interpolation

Page 25: 07 - Designing Interpolating Curves

CSCI-GA.2270-001 - Computer Graphics - Daniele Panozzo

Basic idea for curve design• User gives us points. We need to connect the dots in a smooth way.

• The dots stay as “handles” on the curve. User can move the dots and the curve follows.

Page 26: 07 - Designing Interpolating Curves

CSCI-GA.2270-001 - Computer Graphics - Daniele Panozzo

Basic idea for curve design• User gives us points. We need to connect the dots in a smooth way.

• The dots stay as “handles” on the curve. User can move the dots and the curve follows.

Page 27: 07 - Designing Interpolating Curves

CSCI-GA.2270-001 - Computer Graphics - Daniele Panozzo

Keynote Demo

Page 28: 07 - Designing Interpolating Curves

CSCI-GA.2270-001 - Computer Graphics - Daniele Panozzo

Blender Demo

Page 29: 07 - Designing Interpolating Curves

CSCI-GA.2270-001 - Computer Graphics - Daniele Panozzo

Polynomial curves• Polynomials

• For degree we need points (“coefficients”)

Page 30: 07 - Designing Interpolating Curves

CSCI-GA.2270-001 - Computer Graphics - Daniele Panozzo

Polynomials• Parametric form with polynomials

• Control shape?

Page 31: 07 - Designing Interpolating Curves

CSCI-GA.2270-001 - Computer Graphics - Daniele Panozzo

Polynomials• Parametric form with polynomials

• Control shape?

Page 32: 07 - Designing Interpolating Curves

CSCI-GA.2270-001 - Computer Graphics - Daniele Panozzo

Polynomials• Parametric form with polynomials

• Control shape?

Page 33: 07 - Designing Interpolating Curves

CSCI-GA.2270-001 - Computer Graphics - Daniele Panozzo

Polynomials• Parametric form with polynomials

• Control shape?

Page 34: 07 - Designing Interpolating Curves

CSCI-GA.2270-001 - Computer Graphics - Daniele Panozzo

Polynomials• Parametric form with polynomials

• Control shape?

Page 35: 07 - Designing Interpolating Curves

CSCI-GA.2270-001 - Computer Graphics - Daniele Panozzo

Polynomials• Parametric form with polynomials

• Control shape?

Page 36: 07 - Designing Interpolating Curves

CSCI-GA.2270-001 - Computer Graphics - Daniele Panozzo

Polynomials• Parametric form with polynomials

• Control shape?

Page 37: 07 - Designing Interpolating Curves

CSCI-GA.2270-001 - Computer Graphics - Daniele Panozzo

Polynomials• Parametric form with polynomials

• Control shape?

• Monomial coefficients are not intuitive

Page 38: 07 - Designing Interpolating Curves

CSCI-GA.2270-001 - Computer Graphics - Daniele Panozzo

Interpolation (1D)• Interpolate control points • Find polynomial

with

Page 39: 07 - Designing Interpolating Curves

CSCI-GA.2270-001 - Computer Graphics - Daniele Panozzo

Interpolation (1D)• Interpolate control points • Find polynomial

with

Page 40: 07 - Designing Interpolating Curves

CSCI-GA.2270-001 - Computer Graphics - Daniele Panozzo

Interpolation (1D)• Interpolate control points • Find polynomial

with • Solve

Vandermonde matrix

Page 41: 07 - Designing Interpolating Curves

CSCI-GA.2270-001 - Computer Graphics - Daniele Panozzo

Interpolation (1D)• Interpolate control points • Find polynomial

with • Solve

Page 42: 07 - Designing Interpolating Curves

CSCI-GA.2270-001 - Computer Graphics - Daniele Panozzo

Interpolation (1D)• Interpolate control points • Find polynomial

with • Solve

Page 43: 07 - Designing Interpolating Curves

CSCI-GA.2270-001 - Computer Graphics - Daniele Panozzo

Interpolation (1D)• Polynomial fitting can be done explicitly:

• Check that

• Products are called Lagrange polynomials

Page 44: 07 - Designing Interpolating Curves

CSCI-GA.2270-001 - Computer Graphics - Daniele Panozzo

Example of 1D Interpolation

Page 45: 07 - Designing Interpolating Curves

CSCI-GA.2270-001 - Computer Graphics - Daniele Panozzo

Recap

• Monomial coefficients unintuitive

• Lagrange interpolation is better, but there is a global effect

• The possible curves are the same: just cubics

Page 46: 07 - Designing Interpolating Curves

CSCI-GA.2270-001 - Computer Graphics - Daniele Panozzo

Polynomials form a vector space• You can add and subtract them

• You can multiply them by real numbers

• These operations follow the usual rules • Associativity, commutativity, inverses for addition • Distributivity for scalar multiplication • Etc.

• Anything you can do with vectors in general, you can do with polynomials.

Page 47: 07 - Designing Interpolating Curves

CSCI-GA.2270-001 - Computer Graphics - Daniele Panozzo

Monomial basis for cubics:

Page 48: 07 - Designing Interpolating Curves

CSCI-GA.2270-001 - Computer Graphics - Daniele Panozzo

Interpolation basis for :

Page 49: 07 - Designing Interpolating Curves

CSCI-GA.2270-001 - Computer Graphics - Daniele Panozzo

Remark

• Basis change is just a matrix multiplication

• We need to find a good basis for intuitively designing curves

Page 50: 07 - Designing Interpolating Curves

CSCI-GA.2270-001 - Computer Graphics - Daniele Panozzo

Interpolation in 2D• We now have pairs we want to interpolate:

• How to choose ’s at which to specify ?

• Parameter space matters!

Page 51: 07 - Designing Interpolating Curves

CSCI-GA.2270-001 - Computer Graphics - Daniele Panozzo

Runge’s phenomenon

Page 52: 07 - Designing Interpolating Curves

CSCI-GA.2270-001 - Computer Graphics - Daniele Panozzo

Splines• Paste together low-degree polynomials

CubicCub

ic

Cubic

Cubic Cub

ic

Page 53: 07 - Designing Interpolating Curves

CSCI-GA.2270-001 - Computer Graphics - Daniele Panozzo

How do we get smoothness?• With Lagrange polynomials, it’s hard to get tangents to match up

Page 54: 07 - Designing Interpolating Curves

CSCI-GA.2270-001 - Computer Graphics - Daniele Panozzo

Hermite Basis• Instead of four points, specify two points and two derivatives:

Cubic polynomials of the form

p(t0) = p0

p(t1) = p1

p0(t0) = m0

p0(t1) = m1

Page 55: 07 - Designing Interpolating Curves

CSCI-GA.2270-001 - Computer Graphics - Daniele Panozzo

Hermite Basis• Instead of four points, specify two points and two derivatives:

Page 56: 07 - Designing Interpolating Curves

CSCI-GA.2270-001 - Computer Graphics - Daniele Panozzo

Catmull-Rom splines• If no tangents are explicitly specified – get them from the input

points!

Page 57: 07 - Designing Interpolating Curves

CSCI-GA.2270-001 - Computer Graphics - Daniele Panozzo

Next time

• Approximating Curves • Bezier splines • B-splines

Page 58: 07 - Designing Interpolating Curves

CSCI-GA.2270-001 - Computer Graphics - Daniele Panozzo

References

Fundamentals of Computer Graphics, Fourth Edition 4th Edition by Steve Marschner, Peter Shirley

Chapter 15