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

Similar documents
Computergrafik. Matthias Zwicker Universität Bern Herbst 2016

CMSC427 Parametric curves: Hermite, Catmull-Rom, Bezier

Interpolation and polynomial approximation Interpolation

On-Line Geometric Modeling Notes

M2R IVR, October 12th Mathematical tools 1 - Session 2

Sample Exam 1 KEY NAME: 1. CS 557 Sample Exam 1 KEY. These are some sample problems taken from exams in previous years. roughly ten questions.

Lecture 20: Bezier Curves & Splines

Lecture 23: Hermite and Bezier Curves

Bézier Curves and Splines

Arsène Pérard-Gayot (Slides by Piotr Danilewski)

Introduction to Computer Graphics. Modeling (1) April 13, 2017 Kenshi Takayama

Approximation of Circular Arcs by Parametric Polynomials

Curves, Surfaces and Segments, Patches

Curves. Hakan Bilen University of Edinburgh. Computer Graphics Fall Some slides are courtesy of Steve Marschner and Taku Komura

MAT300/500 Programming Project Spring 2019

CGT 511. Curves. Curves. Curves. What is a curve? 2) A continuous map of a 1D space to an nd space

Bernstein polynomials of degree N are defined by

1.1. The analytical denition. Denition. The Bernstein polynomials of degree n are dened analytically:

Introduction to Curves. Modelling. 3D Models. Points. Lines. Polygons Defined by a sequence of lines Defined by a list of ordered points

Computer Graphics Keyframing and Interpola8on

Lagrange Interpolation and Neville s Algorithm. Ron Goldman Department of Computer Science Rice University

The Essentials of CAGD

MA 323 Geometric Modelling Course Notes: Day 07 Parabolic Arcs

Smooth Path Generation Based on Bézier Curves for Autonomous Vehicles

MA 323 Geometric Modelling Course Notes: Day 12 de Casteljau s Algorithm and Subdivision

Cubic Splines; Bézier Curves

AFFINE COMBINATIONS, BARYCENTRIC COORDINATES, AND CONVEX COMBINATIONS

CSE 167: Introduction to Computer Graphics Lecture #2: Linear Algebra Primer

Spiral spline interpolation to a planar spiral

CONTROL POLYGONS FOR CUBIC CURVES

Visualizing Bezier s curves: some applications of Dynamic System Geogebra

Keyframing. CS 448D: Character Animation Prof. Vladlen Koltun Stanford University

CS 536 Computer Graphics NURBS Drawing Week 4, Lecture 6

CSE 167: Introduction to Computer Graphics Lecture #2: Linear Algebra Primer

Lecture 20: Lagrange Interpolation and Neville s Algorithm. for I will pass through thee, saith the LORD. Amos 5:17

Continuous Curvature Path Generation Based on Bézier Curves for Autonomous Vehicles

Q( t) = T C T =! " t 3,t 2,t,1# Q( t) T = C T T T. Announcements. Bezier Curves and Splines. Review: Third Order Curves. Review: Cubic Examples

Home Page. Title Page. Contents. Bezier Curves. Milind Sohoni sohoni. Page 1 of 27. Go Back. Full Screen. Close.

MA 323 Geometric Modelling Course Notes: Day 11 Barycentric Coordinates and de Casteljau s algorithm

Animation Curves and Splines 1

Subdivision Matrices and Iterated Function Systems for Parametric Interval Bezier Curves

Reading. w Foley, Section 11.2 Optional

CMSC427 Geometry and Vectors

Characterization of Planar Cubic Alternative curve. Perak, M sia. M sia. Penang, M sia.

Curve Fitting: Fertilizer, Fonts, and Ferraris

Announcements September 19

NFC ACADEMY COURSE OVERVIEW

Applied Math 205. Full office hour schedule:

THE UNIVERSITY OF BRITISH COLUMBIA Midterm Examination 14 March 2001

Pythagorean-hodograph curves

MA 323 Geometric Modelling Course Notes: Day 20 Curvature and G 2 Bezier splines

Computer Aided Design. B-Splines

RADNOR TOWNSHIP SCHOOL DISTRICT Course Overview Honors Algebra 2 ( )

Outline. 1 Interpolation. 2 Polynomial Interpolation. 3 Piecewise Polynomial Interpolation

Geometric Lagrange Interpolation by Planar Cubic Pythagorean-hodograph Curves

Announcements. Review. Announcements. Piecewise Affine Quadratic Lyapunov Theory. EECE 571M/491M, Spring 2007 Lecture 9

