Bézier Curves and Splines

Similar documents
CSE 167: Lecture 13: Bézier Curves. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2011

Modeling Curves and Surfaces

Computer Graphics. Geometric Modeling. Page 1. Copyright Gotsman, Elber, Barequet, Karni, Sheffer Computer Science - Technion. An Example.

Computer Graphics CS 543 Lecture 12 (Part 1) Curves. Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

Figure 2.1: Center of mass of four points.

CHAPTER 1 Splines and B-splines an Introduction

(Refer Slide Time: 1:42)

We can display an object on a monitor screen in three different computer-model forms: Wireframe model Surface Model Solid model

Essential Mathematics for Computer Graphics fast

MA 323 Geometric Modelling Course Notes: Day 02 Model Construction Problem

Geometric Modelling & Curves

Solving Simultaneous Equations and Matrices

Name: Section Registered In:

Degree Reduction of Interval SB Curves

Content. Chapter 4 Functions Basic concepts on real functions 62. Credits 11

the points are called control points approximating curve

NOTES ON LINEAR TRANSFORMATIONS

Section 1.1. Introduction to R n

Mathematics Course 111: Algebra I Part IV: Vector Spaces

MATH2210 Notebook 1 Fall Semester 2016/ MATH2210 Notebook Solving Systems of Linear Equations... 3

The Essentials of CAGD

Corollary. (f є C n+1 [a,b]). Proof: This follows directly from the preceding theorem using the inequality

Pre-Algebra Academic Content Standards Grade Eight Ohio. Number, Number Sense and Operations Standard. Number and Number Systems

Solutions to Math 51 First Exam January 29, 2015

MATH 304 Linear Algebra Lecture 9: Subspaces of vector spaces (continued). Span. Spanning set.

Dhiren Bhatia Carnegie Mellon University

DERIVATIVES AS MATRICES; CHAIN RULE

4.5 Linear Dependence and Linear Independence

MATH1231 Algebra, 2015 Chapter 7: Linear maps

Linear Algebra Notes for Marsden and Tromba Vector Calculus

1 Review of Least Squares Solutions to Overdetermined Systems

Finite Element Formulation for Plates - Handout 3 -

JUST THE MATHS UNIT NUMBER 8.5. VECTORS 5 (Vector equations of straight lines) A.J.Hobson

BEZIER CURVES AND SURFACES

Big Ideas in Mathematics

Planar Curve Intersection

Curves and Surfaces. Goals. How do we draw surfaces? How do we specify a surface? How do we approximate a surface?

Mathematical Modeling for Game Design

Recall that two vectors in are perpendicular or orthogonal provided that their dot

Algebra Academic Content Standards Grade Eight and Grade Nine Ohio. Grade Eight. Number, Number Sense and Operations Standard

B2.53-R3: COMPUTER GRAPHICS. NOTE: 1. There are TWO PARTS in this Module/Paper. PART ONE contains FOUR questions and PART TWO contains FIVE questions.

Copyrighted Material. Chapter 1 DEGREE OF A CURVE

x = + x 2 + x

Largest Fixed-Aspect, Axis-Aligned Rectangle

a 11 x 1 + a 12 x a 1n x n = b 1 a 21 x 1 + a 22 x a 2n x n = b 2.

Lecture L3 - Vectors, Matrices and Coordinate Transformations

Prentice Hall Algebra Correlated to: Colorado P-12 Academic Standards for High School Mathematics, Adopted 12/2009

1 Introduction to Matrices

A Short Introduction to Computer Graphics

Similarity and Diagonalization. Similar Matrices

Math 4310 Handout - Quotient Vector Spaces

1 Sets and Set Notation.

Math 241, Exam 1 Information.

Lecture Notes 2: Matrices as Systems of Linear Equations

South Carolina College- and Career-Ready (SCCCR) Pre-Calculus

Section 1.4. Lines, Planes, and Hyperplanes. The Calculus of Functions of Several Variables

Mean value theorem, Taylors Theorem, Maxima and Minima.

KEANSBURG SCHOOL DISTRICT KEANSBURG HIGH SCHOOL Mathematics Department. HSPA 10 Curriculum. September 2007

