Computergrafik. Matthias Zwicker Universität Bern Herbst 2016

Similar documents
CMSC427 Parametric curves: Hermite, Catmull-Rom, Bezier

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

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

Interpolation and polynomial approximation Interpolation

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

Bézier Curves and Splines

Lecture 20: Bezier Curves & Splines

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

Lecture 23: Hermite and Bezier Curves

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

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.

The Essentials of CAGD

Bernstein polynomials of degree N are defined by

Approximation of Circular Arcs by Parametric Polynomials

Computer Graphics Keyframing and Interpola8on

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

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

On-Line Geometric Modeling Notes

Reading. w Foley, Section 11.2 Optional

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

Curves, Surfaces and Segments, Patches

Animation Curves and Splines 1

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

Cubic Splines; Bézier Curves

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

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

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

MA 323 Geometric Modelling Course Notes: Day 07 Parabolic Arcs

The degree of the polynomial function is n. We call the term the leading term, and is called the leading coefficient. 0 =

Spiral spline interpolation to a planar spiral

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

Interpolation and polynomial approximation Interpolation

Curve Fitting: Fertilizer, Fonts, and Ferraris

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

Visualizing Bezier s curves: some applications of Dynamic System Geogebra

Subdivision Matrices and Iterated Function Systems for Parametric Interval Bezier Curves

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

Computer Aided Design. B-Splines

Polynomial approximation and Splines

Geometric Lagrange Interpolation by Planar Cubic Pythagorean-hodograph Curves

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

G-code and PH curves in CNC Manufacturing

CONTROL POLYGONS FOR CUBIC CURVES

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

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

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

Curvature variation minimizing cubic Hermite interpolants

AFFINE COMBINATIONS, BARYCENTRIC COORDINATES, AND CONVEX COMBINATIONS

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

Math 1310 Section 4.1: Polynomial Functions and Their Graphs. A polynomial function is a function of the form ...

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

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

Scientific Computing: An Introductory Survey

Hermite Interpolation with Euclidean Pythagorean Hodograph Curves

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

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

CMSC427 Geometry and Vectors

Pythagorean-hodograph curves

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

Engineering 7: Introduction to computer programming for scientists and engineers

Katholieke Universiteit Leuven Department of Computer Science

13 Path Planning Cubic Path P 2 P 1. θ 2

Moving Along a Curve with Specified Speed

Jakarta International School 8 th Grade AG1

2 The De Casteljau algorithm revisited

V. Graph Sketching and Max-Min Problems

MTH301 Calculus II Glossary For Final Term Exam Preparation

An Intuitive Introduction to Motivic Homotopy Theory Vladimir Voevodsky

It s Your Turn Problems I. Functions, Graphs, and Limits 1. Here s the graph of the function f on the interval [ 4,4]

Midterm 1 Review. Distance = (x 1 x 0 ) 2 + (y 1 y 0 ) 2.

APPROXIMATION OF ROOTS OF EQUATIONS WITH A HAND-HELD CALCULATOR. Jay Villanueva Florida Memorial University Miami, FL

SPLINE INTERPOLATION

Homework 5: Sampling and Geometry

Finite element function approximation

1 Roots of polynomials

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

Curves - Foundation of Free-form Surfaces

5.2 LENGTHS OF CURVES & AREAS OF SURFACES OF REVOLUTION

Chapter 2 Polynomial and Rational Functions

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

INTERPOLATION. and y i = cos x i, i = 0, 1, 2 This gives us the three points. Now find a quadratic polynomial. p(x) = a 0 + a 1 x + a 2 x 2.

Curve Fitting. 1 Interpolation. 2 Composite Fitting. 1.1 Fitting f(x) 1.2 Hermite interpolation. 2.1 Parabolic and Cubic Splines

Applied Math 205. Full office hour schedule:

Volume vs. Diameter. Teacher Lab Discussion. Overview. Picture, Data Table, and Graph

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

Q(s, t) = S M = S M [ G 1 (t) G 2 (t) G 3 1(t) G 4 (t) ] T

VARIATIONAL INTERPOLATION OF SUBSETS

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

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

Calculus I Practice Test Problems for Chapter 2 Page 1 of 7

CS 536 Computer Graphics NURBS Drawing Week 4, Lecture 6

