cs 445/645 fall 2001 splines/film/animation. final exam thursday, december 13 th from 7 – 10 p.m....

40
CS 445/645 Fall 2001 Splines/Film/Animation

Upload: ashlynn-ford

Post on 05-Jan-2016

212 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CS 445/645 Fall 2001 Splines/Film/Animation. Final Exam Thursday, December 13 th from 7 – 10 p.m. –Room Olsson 011 You may use one sheet of notes (8.5

CS 445/645Fall 2001

Splines/Film/Animation

Page 2: CS 445/645 Fall 2001 Splines/Film/Animation. Final Exam Thursday, December 13 th from 7 – 10 p.m. –Room Olsson 011 You may use one sheet of notes (8.5

Final Exam

• Thursday, December 13th from 7 – 10 p.m.– Room Olsson 011

• You may use one sheet of notes (8.5 x 11’’)– You can write on both sides of paper

• Not everything from semester will be on test– Class on Thursday will outline material and

review

Page 3: CS 445/645 Fall 2001 Splines/Film/Animation. Final Exam Thursday, December 13 th from 7 – 10 p.m. –Room Olsson 011 You may use one sheet of notes (8.5

Wanted: Undergrad TAs

• Undergrads needed to TA and grade for CS courses– TA labs for CS101, CS201, CS216, etc.– Office hours, grading for all undergrad courses

• To apply, fill out form at:– http://www.cs.virginia.edu/jobs

• Get to know CS professors (letters of reco)• Good for you resume• You folks play an important role in delivering high-

quality CS courses at UVA

Page 4: CS 445/645 Fall 2001 Splines/Film/Animation. Final Exam Thursday, December 13 th from 7 – 10 p.m. –Room Olsson 011 You may use one sheet of notes (8.5

Teaching Evaluations

• Would you like this course to continue to be taught?

• We need feedback that students like this course and want it to be a permanent part of our course offerings

• Think about what you liked in the course– And what you didn’t like

• And fill out a survey

Page 5: CS 445/645 Fall 2001 Splines/Film/Animation. Final Exam Thursday, December 13 th from 7 – 10 p.m. –Room Olsson 011 You may use one sheet of notes (8.5

Today

• One more type of curve to look at– B-splines

• Some leftover slides about films

• Some slides about animation

Page 6: CS 445/645 Fall 2001 Splines/Film/Animation. Final Exam Thursday, December 13 th from 7 – 10 p.m. –Room Olsson 011 You may use one sheet of notes (8.5

Specifying Curves

• Control Points– A set of points that influence the

curve’s shape

• Knots– Control points that lie on the curve

• Interpolating Splines– Curves that pass through the control

points (knots)

• Approximating Splines– Control points merely influence shape

Page 7: CS 445/645 Fall 2001 Splines/Film/Animation. Final Exam Thursday, December 13 th from 7 – 10 p.m. –Room Olsson 011 You may use one sheet of notes (8.5

Parametric Cubic Splines

• Can represent this as a matrix too

Page 8: CS 445/645 Fall 2001 Splines/Film/Animation. Final Exam Thursday, December 13 th from 7 – 10 p.m. –Room Olsson 011 You may use one sheet of notes (8.5

Hermite Cubic Splines

• An example of knot and continuity constraints

Page 9: CS 445/645 Fall 2001 Splines/Film/Animation. Final Exam Thursday, December 13 th from 7 – 10 p.m. –Room Olsson 011 You may use one sheet of notes (8.5

Resulting Hermite Spline Equation

Page 10: CS 445/645 Fall 2001 Splines/Film/Animation. Final Exam Thursday, December 13 th from 7 – 10 p.m. –Room Olsson 011 You may use one sheet of notes (8.5

Demonstration

• Hermite

Page 11: CS 445/645 Fall 2001 Splines/Film/Animation. Final Exam Thursday, December 13 th from 7 – 10 p.m. –Room Olsson 011 You may use one sheet of notes (8.5

Blending Functions

• By multiplying first two components, you have four functions of ‘t’ that blend the four control parameters

Page 12: CS 445/645 Fall 2001 Splines/Film/Animation. Final Exam Thursday, December 13 th from 7 – 10 p.m. –Room Olsson 011 You may use one sheet of notes (8.5

Hermite Blending Functions

• If you plot the blending functions on the parameter ‘t’

Page 13: CS 445/645 Fall 2001 Splines/Film/Animation. Final Exam Thursday, December 13 th from 7 – 10 p.m. –Room Olsson 011 You may use one sheet of notes (8.5

Bézier Curves

• Similar to Hermite, but more intuitive definition of endpoint derivatives

• Four control points, two of which are knots

Page 14: CS 445/645 Fall 2001 Splines/Film/Animation. Final Exam Thursday, December 13 th from 7 – 10 p.m. –Room Olsson 011 You may use one sheet of notes (8.5

Bézier Curves

• Similar to Hermite, but more intuitive definition of endpoint derivatives

• Four control points, two of which are knots

Page 15: CS 445/645 Fall 2001 Splines/Film/Animation. Final Exam Thursday, December 13 th from 7 – 10 p.m. –Room Olsson 011 You may use one sheet of notes (8.5

Bézier Curves

• The derivative values of the Bezier Curve at the knots are dependent on the adjacent points

• The scalar 3 was selected just for this curve

Page 16: CS 445/645 Fall 2001 Splines/Film/Animation. Final Exam Thursday, December 13 th from 7 – 10 p.m. –Room Olsson 011 You may use one sheet of notes (8.5

Bézier Basis and Geometry Matrices

• Matrix Form

• But why is MBezier a good basis matrix?

Page 17: CS 445/645 Fall 2001 Splines/Film/Animation. Final Exam Thursday, December 13 th from 7 – 10 p.m. –Room Olsson 011 You may use one sheet of notes (8.5

Bézier Blending Functions

• Look at the blending functions

• This family of polynomials is calledorder-3 Bernstein Polynomials– They are all positive in interval [0,1]– Their sum is equal to 1

Page 18: CS 445/645 Fall 2001 Splines/Film/Animation. Final Exam Thursday, December 13 th from 7 – 10 p.m. –Room Olsson 011 You may use one sheet of notes (8.5

Bézier Blending Functions

• Thus, every point on curve is linear combination of the control points

• The weights of the combination are all positive

• The sum of the weights is 1• Therefore, the curve is a

convex combination of the control points

Page 19: CS 445/645 Fall 2001 Splines/Film/Animation. Final Exam Thursday, December 13 th from 7 – 10 p.m. –Room Olsson 011 You may use one sheet of notes (8.5

Bézier Curves

• Bezier

Page 20: CS 445/645 Fall 2001 Splines/Film/Animation. Final Exam Thursday, December 13 th from 7 – 10 p.m. –Room Olsson 011 You may use one sheet of notes (8.5

Splines - History

• Draftsman use ‘ducks’ and strips of wood (splines) to draw curves

• Wood splines have second-order continuity

• And pass through the control points

A Duck (weight)

Ducks trace out curve

Page 21: CS 445/645 Fall 2001 Splines/Film/Animation. Final Exam Thursday, December 13 th from 7 – 10 p.m. –Room Olsson 011 You may use one sheet of notes (8.5

Why more spline lectures?

• Bezier and Hermite splines have global influence– Moving one control point affects the entire

curve

• B-splines consist of curve segments whose polynomial coefficients depend on just a few control points– Local control

Page 22: CS 445/645 Fall 2001 Splines/Film/Animation. Final Exam Thursday, December 13 th from 7 – 10 p.m. –Room Olsson 011 You may use one sheet of notes (8.5

Uniform B-Splines

• Approximating Splines

• Approximates m+1 control points

– P0, P1, …, Pm, m ¸ 3

• Curve consists of m –2 cubic polynomial segments

– Q3, Q4, … Qm

• t varies along B-spline as Qi: ti <= t < ti+1

• ti (i = integer) are knot points that join segment Qi-1 to Qi

• Curve is uniform because knots are spaced at equal intervals of parameter, t

Page 23: CS 445/645 Fall 2001 Splines/Film/Animation. Final Exam Thursday, December 13 th from 7 – 10 p.m. –Room Olsson 011 You may use one sheet of notes (8.5

Uniform B-Splines

• First curve segment, Q3, is defined by first four control points

• Last curve segment, Qm, is defined by last four control points, Pm-3, Pm-2, Pm-1, Pm

• Each control point affects four curve segments

Page 24: CS 445/645 Fall 2001 Splines/Film/Animation. Final Exam Thursday, December 13 th from 7 – 10 p.m. –Room Olsson 011 You may use one sheet of notes (8.5

B-spline Basis Matrix

• Formulate 16 equations to solve the 16 unknowns

• The 16 equations enforce the C0, C1, and C2 continuity between adjoining segments, Q

0141

0303

0363

1331

6

1splineBM

Page 25: CS 445/645 Fall 2001 Splines/Film/Animation. Final Exam Thursday, December 13 th from 7 – 10 p.m. –Room Olsson 011 You may use one sheet of notes (8.5

B-Spline

• Points along B-Spline are computed just as with Bezier Curves

PUMtQ SplineBi

3

2

123

0141

0303

0363

1331

6

11

i

i

i

i

i

p

p

p

p

ttttQ

Page 26: CS 445/645 Fall 2001 Splines/Film/Animation. Final Exam Thursday, December 13 th from 7 – 10 p.m. –Room Olsson 011 You may use one sheet of notes (8.5

B-Spline

• By far the most popular spline used

• C0, C1, and C2 continuous

Page 27: CS 445/645 Fall 2001 Splines/Film/Animation. Final Exam Thursday, December 13 th from 7 – 10 p.m. –Room Olsson 011 You may use one sheet of notes (8.5

B-Spline

• Locality of points

Page 28: CS 445/645 Fall 2001 Splines/Film/Animation. Final Exam Thursday, December 13 th from 7 – 10 p.m. –Room Olsson 011 You may use one sheet of notes (8.5

Nonuniform, Rational B-Splines(NURBS)

• The native geometry element in Maya

• Models are composed of surfaces defined by NURBS, not polygons

• NURBS are smooth

• NURBS require effort to make non-smooth

Page 29: CS 445/645 Fall 2001 Splines/Film/Animation. Final Exam Thursday, December 13 th from 7 – 10 p.m. –Room Olsson 011 You may use one sheet of notes (8.5

What is a NURB?

• Nonuniform: The amount of parameter, t, that is used to model each curve segment varies

• Rational: The parametric functions that define each curve segment are ratios of polynomals:

)(

)()(,

)(

)()(,

)(

)()(

tW

tZtz

tW

tYty

tW

tXtx

Page 30: CS 445/645 Fall 2001 Splines/Film/Animation. Final Exam Thursday, December 13 th from 7 – 10 p.m. –Room Olsson 011 You may use one sheet of notes (8.5

What do we get?

• Nonuniformity permits either C2, C1, or C0 continuity at join points between curve segments

• Nonuniformity permits control points to be added to middle of curve

• Rational curves are invariant under rotation, scaling, translation, and perspective transformations of the control points (nonrational curves are not preserved under perspective projection)– This means you can transform the control points and

redraw the curve using the transformed points– If this weren’t true you’d have to sample curve to many

points and transform each point individually

Page 31: CS 445/645 Fall 2001 Splines/Film/Animation. Final Exam Thursday, December 13 th from 7 – 10 p.m. –Room Olsson 011 You may use one sheet of notes (8.5

What do we get?

• NURBS represent conics

Page 32: CS 445/645 Fall 2001 Splines/Film/Animation. Final Exam Thursday, December 13 th from 7 – 10 p.m. –Room Olsson 011 You may use one sheet of notes (8.5

Converting Between Splines

• Consider two spline basis formulations for two spline types

Page 33: CS 445/645 Fall 2001 Splines/Film/Animation. Final Exam Thursday, December 13 th from 7 – 10 p.m. –Room Olsson 011 You may use one sheet of notes (8.5

Converting Between Splines

• We can transform the control points from one spline basis to another

Page 34: CS 445/645 Fall 2001 Splines/Film/Animation. Final Exam Thursday, December 13 th from 7 – 10 p.m. –Room Olsson 011 You may use one sheet of notes (8.5

Converting Between Splines

• With this conversion, we can convert a B-Spline into a Bezier Spline

• Bezier Splines are easy to render

Page 35: CS 445/645 Fall 2001 Splines/Film/Animation. Final Exam Thursday, December 13 th from 7 – 10 p.m. –Room Olsson 011 You may use one sheet of notes (8.5

Rendering Splines

• Horner’s Method

• Incremental (Forward Difference) Method

• Subdivision Methods

Page 36: CS 445/645 Fall 2001 Splines/Film/Animation. Final Exam Thursday, December 13 th from 7 – 10 p.m. –Room Olsson 011 You may use one sheet of notes (8.5

Horner’s Method

• Three multiplications

• Three additions

xxxx

xxxx

ducubuaux

ducubuaux

])[()(

)( 23

Page 37: CS 445/645 Fall 2001 Splines/Film/Animation. Final Exam Thursday, December 13 th from 7 – 10 p.m. –Room Olsson 011 You may use one sheet of notes (8.5

Forward Difference

• But this still is expensive to compute

)()23(3

)()()(2322

1

231

23

1

xxxkxxkxkkk

xkxkxkxk

xxxk

kkk

cbaubauaxxx

ducubuax

ducubuax

xxx

33

321

2

232

2

12

21

6

266

))(

xk

kkk

xxxk

kkkk

kkk

ax

xxx

baax

xxxx

xxx

Page 38: CS 445/645 Fall 2001 Splines/Film/Animation. Final Exam Thursday, December 13 th from 7 – 10 p.m. –Room Olsson 011 You may use one sheet of notes (8.5

Forward Difference

• So, at startup compute these things

• Successive values of x requires 3 additions

230

2

230

0

26

xx

xxx

x

bax

cbax

dx

Page 39: CS 445/645 Fall 2001 Splines/Film/Animation. Final Exam Thursday, December 13 th from 7 – 10 p.m. –Room Olsson 011 You may use one sheet of notes (8.5

Subdivision Methods

• Bezier

Page 40: CS 445/645 Fall 2001 Splines/Film/Animation. Final Exam Thursday, December 13 th from 7 – 10 p.m. –Room Olsson 011 You may use one sheet of notes (8.5

Rendering Bezier Spline

public void spline(ControlPoint p0, ControlPoint p1, ControlPoint p2, ControlPoint p3, int pix) { float len = ControlPoint.dist(p0,p1) + ControlPoint.dist(p1,p2) + ControlPoint.dist(p2,p3); float chord = ControlPoint.dist(p0,p3); if (Math.abs(len - chord) < 0.25f) return; fatPixel(pix, p0.x, p0.y); ControlPoint p11 = ControlPoint.midpoint(p0, p1); ControlPoint tmp = ControlPoint.midpoint(p1, p2); ControlPoint p12 = ControlPoint.midpoint(p11, tmp); ControlPoint p22 = ControlPoint.midpoint(p2, p3); ControlPoint p21 = ControlPoint.midpoint(p22, tmp); ControlPoint p20 = ControlPoint.midpoint(p12, p21); spline(p20, p12, p11, p0, pix); spline(p3, p22, p21, p20, pix); }