MATH APPLIED MATRIX THEORY

521493S Computer Graphics. Exercise 2 & course schedule change

Topics in Computer Graphics Chap 14: Tensor Product Patches

MATH10212 Linear Algebra. Systems of Linear Equations. Definition. An n-dimensional vector is a row or a column of n numbers (or letters): a 1.

CONTROLLABILITY. Chapter Reachable Set and Controllability. Suppose we have a linear system described by the state equation

Thnkwell s Homeschool Precalculus Course Lesson Plan: 36 weeks

Inner Product Spaces

University of Lille I PC first year list of exercises n 7. Review

3. Interpolation. Closing the Gaps of Discretization... Beyond Polynomials

Georgia Department of Education Kathy Cox, State Superintendent of Schools 7/19/2005 All Rights Reserved 1

Introduction to Computer Graphics

Geometric Transformation CS 211A

by the matrix A results in a vector which is a reflection of the given

CITY UNIVERSITY LONDON. BEng Degree in Computer Systems Engineering Part II BSc Degree in Computer Systems Engineering Part III PART 2 EXAMINATION

Prentice Hall Mathematics: Algebra Correlated to: Utah Core Curriculum for Math, Intermediate Algebra (Secondary)

Linear Programming. March 14, 2014

MATH 423 Linear Algebra II Lecture 38: Generalized eigenvectors. Jordan canonical form (continued).

3. INNER PRODUCT SPACES

Precalculus REVERSE CORRELATION. Content Expectations for. Precalculus. Michigan CONTENT EXPECTATIONS FOR PRECALCULUS CHAPTER/LESSON TITLES

THE DIMENSION OF A VECTOR SPACE

Vector Spaces; the Space R n

MATRIX ALGEBRA AND SYSTEMS OF EQUATIONS. + + x 2. x n. a 11 a 12 a 1n b 1 a 21 a 22 a 2n b 2 a 31 a 32 a 3n b 3. a m1 a m2 a mn b m

MCS 563 Spring 2014 Analytic Symbolic Computation Wednesday 9 April. Hilbert Polynomials

Figure 1.1 Vector A and Vector F

How To Use Design Mentor

1 Cubic Hermite Spline Interpolation

LS.6 Solution Matrices

In mathematics, there are four attainment targets: using and applying mathematics; number and algebra; shape, space and measures, and handling data.

Vector and Matrix Norms

Linear Algebra Notes

Review of Fundamental Mathematics

Vector Math Computer Graphics Scott D. Anderson

Algebra and Geometry Review (61 topics, no due date)

Current Standard: Mathematical Concepts and Applications Shape, Space, and Measurement- Primary

MAT 242 Test 2 SOLUTIONS, FORM T

Unified Lecture # 4 Vectors

Algebra 2 Chapter 1 Vocabulary. identity - A statement that equates two equivalent expressions.

Linear Algebra Review. Vectors

A Geometric Characterization of Parametric Cubic Curves

Higher Education Math Placement

1 VECTOR SPACES AND SUBSPACES

Monash University Clayton s School of Information Technology CSE3313 Computer Graphics Sample Exam Questions 2007

Transcription:

6.837 Computer Graphics Bézier Curves and Splines Wojciech Matusik MIT CSAIL vectorportal.com 6.837 Matusik

2 Before We Begin Anything on your mind concerning Assignment 0? Any questions about the course? Assignment 1 (Curves & Surfaces) Linear algebra review session

Today Smooth curves in 2D Useful in their own right Provides basis for surface editing This image is in the public domain Source:Wikimedia Commons 3

4 Modeling 1D Curves in 2D Polylines Sequence of vertices connected by straight line segments Useful, but not for smooth curves This is the representation that usually gets drawn in the end (a curve is converted into a polyline) Smooth curves How do we specify them? A little harder (but not too much)

Splines A type of smooth curve in 2D/3D Many different uses 2D illustration (e.g., Adobe Illustrator) Fonts (e.g., PostScript, TrueType) 3D modeling Animation: trajectories In general: interpolation and approximation ACM 1987 Principles of traditional animation applied to 3D computer animation ACM. All rights reserved. This content is excluded from our Creative Commons license. For more information, see http://ocw.mit.edu/help/faq-fair-use/. 5