Graphs of Polynomials: Polynomial functions of degree 2 or higher are smooth and continuous. (No sharp corners or breaks).

Iterative Methods for Solving A x = b

Summary of Derivative Tests

Numerical method for approximating the solution of an IVP. Euler Algorithm (the simplest approximation method)

Introduction. Chapter Points, Vectors and Coordinate Systems

Interpolation. 1. Judd, K. Numerical Methods in Economics, Cambridge: MIT Press. Chapter

Quick Review for BC Calculus

Transcription:

Computergrafik Matthias Zwicker Universität Bern Herbst 2016

2 Today Curves Introduction Polynomial curves Bézier curves Drawing Bézier curves Piecewise curves

Modeling Creating 3D objects How to construct complicated surfaces? Goal Specify objects with few control points Resulting object should be visually pleasing (smooth) Start with curves, then generalize to surfaces 3

4 Usefulness of curves Surface of revolution

5 Usefulness of curves Extruded/swept surfaces

Usefulness of curves Animation Provide a track for objects Use as camera path 6

Usefulness of curves Generalize to surface patches using grids of curves, next class 7

8 How to represent curves Specify every point along curve? Hard to get precise, smooth results Too much data, too hard to work with Idea: specify curves using small numbers of control points Mathematics: use polynomials to represent curves Control point

9 Interpolating polynomial curves http://en.wikipedia.org/wiki/polynomial_interpolation Curve goes through all control points Seems most intuitive Surprisingly, not usually the best choice Hard to predict behavior Overshoots, wiggles Hard to get nice-looking curves Control point Interpolating curve

Approximating polynomial curves Curve is influenced by control points Control point Various types & techniques based on polynomial functions Bézier curves, B-splines, NURBS Focus on Bézier curves 10

11 Mathematical definition A vector valued function of one variable x(t) Given t, compute a 3D point x=(x,y,z) May interpret as three functions x(t), y(t), z(t) Moving a point along the curve x(t) z y x(0.0) x(0.5) x(1.0) x

Tangent vector Derivative A vector that points in the direction of movement Length of x (t) corresponds to speed x(t) z y x (0.0) x (0.5) x (1.0) x 12

13 Today Curves Introduction Polynomial curves Bézier curves Drawing Bézier curves Piecewise curves

14 Polynomial functions Linear: (1 st order) Quadratic: (2 nd order) Cubic: (3 rd order)

15 Polynomial curves Linear Evaluated as a + b b

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

Control points Polynomial coefficients a, b, c, d etc. can be interpreted as 3D control points Remember a, b, c, d have x,y,z components each Unfortunately, polynomial coefficients don t intuitively describe shape of curve Main objective of curve representation is to come up with intuitive control points Position of control points predicts shape of curve 17

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 18

First order curve Based on linear interpolation (LERP) http://en.wikipedia.org/wiki/linear_interpolation 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 curve) t=0 corresponds to p 0 t=1 corresponds to p 1 t=0.5 corresponds to midpoint p 0. 0<t<1 t=0. p 1 t=1 x(t) Lerpt, p 0, p 1 1 tp 0 t p 1 19

20 Linear interpolation Three different ways to write it Equivalent, but different properties become apparent Advantages for different operations, see later 1. Weighted sum of control points 2. Polynomial in t t 0 3. Matrix form

Weighted sum of control points 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 B 0 (t), B 1 (t) are functions of t Sum is always 1, for any value of t Also known as basis or blending functions 21

22 Linear polynomial x(t) (p 1 p 0 ) vector t p 0 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

23 Matrix form Geometry matrix Geometric basis Polynomial basis In components

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

25 Lissajou curves http://en.wikipedia.org/wiki/lissajous_curve

26 Today Curves Introduction Polynomial curves Bézier curves Drawing Bézier curves Piecewise curves

Bézier curves http://en.wikipedia.org/wiki/b%c3%a9zier_curve A particularly intuitive way to define control points for polynomial curves Developed for CAD (computer aided design) and manufacturing Before games, before movies, CAD was the big application for CG Pierre Bézier (1962), design of auto bodies for Peugeot, http://en.wikipedia.org/wiki/pierre_b%c3%a9zier Paul de Casteljau (1959), for Citroen 27

28 Bézier curves Higher order extension of linear interpolation Control points p 0, p 1,... p 1 p 1 p 2 p 1 p 3 p 0 p 0 p 0 p 2 Linear Quadratic Cubic