56 CHAPTER 3. POLYNOMIAL FUNCTIONS

Hermite Interpolation with Euclidean Pythagorean Hodograph Curves

Demo 5. 1 Degree Reduction and Raising Matrices for Degree 5

Novel polynomial Bernstein bases and Bézier curves based on a general notion of polynomial blossoming

Chapter 1 Numerical approximation of data : interpolation, least squares method

Lecture 8: Coordinate Frames. CITS3003 Graphics & Animation

Engineering 7: Introduction to computer programming for scientists and engineers

Analyzing Functions Maximum & Minimum Points Lesson 75

A matrix Method for Interval Hermite Curve Segmentation O. Ismail, Senior Member, IEEE

SPLINE INTERPOLATION

A Relationship Between Minimum Bending Energy and Degree Elevation for Bézier Curves

Lesson 6b Rational Exponents & Radical Functions

R1: Sets A set is a collection of objects sets are written using set brackets each object in onset is called an element or member

An O(h 2n ) Hermite approximation for conic sections

Mon Jan Improved acceleration models: linear and quadratic drag forces. Announcements: Warm-up Exercise:

G-code and PH curves in CNC Manufacturing

Secondary Honors Algebra II Objectives

Lecture 5 3D polygonal modeling Part 1: Vector graphics Yong-Jin Liu.

Scientific Computing

3.1 Interpolation and the Lagrange Polynomial

2 The De Casteljau algorithm revisited

Computing roots of polynomials by quadratic clipping

Some notes on Chapter 8: Polynomial and Piecewise-polynomial Interpolation

GEOMETRIC MODELLING WITH BETA-FUNCTION B-SPLINES, I: PARAMETRIC CURVES

To find an approximate value of the integral, the idea is to replace, on each subinterval

Introduction. Introduction (2) Easy Problems for Vectors 7/13/2011. Chapter 4. Vector Tools for Graphics

Cubic Splines MATH 375. J. Robert Buchanan. Fall Department of Mathematics. J. Robert Buchanan Cubic Splines

Matrix Methods for the Bernstein Form and Their Application in Global Optimization

B-splines and control theory

Exam 2. Average: 85.6 Median: 87.0 Maximum: Minimum: 55.0 Standard Deviation: Numerical Methods Fall 2011 Lecture 20

Path Planning based on Bézier Curve for Autonomous Ground Vehicles

Prentice Hall CME Project, Algebra

Planar interpolation with a pair of rational spirals T. N. T. Goodman 1 and D. S. Meek 2

9th and 10th Grade Math Proficiency Objectives Strand One: Number Sense and Operations

Math 660-Lecture 15: Finite element spaces (I)

Missouri Educator Gateway Assessments DRAFT

I can translate between a number line graph, an inequality, and interval notation.

1 Roots of polynomials

Curves - Foundation of Free-form Surfaces

Scientific Computing: An Introductory Survey

Name: ID: Math 233 Exam 1. Page 1

Wed. Sept 28th: 1.3 New Functions from Old Functions: o vertical and horizontal shifts o vertical and horizontal stretching and reflecting o

Identify the graph of a function, and obtain information from or about the graph of a function.

Academic Content Standard MATHEMATICS. MA 51 Advanced Placement Calculus BC

Transcription:

CSE 167: Introduction to Computer Graphics Lecture 11: Bézier Curves Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2012

Announcements Homework project #5 due Nov. 9 th at 1:30pm To be presented in lab 260 Veterans Day: reschedule homework introduction Friday at 3:30pm? Tuesday before or after class? In Winter: CSE 190: 3D User Interaction 4 Units 2 lectures (Mon/Wed 11am-12:20pm) Programming assignments for 3D input devices 2

Lecture Overview Polynomial Curves Introduction Polynomial functions Bézier Curves Introduction Drawing Bézier curves Piecewise Bézier curves 3

Modeling Creating 3D objects How to construct complex surfaces? Goal Specify objects with control points Objects should be visually pleasing (smooth) Start with curves, then generalize to surfaces Next: What can curves be used for? 4

Curves Surface of revolution 5

Curves Extruded/swept surfaces 6

Curves Animation Provide a track for objects Use as camera path 7

Curves Specify parameter values over time 8

Curves Can be generalized to surface patches 9

Curve Representation Specify many points along a curve, connect with lines? Difficult to get precise, smooth results across magnification levels Large storage and CPU requirements How many points are enough? Specify a curve using a small number of control points Known as a spline curve or just spline Control point 10