Demo 6

How Many Dimensions? 7

How Many Dimensions? This curve lies on the 2D plane, but is itself 1D. 8

How Many Dimensions? This curve lies on the 2D plane, but is itself 1D. You can just as well define 1D curves in 3D space. 9

Two Definitions of a Curve A continuous 1D set of points in 2D (or 3D) A mapping from an interval S onto the plane That is, P(t) is the point of the curve at parameter t Big differences It is easy to generate points on the curve from the 2nd The second definition can describe trajectories, the speed at which we move on the curve 10

11 General Principle of Splines User specifies control points We will interpolate the control points by a smooth curve The curve is completely determined by the control points.

12 Physical Splines Courtesy of The Antique Boat Museum. See http://en.wikipedia.org/wiki/flat_spline

13 Two Application Scenarios Approximation/interpolation We have data points, how can we interpolate? Important in many applications User interface/modeling What is an easy way to specify a smooth curve? Our main perspective today. Image courtesy of SaphireS on Wikimedia Commons. License: CC-BY- SA. This content is excluded from our Creative Commons license. For more information, see http://ocw.mit.edu/help/faq-fair-use/.

Questions? 14

15 Splines Specified by a few control points Good for UI Good for storage Results in a smooth parametric curve P(t) Just means that we specify x(t) and y(t) In practice: low-order polynomials, chained together Convenient for animation, where t is time Convenient for tessellation because we can discretize t and approximate the curve with a polyline

Tessellation It is easy to rasterize mathematical line segments into pixels OpenGL and the graphics hardware can do it for you But polynomials and other parametric functions are harder Image courtesy of Phrood on Wikimedia Commons. License: CC-BY-SA.This content is excluded from our Creative Commons license. For moreinformation, see http://ocw.mit.edu/help/faq-fair-use/. 6.837 Durand 16

17 Tessellation tn t1 t2 To display P(t), discretize it at discrete ts t0

18 Tessellation tn t1 t2 t0 It s clear that adding more points will get us closer to the curve.

19 Tessellation tn t1 t2 t0 It s clear that adding more points will get us closer to the curve.

20 Interpolation vs. Approximation Interpolation Goes through all specified points Sounds more logical Interpolation Approximation Does not go through all points Approximation

Interpolation vs. Approximation Interpolation Goes through all specified points Sounds more logical But can be more unstable Approximation Does not go through all points Turns out to be convenient Interpolation We will do something in between. Approximation 21

Questions? 22

23 Cubic Bézier Curve User specifies 4 control points P1... P4 Curve goes through (interpolates) the ends P1, P4 Approximates the two other ones Cubic polynomial

24 Cubic Bézier Curve P(t) = (1-t)³ P1 + 3t(1-t)² P2 + 3t²(1-t) P3 + t³ P4 That is,

25 Cubic Bézier Curve P(t) = (1-t)³ P1 + 3t(1-t)² P2 + 3t²(1-t) P3 + t³ P4 Verify what happens for t=0 and t=1

26 Cubic Bézier Curve 4 control points Curve passes through first & last control point Courtesy of Seth Teller. Used with permission.

27 Cubic Bézier Curve 4 control points Curve passes through first & last control point Curve is tangent at P1 to (P1-P2) and at P4 to (P4-P3) A Bézier curve is bounded by the convex hull of its control points.

Questions? 28

29 Why Does the Formula Work? Explanation 1: Magic! Explanation 2: These are smart weights that describe the influence of each control point Explanation 3: It is a linear combination of basis polynomials.

Weights P(t) is a weighted combination of the 4 control points with weights: B1(t)=(1-t)³ B2(t)=3t(1-t)² B3(t)=3t²(1-t) B4(t)=t³ First, P1 is the most influential point, P(t) = (1-t)³ P1 + 3t(1-t)² P2 + 3t²(1-t) P3 + t³ P4 then P2, P3, and P4 30

31 Weights P2 and P3 never have full influence Not interpolated! P(t) = (1-t)³ P1 + 3t(1-t)² P2 + 3t²(1-t) P3 + t³ P4

Questions? 32