Bézier curves Intuitive control over curve given control points Endpoints are interpolated, intermediate points are approximated Convex Hull property Variation-diminishing property Many demo applets online http://ibiblio.org/e-notes/splines/intro.htm http://www.gris.unituebingen.de/edu/projects/grdev/doc/html/overview.html http://www.theparticle.com/applets/nyu/bezierapplet/ http://www.sunsite.ubc.ca/livingmathematics/v001n01/ubcexamples/ Bezier/bezier.html 29

Cubic Bézier curve Cubic polynomials, most common case Defined by 4 control points Two interpolated endpoints Two midpoints control the tangent at the endpoints p 1 x(t) p 0 p 2 Control polyline p 3 30

31 Bézier Curve formulation Three alternatives, analogous to linear case 1. Weighted average of control points 2. Cubic polynomial function of t 3. Matrix form Algorithmic construction de Casteljau algorithm

de Casteljau Algorithm http://en.wikipedia.org/wiki/de_casteljau's_algorithm A recursive series of linear interpolations Works for any order, not only cubic Not terribly efficient to evaluate Other forms more commonly used Why study it? Intuition about the geometry Useful for subdivision (later today) 32

33 de Casteljau Algorithm Given the control points A value of t Here t 0.25 p 0 p 1 p 2 p 3

34 de Casteljau Algorithm p 1 q 1 q 0 (t) Lerpt,p 0,p 1 q 1 (t) Lerpt,p 1,p 2 q 2 (t) Lerpt,p 2,p 3 p 0 q 0 q 2 p 2 p 3

35 de Casteljau Algorithm q 0 r 0 q 1 r 0 (t) Lerpt,q 0 (t),q 1 (t) r 1 (t) Lerpt,q 1 (t),q 2 (t) r 1 q 2

36 de Casteljau Algorithm r 0 x r 1 x(t) Lerpt,r 0 (t),r 1 (t)

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

38 de Casteljau Algorithm http://en.wikipedia.org/wiki/de_casteljau's_algorithm Linear Quadratic Cubic Quartic

39 Recursive linear interpolation x Lerp t,r 0,r 1 r Lerp t,q,q 0 0 1 r 1 Lerpt,q 1,q 2 q 0 Lerpt,p 0,p 1 q 1 Lerpt,p 1,p 2 q 2 Lerpt,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

40 Recursive linear interpolation x Lerp t,r 0,r 1 r Lerp t,q,q 0 0 1 r 1 Lerpt,q 1,q 2 q 0 Lerpt,p 0,p 1 q 1 Lerpt,p 1,p 2 q 2 Lerpt,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

41 Recursive linear interpolation x Lerp t,r 0,r 1 r Lerp t,q,q 0 0 1 r 1 Lerpt,q 1,q 2 q 0 Lerpt,p 0,p 1 q 1 Lerpt,p 1,p 2 q 2 Lerpt,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

42 Recursive linear interpolation x Lerp t,r 0,r 1 r Lerp t,q,q 0 0 1 r 1 Lerpt,q 1,q 2 q 0 Lerpt,p 0,p 1 q 1 Lerpt,p 1,p 2 q 2 Lerpt,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

43 Expand the LERPs q 0 (t) Lerp t,p 0,p 1 1 tp 0 tp 1 q 1 (t) Lerpt,p 1,p 2 1 tp 1 tp 2 q 2 (t) Lerpt,p 2,p 3 1 tp 2 tp 3 r 0 (t) Lerpt,q 0 (t),q 1 (t) 1 t 1 tp 0 tp 1 t 1 tp 1 tp 2 r 1 (t) Lerpt,q 1 (t),q 2 (t) 1 t 1 tp 1 tp 2 t 1 tp 2 tp 3 x(t) Lerp t,r 0 (t),r 1 (t) 1 t 1 t 1 tp 0 tp 1 t 1 tp 1 tp 2 t 1 t 1 tp 1 tp 2 t 1 tp 2 tp 3