Spline: Definition Wikipedia: Term comes from flexible spline devices used by shipbuilders and draftsmen to draw smooth shapes. Spline consists of a long strip fixed in position at a number of points that relaxes to form a smooth curve passing through those points. 11

Interpolating Control Points Interpolating means that curve goes through all control points Seems most intuitive Surprisingly, not usually the best choice Hard to predict behavior Hard to get aesthetically pleasing curves 12

Approximating Control Points Curve is influenced by control points Various types Most common: polynomial functions Bézier spline (our main focus) B-spline (generalization of Bézier spline) NURBS (Non Uniform Rational Basis Spline): used in CAD tools 13

Mathematical Definition A vector valued function of one variable x(t) Given t, compute a 3D point x=(x,y,z) Could be interpreted as three functions: x(t), y(t), z(t) Parameter t moves a point along the curve x(t) z y x(0.0) x(0.5) x(1.0) x 14

Tangent Vector Derivative Vector x points in direction of movement Length corresponds to speed x(t) z y x (0.0) x (0.5) x (1.0) 15 x

Lecture Overview Polynomial Curves Introduction Polynomial functions Bézier Curves Introduction Drawing Bézier curves Piecewise Bézier curves 16

Polynomial Functions Linear: (1 st order) Quadratic: (2 nd order) Cubic: (3 rd order) 17

Polynomial Curves Linear Evaluated as: 18

Polynomial Curves Quadratic: (2 nd order) Cubic: (3 rd order) We usually define the curve for 0 t 1 19

Control Points Polynomial coefficients a, b, c, d can be interpreted as control points Remember: a, b, c, d have x,y,z components each Unfortunately, they do not intuitively describe the shape of the curve Goal: intuitive control points 20

Control Points How many control points? Two points define a line (1 st order) Three points define a quadratic curve (2 nd order) Four points define a cubic curve (3 rd order) k+1 points define a k-order curve Let s start with a line 21

First Order Curve Based on linear interpolation (LERP) Weighted average between two values Value could be a number, vector, color, Interpolate between points p 0 and p 1 with parameter t Defines a curve that is straight (first-order spline) t=0 corresponds to p 0 t=1 corresponds to p 1 t=0.5 corresponds to midpoint 22 p 0. 0<t<1 t=0. p 1 t=1 x(t) = Lerp( t, p 0, p 1 )= ( 1 t)p 0 + t p 1

Linear Interpolation Three equivalent ways to write it Expose different properties 1. Regroup for points p 2. Regroup for t 3. Matrix form 23

Weighted Average x(t) = (1 t)p 0 + (t)p 1 = B 0 (t) p 0 + B 1 (t)p 1, where B 0 (t) = 1 t and B 1 (t) = t Weights are a function of t Sum is always 1, for any value of t Also known as blending functions 24

Linear Polynomial x(t) = (p p 0 ) 14 2 34 t + p 123 0 vector point Curve is based at point p 0 Add the vector, scaled by t p 0..5(p 1 -p 0 ). p 1 -p 0. 25

Matrix Form Geometry matrix Geometric basis Polynomial basis In components 26

Tangent For a straight line, the tangent is constant Weighted average Polynomial Matrix form 27

Lecture Overview Polynomial Curves Introduction Polynomial functions Bézier Curves Introduction Drawing Bézier curves Piecewise Bézier curves 28

Bézier Curves Are a higher order extension of linear interpolation p 1 p 1 p 1 p 2 p 1 p 3 p 0 p 0 p 0 p 2 Linear Quadratic Cubic 29

Bézier Curves Give intuitive control over curve with control points Endpoints are interpolated, intermediate points are approximated Convex Hull property Variation-Diminishing property Many demo applets online, for example: Demo: http://www.cs.princeton.edu/~min/cs426/jar/bezier.html http://www.theparticle.com/applets/nyu/bezierapplet/ http://www.sunsite.ubc.ca/livingmathematics/v001n01/ubcexamples/b ezier/bezier.html 30

Cubic Bézier Curve Most commonly used case Defined by four control points: Two interpolated endpoints (points are on the curve) Two points control the tangents at the endpoints Points x on curve defined as function of parameter t p 0 x(t) p 1 p 2 31 p 3

Algorithmic Construction Algorithmic construction De Casteljau algorithm, developed at Citroen in 1959, named after its inventor Paul de Casteljau (pronounced Cast-all- Joe ) Developed independently from Bézier s work: Bézier created the formulation using blending functions, Casteljau devised the recursive interpolation algorithm 32