33 Why Does the Formula Work? Explanation 1: Magic! Explanation 2: These are smart weights that describe the influence of each control point Explanation 3: It is a linear combination of basis polynomials. The opposite perspective: control points are the weights of polynomials!!!

34 Why Study Splines as Vector Space? Understand relationships between types of splines Conversion Express what happens when a spline curve is transformed by an affine transform (rotation, translation, etc.) Cool simple example of non-trivial vector space Important to understand for advanced methods such as finite elements

35 Usual Vector Spaces In 3D, each vector has three components x, y, z But geometrically, each vector is actually the sum i, j, k are basis vectors j k i Vector addition: just add components Scalar multiplication: just multiply components

36 Polynomials as a Vector Space Polynomials Can be added: just add the coefficients Can be multiplied by a scalar: multiply the coefficients

Polynomials as a Vector Space Polynomials In the polynomial vector space, {1, t,..., tn} are the basis vectors, a0, a1,..., an are the components 37

Questions? 38

39 Subset of Polynomials: Cubic Closed under addition & scalar multiplication Means the result is still a cubic polynomial (verify!) Cubic polynomials also compose a vector space A 4D subspace of the full space of polynomials The x and y coordinates of cubic Bézier curves belong to this subspace as functions of t.

Basis for Cubic Polynomials More precisely: What s a basis? A set of atomic vectors In 3D Called basis vectors Linear combinations of basis vectors span the space i.e. any cubic polynomial is a sum of those basis cubics Linearly independent Means that no basis vector can be obtained from the others by linear combination Example: i, j, i+j is not a basis (missing k direction!) j k i 40

Canonical Basis for Cubics 1 t t2 t3 Any cubic polynomial is a linear combination of these: a0+a1t+a2t2+a3t3 = a0*1+a1*t+a2*t2+a3*t3 They are linearly independent Means you cannot write any of the four monomials as a linear combination of the others. (You can try.) 41

42 Different Basis For example: {1, 1+t, 1+t+t2, 1+t-t2+t3} {t3, t3+t2, t3+t, t3+1} 2D examples These can all be obtained from by linear combination Infinite number of possibilities, just like you have an infinite number of bases to span R2

43 Matrix-Vector Notation For example: 1, 1+t, 1+t+t², 1+t-t²+t³ t³, t³+t², t³+t, t³+1 These relationships hold for each value of t Change-of-basis matrix Canonical monomial basis

Matrix-Vector Notation For example: 1, 1+t, 1+t+t2, 1+t-t2+t3 t3, t3+t2, t3+t, t3+1 Change-of-basis matrix Canonical monomial basis Not any matrix will do! If it s singular, the basis set will be linearly dependent, i.e., redundant and incomplete. 44

45 Bernstein Polynomials For Bézier curves, the basis polynomials/vectors are Bernstein polynomials For cubic Bezier curve: B1(t)=(1-t)³ B2(t)=3t(1-t)² B3(t)=3t²(1-t) B4(t)=t³ (careful with indices, many authors start at 0) Defined for any degree

Properties of Bernstein Polynomials for all 0 t 1 Sum to 1 for every t called partition of unity These two together are the reason why Bézier curves lie within convex hull B1(0) =1 Bezier curve interpolates P1 B4(1) =1 Bezier curve interpolates P4 46

47 Bézier Curves in Bernstein Basis P(t) = P1B1(t) + P2B2(t) + P3B3(t) + P4B4(t) Pi are 2D points (xi, yi) P(t) is a linear combination of the control points with weights equal to Bernstein polynomials at t But at the same time, the control points (P1, P2, P3, P4) are the coordinates of the curve in the Bernstein basis In this sense, specifying a Bézier curve with control points is exactly like specifying a 2D point with its x and y coordinates.

Two Different Vector Spaces!!! The plane where the curve lies, a 2D vector space The space of cubic polynomials, a 4D space Don t be confused! The 2D control points can be replaced by 3D points this yields space curves. The math stays the same, just add z(t). The cubic basis can be extended to higher-order polynomials Higher-dimensional vector space More control points 48

Questions? 49