44 Expand the LERPs q 0 (t) Lerp t,p 0,p 1 1 tp 0 tp 1 q 1 (t) Lerpt,p 1,p 2 1 tp 1 tp 2 q 2 (t) Lerpt,p 2,p 3 1 tp 2 tp 3 r 0 (t) Lerpt,q 0 (t),q 1 (t) 1 t 1 tp 0 tp 1 t 1 tp 1 tp 2 r 1 (t) Lerpt,q 1 (t),q 2 (t) 1 t 1 tp 1 tp 2 t 1 tp 2 tp 3 x(t) Lerp t,r 0 (t),r 1 (t) 1 t 1 t 1 tp 0 tp 1 t 1 tp 1 tp 2 t 1 t 1 tp 1 tp 2 t 1 tp 2 tp 3

45 Expand the LERPs q 0 (t) Lerp t,p 0,p 1 1 tp 0 tp 1 q 1 (t) Lerpt,p 1,p 2 1 tp 1 tp 2 q 2 (t) Lerpt,p 2,p 3 1 tp 2 tp 3 r 0 (t) Lerpt,q 0 (t),q 1 (t) 1 t 1 tp 0 tp 1 t 1 tp 1 tp 2 r 1 (t) Lerpt,q 1 (t),q 2 (t) 1 t 1 tp 1 tp 2 t 1 tp 2 tp 3 x(t) Lerp t,r 0 (t),r 1 (t) 1 t 1 t 1 tp 0 tp 1 t 1 tp 1 tp 2 t 1 t 1 tp 1 tp 2 t 1 tp 2 tp 3

46 Expand the LERPs q 0 (t) Lerp t,p 0,p 1 1 tp 0 tp 1 q 1 (t) Lerpt,p 1,p 2 1 tp 1 tp 2 q 2 (t) Lerpt,p 2,p 3 1 tp 2 tp 3 r 0 (t) Lerpt,q 0 (t),q 1 (t) 1 t 1 tp 0 tp 1 t 1 tp 1 tp 2 r 1 (t) Lerpt,q 1 (t),q 2 (t) 1 t 1 tp 1 tp 2 t 1 tp 2 tp 3 x(t) Lerp t,r 0 (t),r 1 (t) 1 t 1 t 1 tp 0 tp 1 t 1 tp 1 tp 2 t 1 t 1 tp 1 tp 2 t 1 tp 2 tp 3

47 Expand the LERPs q 0 (t) Lerp t,p 0,p 1 1 tp 0 tp 1 q 1 (t) Lerpt,p 1,p 2 1 tp 1 tp 2 q 2 (t) Lerpt,p 2,p 3 1 tp 2 tp 3 r 0 (t) Lerpt,q 0 (t),q 1 (t) 1 t 1 tp 0 tp 1 t 1 tp 1 tp 2 r 1 (t) Lerpt,q 1 (t),q 2 (t) 1 t 1 tp 1 tp 2 t 1 tp 2 tp 3 x(t) Lerp t,r 0 (t),r 1 (t) 1 t 1 t 1 tp 0 tp 1 t 1 tp 1 tp 2 t 1 t 1 tp 1 tp 2 t 1 tp 2 tp 3

48 Weighted average of control points Regroup x(t) 1 t 1 t t 1 t x(t) 1 t 1 tp 0 tp 1 t 1 tp 1 tp 2 t 1 tp 2 tp 3 1 tp 1 tp 2 3 p 0 31 t 2 tp 1 31 tt 2 p 2 t 3 p 3 B 0 (t ) x(t) t 3 3t 2 3t 1 3t 3 3t 2 B 2 (t ) p 2 t 3 B 1 (t ) p 0 3t 3 6t 2 3t B 3 (t ) p 3 p 1

49 Weighted average of control points Regroup x(t) 1 t 1 t t 1 t x(t) 1 t 1 tp 0 tp 1 t 1 tp 1 tp 2 t 1 tp 2 tp 3 1 tp 1 tp 2 3 p 0 31 t 2 tp 1 31 tt 2 p 2 t 3 p 3 B 0 (t ) x(t) t 3 3t 2 3t 1 3t 3 3t 2 B 2 (t ) p 2 t 3 B 1 (t ) p 0 3t 3 6t 2 3t B 3 (t ) p 3 p 1

50 Weighted average of control points Regroup x(t) 1 t 1 t t 1 t x(t) 1 t 1 tp 0 tp 1 t 1 tp 1 tp 2 t 1 tp 2 tp 3 1 tp 1 tp 2 3 p 0 31 t 2 tp 1 31 tt 2 p 2 t 3 p 3 B 0 (t ) x(t) t 3 3t 2 3t 1 3t 3 3t 2 B 2 (t ) p 2 t 3 B 1 (t ) p 0 3t 3 6t 2 3t B 3 (t ) p 3 p 1 Bernstein polynomials

51 Cubic Bernstein polynomials http://en.wikipedia.org/wiki/bernstein_polynomial 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 Partition of unity, at each t always add to 1 Endpoint interpolation, B 0 and B 3 go to 1

52 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 B i n t n i 1 t ni t i B n i t 1 n i n! i! n i!

53 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 B i n t n i 1 t ni t i B n i t 1 n i n! i! n i!

54 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 B i n t n i 1 t ni t i B n i t 1 n i n! i! n i!

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 Order n: B i n t n i 1 t ni t i B n i t 1 n i n! i! n i! Partition of unity, endpoint interpolation 55

56 General Bézier curves nth-order Bernstein polynomials form nth-order Bézier curves Bézier curves are weighted sum of control points using nth-order Bernstein polynomials Bernstein polynomials of order n: Bézier curve of order n: B i n t n i 1 tni t n i0 xt B n i t p i i

57 Bézier curve properties Convex hull property Variation diminishing property Affine invariance

58 Convex hull, convex combination Convex hull of a set of points Smallest polyhedral volume such that (i) all points are in it (ii) line connecting any two points in the volume lies completely inside it (or on its boundary) Convex combination of the points Weighted average of the points, where weights all between 0 and 1, sum up to 1 Any convex combination always lies within the convex hull p 1 p 3 Convex hull p 0 p 2

59 Convex hull property Bézier curve is a convex combination of the control points Bernstein polynomials add to 1 at each value of t Curve is always inside the convex hull of control points Makes curve predictable Allows efficient culling, intersection testing, adaptive tessellation p 1 p 3 p 0 p 2

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 Yellow line: 7 intersections with control polyline 3 intersections with curve 60

Affine invariance Two ways to transform Bézier curves 1. Transform the control points, then compute resulting point on curve 2. Compute point on curve, then transform it Either way, get the same transform point! Curve is defined via affine combination of points (convex combination is special case of an affine combination) Invariant under affine transformations Convex hull property always remains 61

62 Cubic polynomial form Start with Bernstein form: x(t) t 3 3t 2 3t 1p 0 3t 3 6t 2 3tp 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

63 Cubic polynomial form Start with Bernstein form: x(t) t 3 3t 2 3t 1p 0 3t 3 6t 2 3tp 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

64 Cubic polynomial form Start with Bernstein form: x(t) t 3 3t 2 3t 1p 0 3t 3 6t 2 3tp 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

65 Cubic polynomial form Start with Bernstein form: x(t) t 3 3t 2 3t 1p 0 3t 3 6t 2 3tp 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

66 Cubic matrix form x(t) a b c d t 3 t 2 t 1 a p 0 3p 1 3p 2 p 3 b 3p 0 6p 1 3p 2 c 3p 0 3p 1 d p 0 x(t) p 0 p 1 p 2 p 3 G Bez Can construct other cubic curves by just using different basis matrix B Hermite, Catmull-Rom, B-Spline, 1 3 3 1 t 3 3 6 3 0 t 2 3 3 0 0 t 1 0 0 0 1 T B Bez

67 Cubic matrix form 3 parallel equations, in x, y and z: 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 Precompute C Take advantage of existing 4x4 matrix hardware support 68

69 Today Curves Introduction Polynomial curves Bézier curves Drawing Bézier curves Piecewise curves

70 Drawing Bézier curves Generally no low-level support for drawing smooth curves I.e., GPU draws only straight line segments Need to break curves into line segments or individual pixels Approximating curves as series of line segments called tessellation Tessellation algorithms Uniform sampling Adaptive sampling Recursive subdivision

Uniform sampling Approximate curve with N-1 straight segments N chosen in advance Evaluate x i x t i where t i i N for i 0, 1,, N x i a i 3 N b i2 3 N c i 2 N d Connect the points with lines Too few points? x(t) x 2 x 3 x 4 Bad approximation Curve is faceted Too many points? x 1 x 0 Slow to draw too many line segments Segments may draw on top of each other 71

72 Adaptive Sampling Use only as many line segments as you need Fewer segments where curve is mostly flat More segments where curve bends Segments never smaller than a pixel Various schemes for sampling, checking results, deciding whether to sample more x(t)

73 Recursive Subdivision Any cubic (or k-th order) curve segment can be expressed as a cubic (or k-th order) Bézier curve Any piece of a cubic (or k-th order) curve is itself a cubic (or k-th order) curve Therefore, any Bézier curve can be subdivided into smaller Bézier curves

de Casteljau subdivision p 1 p 0 q r 0 0 r x 1 p 2 q 2 de Casteljau construction points are the control points of two Bézier sub-segments (p 0,q 0,r 0,x) and (x,r 1,q 2,p 3 ) p 3 74

Adaptive subdivision algorithm 1. Use de Casteljau construction to split Bézier segment in middle (t=0.5) 2. For each half If flat enough : draw line segment Else: recurse from 1. for each half Curve is flat enough if hull is flat enough Test how far away midpoints are from straight segment connecting start and end If about a pixel, then hull is flat enough 75

76 Today Curves Introduction Polynomial curves Bézier curves Drawing Bézier curves Piecewise curves

77 More control points Cubic Bézier curve limited to 4 control points Cubic curve can only have one inflection Need more control points for more complex curves k-1 order Bézier curve with k control points Hard to control and hard to work with Intermediate points don t have obvious effect on shape Changing any control point changes the whole curve Want local support Each control point only influences nearby portion of curve

78 Piecewise curves (splines) Sequence of simple (low-order) curves, end-to-end Piecewise polynomial curve, or splines http://en.wikipedia.org/wiki/spline_(mathematics) Sequence of line segments Piecewise linear curve (linear or first-order spline) Sequence of cubic curve segments Piecewise cubic curve, here piecewise Bézier (cubic spline)

79 Piecewise cubic Bézier curve Given 3N 1 points p 0,p 1, Define N Bézier segments:,p 3N x 0 (t) B 0 (t)p 0 B 1 (t)p 1 B 2 (t)p 2 B 3 (t)p 3 x 1 (t) B 0 (t)p 3 B 1 (t)p 4 B 2 (t)p 5 B 3 (t)p 6 x N 1 (t) B 0 (t)p 3N 3 B 1 (t)p 3N 2 B 2 (t)p 3N 1 B 3 (t)p 3N p 0 p p 2 1 x 0 (t) p 3 x 1 (t) 7 p 8 p x 2 (t) 6p p 9 x 3 (t) p p 12 10 p 11 p 4 p 5

80 Piecewise cubic Bézier curve Global parameter u, 0<=u<=3N x(u) x 0 ( 1 u), 0 u 3 3 x 1 ( 1 u 1), 3 u 6 3 x N 1 ( 1 3 u (N 1)), 3N 3 u 3N 1 x(u) x i u i 3, where i 1 u 3 x(8.75) x 0 (t) x 1 (t) x 2 (t) x 3 (t) u=0 x(3.5) u=12

81 Continuity Want smooth curves C 0 continuity No gaps Segments match at the endpoints C 1 continuity: first derivative is well defined No corners Tangents/normals are C 0 continuous (no jumps) C 2 continuity: second derivative is well defined Tangents/normals are C 1 continuous Important for high quality reflections on surfaces

82 Piecewise cubic Bézier curve C 0 continuous by construction C 1 continuous at segment endpoints p 3i if p 3i - p 3i-1 = p 3i+1 - p 3i C 2 is harder to get p 4 p 2 p 1 p 2 P 3 p p 1 P 6 p 3 6 p 4 p 5 p 0 p 0 C 0 continuous p 5 C 1 continuous

83 Piecewise cubic Bézier curves Used often in 2D drawing programs Inconveniences Must have 4 or 7 or 10 or 13 or (1 plus a multiple of 3) control points Some points interpolate (endpoints), others approximate (handles) Need to impose constraints on control points to obtain C 1 continuity C 2 continuity more difficult Solutions User interface using Bézier handles Generalization to B-splines, next time

Bézier handles Segment end points (interpolating) presented as curve control points Midpoints (approximating points) presented as handles Can have option to enforce C 1 continuity [www.blender.org] Adobe Illustrator 84

85 Next time B-splines and NURBS Extending curves to surfaces