De Casteljau Algorithm A recursive series of linear interpolations Works for any order Bezier function, not only cubic Not very efficient to evaluate Other forms more commonly used But: Gives intuition about the geometry Useful for subdivision 33

De Casteljau Algorithm Given: Four control points A value of t (here t 0.25) p 1 p 0 p 2 p 3 34

De Casteljau Algorithm p 1 q 1 q 0 (t) = Lerp( t,p 0,p ) 1 p 0 q 0 ( ) q 1 (t) = Lerp t,p 1,p 2 p 2 q 2 (t) = Lerp( t,p 2,p ) 3 q 2 p 3 35

De Casteljau Algorithm q 1 q r 0 0 r 1 ( ) r 0 (t) = Lerp t,q 0 (t),q 1 (t) r 1 (t) = Lerp( t,q 1 (t),q 2 (t)) q 2 36

De Casteljau Algorithm r 0 x r 1 x(t) = Lerp( t,r 0 (t),r 1 (t)) 37

De Casteljau Algorithm p 1 p 0 x p 2 Applets Demo: http://www2.mat.dtu.dk/people/j.gravesen/cagd/decast.html http://www.caffeineowl.com/graphics/2d/vectorial/bezierintro.html 38 p 3

Recursive Linear Interpolation x = Lerp t,r 0,r 1 ( ) r = Lerp ( t,q,q ) 0 0 1 ( ) r 1 = Lerp t,q 1,q 2 q 0 = Lerp( t,p 0,p ) 1 q 1 = Lerp( t,p 1,p ) 2 q 2 = Lerp( t,p 2,p ) 3 p 0 p 1 p 2 p 3 p 1 q 0 r 0 p 2 x q 1 r 1 p 3 q 2 p 4 39

Expand the LERPs q 0 (t) = Lerp( t,p 0,p 1 )= ( 1 t)p 0 + tp 1 q 1 (t) = Lerp( t,p 1,p 2 )= ( 1 t)p 1 + tp 2 q 2 (t) = Lerp( t,p 2,p 3 )= ( 1 t)p 2 + tp 3 r 0 (t) = Lerp ( t,q 0 (t),q 1 (t) )= 1 t r 1 (t) = Lerp( t,q 1 (t),q 2 (t))= 1 t ( ) ( )p 0 + tp 1 )+ t ( 1 t )p 1 + tp 2 ( )p 1 + tp 2 )+ t ( 1 t)p 2 + tp 3 ( ) 1 t ( ) 1 t x(t) = Lerp t,r 0 (t),r 1 (t) = ( 1 t) ( 1 t) ( 1 t)p 0 + tp 1 )+ t ( 1 t)p 1 + tp 2 +t ( 1 t) ( 1 t)p 1 + tp 2 )+ t ( 1 t)p 2 + tp 3 40 ( ) ( ) ( ) ( ) ( ) ( )

Weighted Average of Control Points Regroup for p: x(t) = 1 t ( )p 0 + tp 1 )+ t ( 1 t)p 1 + tp 2 ( )p 1 + tp 2 )+ t( 1 t)p 2 + tp 3 ) ( ) ( 1 t) 1 t +t 1 t ( ) ( ) ( ) 1 t ( ) x(t) = 1 t ( ) 3 p ( ) 2 3 0 + 3( 1 t) 2 tp 1 + 3 1 t ( )t 2 p 2 + t 3 p 3 B 0 (t ) B 6444 74448 1 (t ) 644 7448 x(t) = t 3 + 3t 2 3t + 1 p 0 + 3t 3 6t 2 + 3t ( ) ( ) + 3t 3 + 3t 2 142 43 p + t 3 2 { p 3 B 2 (t ) ( ) B 3 (t ) ( ) p 1 41

Cubic Bernstein Polynomials x(t) = B 0 ( t)p 0 + B 1 ( t)p 1 + B 2 ( t)p 2 + B 3 ( t)p 3 The cubic Bernstein polynomials : B 0 ( t)= t 3 + 3t 2 3t + 1 B 1 ( t)= 3t 3 6t 2 + 3t B 2 ( t)= 3t 3 + 3t 2 ( t)= t 3 B 3 B i (t) = 1 Weights B i (t) add up to 1 for any value of t 42

General Bernstein Polynomials B 1 0 B 1 1 ( t)= t + 1 B 2 0 ( t)= t 2 2t + 1 B 3 0 ( t)= t 3 + 3t 2 3t + 1 ( t)= t B 2 1 ( t)= 2t 2 + 2t B 3 1 ( t)= 3t 3 6t 2 + 3t B 2 2 ( t)= t 2 B 3 2 ( t)= 3t 3 + 3t 2 B 3 3 ( t)= t 3 43 B i n ( t)= n i ( 1 t)n i t B n i ( t) = 1 n ( ) i i = n! i! ( n i)! n! = factorial of n (n+1)! = n! x (n+1)

General Bézier Curves nth-order Bernstein polynomials form nth-order Bézier curves B i n ( t)= n ( 1 t)n i t i n i=0 x( t)= B n i ( t)p i ( ) i 44

Bézier Curve Properties Overview: Convex Hull property Variation Diminishing property Affine Invariance 45

Definitions Convex hull of a set of points: Polyhedral volume created such that all lines connecting any two points lie completely inside it (or on its boundary) Convex combination of a set of points: Weighted average of the points, where all weights between 0 and 1, sum up to 1 Any convex combination of a set of points lies within the convex hull 46

Convex Hull Property A Bézier curve is a convex combination of the control points (by definition, see Bernstein polynomials) A Bézier curve is always inside the convex hull Makes curve predictable Allows culling, intersection testing, adaptive tessellation Demo: http://www.cs.princeton.edu/~min/cs426/jar/bezier.html p 1 p 3 p 0 p 2 47

Variation Diminishing Property If the curve is in a plane, this means no straight line intersects a Bézier curve more times than it intersects the curve's control polyline Curve is not more wiggly than control polyline 48

Affine Invariance Transforming Bézier curves Two ways to transform: Transform the control points, then compute resulting spline points Compute spline points, then transform them Either way, we get the same points Curve is defined via affine combination of points Invariant under affine transformations (i.e., translation, scale, rotation, shear) Convex hull property remains true 49

Cubic Polynomial Form Start with Bernstein form: x(t) = ( t 3 + 3t 2 3t + 1)p 0 + ( 3t 3 6t 2 + 3t)p 1 + ( 3t 3 + 3t 2 )p 2 + ( t 3 )p 3 Regroup into coefficients of t : x(t) = ( p 0 + 3p 1 3p 2 + p 3 )t 3 + ( 3p 0 6p 1 + 3p 2 )t 2 + ( 3p 0 + 3p 1 )t + ( p 0 )1 x(t) = at 3 + bt 2 + ct + d ( ) ( ) ( ) ( ) a = p 0 + 3p 1 3p 2 + p 3 b = 3p 0 6p 1 + 3p 2 c = 3p 0 + 3p 1 d = p 0 Good for fast evaluation Precompute constant coefficients (a,b,c,d) Not much geometric intuition 50

Cubic Matrix Form x(t) = a r t 3 r b c r t 2 d t 1 r a = p 0 + 3p 1 3p 2 + p 3 r b = ( 3p 0 6p 1 + 3p 2 ) r c = ( 3p 0 + 3p 1 ) d = p 0 ( ) ( ) 1 3 3 1 t 3 3 6 3 0 x(t) = [ p 0 p 1 p 2 p 3 ] t 2 3 3 0 0 t 0 0 0 1444 24443 1 444 24443 1 { T G Bez B Bez Other types of cubic splines use different basis matrices B Bez 51

Cubic Matrix Form In 3D: 3 equations for x, y and z: 52 [ ] x x (t) = p 0 x p 1x p 2 x p 3x x y (t) = p 0 y p 1y p 2 y p 3y x z (t) = p 0z p 1z p 2z p 3z 1 3 3 1 t 3 3 6 3 0 t 2 3 3 0 0 t 1 0 0 0 1 1 3 3 1 t 3 3 6 3 0 t 2 3 3 0 0 t 1 0 0 0 1 1 3 3 1 t 3 3 6 3 0 t 2 3 3 0 0 t 1 0 0 0 1

Matrix Form Bundle into a single matrix x(t) = 1 3 3 1 t 3 p 0 x p 1x p 2 x p 3x 3 6 3 0 p 0 y p 1y p 2 y p 3y t 2 3 3 0 0 t p 0z p 1z p 2z p 3z 1 0 0 0 1 x(t) = G Bez B Bez T x(t) = C T Efficient evaluation Pre-compute C Take advantage of existing 4x4 matrix hardware support 53