50 Change of Basis How do we go from Bernstein basis to the canonical monomial basis 1, t, t², t³ and back? With a matrix! B1(t)=(1-t)³ B2(t)=3t(1-t)² B3(t)=3t²(1-t) B4(t)=t³ New basis vectors

51 How You Get the Matrix Cubic Bernstein: B1(t)=(1-t)³ B2(t)=3t(1-t)² B3(t)=3t²(1-t) B4(t)=t³ Expand these out and collect powers of t. The coefficients are the entries in the matrix B!

52 Change of Basis, Other Direction Given B1...B4, how to get back to canonical 1, t, t², t³?

53 Change of Basis, Other Direction That s right, with the inverse matrix! Given B1...B4, how to get back to canonical 1, t, t², t³?

54 Recap Cubic polynomials form a 4D vector space. Bernstein basis is canonical for Bézier. Can be seen as influence function of data points Or data points are coordinates of the curve in the Bernstein basis We can change between basis with matrices.

Questions? 55

56 More Matrix-Vector Notation Bernstein polynomials (4x1 vector) point on curve (2x1 vector) matrix of control points (2 x 4)

Flashback 57

Cubic Bézier in Matrix Notation point on curve (2x1 vector) Canonical monomial basis Geometry matrix of control points P1..P4 (2 x 4) Spline matrix (Bernstein) 58

General Spline Formulation Geometry: control points coordinates assembled into a matrix (P1, P2,, Pn+1) Spline matrix: defines the type of spline Bernstein for Bézier Power basis: the monomials (1, t,..., tn) Advantage of general formulation Compact expression Easy to convert between types of splines Dimensionality (plane or space) does not really matter 59

Questions? 60

61 A Cubic Only Gets You So Far What if you want more control?

Higher-Order Bézier Curves > 4 control points Bernstein Polynomials as the basis functions For polynomial of order n, the ith basis function is Every control point affects the entire curve Not simply a local effect More difficult to control for modeling You will not need this in this class Courtesy of Seth Teller. Used with permission. 62

63 Subdivision of a Bezier Curve Can we split a Bezier curve in the middle into two Bézier curves? This is useful for adding detail It avoids using nasty higher-order curves?

64 Subdivision of a Bezier Curve Can we split a Bezier curve in the middle into two Bézier curves? The resulting curves are again a cubic (Why? A cubic in t is also a cubic in 2t) Hence it must be representable using the Bernstein basis. So yes, we can! t1=2t t2=2t-0.5? cubic t=0 t=0.5 t=1

65 De Casteljau Construction Take the middle point of each of the 3 segments Construct the two segments joining them Take the middle of those two new segments Join them Take the middle point P P 1 P 1 P 2 P 2 P P 3

66 Result of Split in Middle The two new curves are defined by P1, P 1, P 1, and P P, P 2, P 3, and P4 Together they exactly replicate the original curve! P 1 Originally P 2 4 control points, now 7 (more control) P 1 P 2 P P 3 P1 P4

67 Sanity Check Do we actually get the middle point? B1(t)=(1-t)³ B2(t)=3t(1-t)² B3(t)=3t²(1-t) B4(t)=t³ P 2 P 1 P 1 P 2 P P 3

68 De Casteljau Construction Actually works to construct a point at any t, not just 0.5 Just subdivide the segments with ratio (1-t), t (not in the middle) t t t t t t

69 Recap Bezier curves: piecewise polynomials Bernstein polynomials Linear combination of basis functions Basis: control points weights: polynomials Basis: polynomials weights: control points Subdivision by de Casteljau algorithm All linear, matrix algebra

70 Recap Bezier curves: piecewise polynomials Bernstein polynomials Linear combination of basis functions Basis: control points weights: polynomials Basis: polynomials weights: control points Subdivision by de Casteljau algorithm All linear, matrix algebra

That s All for Today, Folks Further reading Buss, Chapters 7 and 8 Fun stuff to know about function/vector spaces http://en.wikipedia.org/wiki/vector_space http://en.wikipedia.org/wiki/functional_analysis http://en.wikipedia.org/wiki/function_space Inkscape is an open source vector drawing program for Mac/Windows. Try it out! vectorportal.com 7

MIT OpenCourseWare http://ocw.mit.edu 6.837 Computer Graphics Fall 2012 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms.