Fall CSCI 420: Computer Graphics. 4.2 Splines. Hao Li.

Similar documents
Splines. Parameterization of a Curve. Curve Representations. Roller coaster. What Do We Need From Curves in Computer Graphics? Modeling Complex Shapes

3D Modeling Parametric Curves & Surfaces

Parametric Curves. University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell

Parametric Curves. University of Texas at Austin CS384G - Computer Graphics

3D Modeling Parametric Curves & Surfaces. Shandong University Spring 2013

Design considerations

Parametric curves. Brian Curless CSE 457 Spring 2016

Information Coding / Computer Graphics, ISY, LiTH. Splines

Until now we have worked with flat entities such as lines and flat polygons. Fit well with graphics hardware Mathematically simple

Curves and Surfaces Computer Graphics I Lecture 9

Curves and Surfaces 1

Know it. Control points. B Spline surfaces. Implicit surfaces

Bezier Curves, B-Splines, NURBS

Computer Graphics Curves and Surfaces. Matthias Teschner

08 - Designing Approximating Curves

Spline Notes. Marc Olano University of Maryland, Baltimore County. February 20, 2004

Lecture IV Bézier Curves

Curves. Computer Graphics CSE 167 Lecture 11

CS130 : Computer Graphics Curves (cont.) Tamar Shinar Computer Science & Engineering UC Riverside

Computer Graphics. Curves and Surfaces. Hermite/Bezier Curves, (B-)Splines, and NURBS. By Ulf Assarsson

Intro to Modeling Modeling in 3D

Curves and Surfaces Computer Graphics I Lecture 10

Intro to Curves Week 4, Lecture 7

B-spline Curves. Smoother than other curve forms

2D Spline Curves. CS 4620 Lecture 13

Parametric curves. Reading. Curves before computers. Mathematical curve representation. CSE 457 Winter Required:

Geometric Modeling of Curves

CSE 167: Introduction to Computer Graphics Lecture #11: Bezier Curves. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2016

Need for Parametric Equations

Representing Curves Part II. Foley & Van Dam, Chapter 11

Central issues in modelling

Introduction to Computer Graphics

Intro to Curves Week 1, Lecture 2

An introduction to interpolation and splines

2D Spline Curves. CS 4620 Lecture 18

Computergrafik. Matthias Zwicker Universität Bern Herbst 2016

CS130 : Computer Graphics Curves. Tamar Shinar Computer Science & Engineering UC Riverside

CS 536 Computer Graphics Intro to Curves Week 1, Lecture 2

CSE 167: Introduction to Computer Graphics Lecture #13: Curves. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2017

A Curve Tutorial for Introductory Computer Graphics

CS-184: Computer Graphics

Sung-Eui Yoon ( 윤성의 )

Computergrafik. Matthias Zwicker. Herbst 2010

The Free-form Surface Modelling System

The goal is the definition of points with numbers and primitives with equations or functions. The definition of points with numbers requires a

OUTLINE. Quadratic Bezier Curves Cubic Bezier Curves

Curves D.A. Forsyth, with slides from John Hart

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

CS-184: Computer Graphics. Today

Curves and Surface I. Angel Ch.10

Properties of Blending Functions

LECTURE #6. Geometric Modelling for Engineering Applications. Geometric modeling for engineering applications

Interpolating/approximating pp gcurves

Interactive Graphics. Lecture 9: Introduction to Spline Curves. Interactive Graphics Lecture 9: Slide 1

Computer Graphics Splines and Curves

Curve and Surface Basics

Curves and Curved Surfaces. Adapted by FFL from CSE167: Computer Graphics Instructor: Ronen Barzel UCSD, Winter 2006

(Refer Slide Time: 00:02:24 min)

GL9: Engineering Communications. GL9: CAD techniques. Curves Surfaces Solids Techniques

Bézier Splines. B-Splines. B-Splines. CS 475 / CS 675 Computer Graphics. Lecture 14 : Modelling Curves 3 B-Splines. n i t i 1 t n i. J n,i.

(Spline, Bezier, B-Spline)

Lecture 9: Introduction to Spline Curves

Rational Bezier Curves

COMPUTER AIDED GEOMETRIC DESIGN. Thomas W. Sederberg

CS 475 / CS Computer Graphics. Modelling Curves 3 - B-Splines

Introduction p. 1 What Is Geometric Modeling? p. 1 Computer-aided geometric design Solid modeling Algebraic geometry Computational geometry

Rendering Curves and Surfaces. Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico

Splines. Connecting the Dots

Remark. Jacobs University Visualization and Computer Graphics Lab : ESM4A - Numerical Methods 331

Objects 2: Curves & Splines Christian Miller CS Fall 2011

Further Graphics. Bezier Curves and Surfaces. Alex Benton, University of Cambridge Supported in part by Google UK, Ltd

A Practical Review of Uniform B-Splines

Curves and Surfaces. Computer Graphics COMP 770 (236) Spring Instructor: Brandon Lloyd

Introduction to Geometry. Computer Graphics CMU /15-662

Shape modeling Modeling technique Shape representation! 3D Graphics Modeling Techniques

COMP3421. Global Lighting Part 2: Radiosity

Advanced Graphics. Beziers, B-splines, and NURBS. Alex Benton, University of Cambridge Supported in part by Google UK, Ltd

Computer Graphics CS 543 Lecture 13a Curves, Tesselation/Geometry Shaders & Level of Detail

CS123 INTRODUCTION TO COMPUTER GRAPHICS. Describing Shapes. Constructing Objects in Computer Graphics 1/15

Fundamentals of Computer Graphics. Lecture 3 Parametric curve and surface. Yong-Jin Liu.

15.10 Curve Interpolation using Uniform Cubic B-Spline Curves. CS Dept, UK

Computer Animation. Rick Parent

In this course we will need a set of techniques to represent curves and surfaces in 2-d and 3-d. Some reasons for this include

MA 323 Geometric Modelling Course Notes: Day 28 Data Fitting to Surfaces

COMPUTER AIDED ENGINEERING DESIGN (BFF2612)

Derivative. Bernstein polynomials: Jacobs University Visualization and Computer Graphics Lab : ESM4A - Numerical Methods 313

CS337 INTRODUCTION TO COMPUTER GRAPHICS. Describing Shapes. Constructing Objects in Computer Graphics. Bin Sheng Representing Shape 9/20/16 1/15

EECS 487, Fall 2005 Exam 2

Curve Representation ME761A Instructor in Charge Prof. J. Ramkumar Department of Mechanical Engineering, IIT Kanpur

An Introduction to B-Spline Curves

CHAPTER 6 Parametric Spline Curves

Parametric Surfaces. Michael Kazhdan ( /657) HB , FvDFH 11.2

Curves and Surfaces. CS475 / 675, Fall Siddhartha Chaudhuri

Review of Tuesday. ECS 175 Chapter 3: Object Representation

CGT 581 G Geometric Modeling Curves

Roadmap for tonight. What are Bezier curves (mathematically)? Programming Bezier curves (very high level view).

ECE 600, Dr. Farag, Summer 09

Computer Graphics I Lecture 11

Shape Representation Basic problem We make pictures of things How do we describe those things? Many of those things are shapes Other things include

Polynomials tend to oscillate (wiggle) a lot, even when our true function does not.

Transcription:

Fall 2014 CSCI 420: Computer Graphics 4.2 Splines Hao Li http://cs420.hao-li.com 1

Roller coaster Next programming assignment involves creating a 3D roller coaster animation We must model the 3D curve describing the roller coaster, but how? 2

Modeling Complex Shapes We want to build models of very complicated objects Complexity is achieved using simple pieces - polygons, - parametric curves and surfaces, or - implicit curves and surfaces This lecture: parametric curves 3

What Do We Need From Curves in Computer Graphics? Local control of shape (so that easy to build and modify) Stability Smoothness and continuity Ability to evaluate derivatives Ease of rendering 4

Curve Representations Explicit: y = f(x) - Must be a function (single-valued) - Big limitation vertical lines? Parametric: (x, y) =(f(u),g(u)) - Easy to specify, modify, control - Extra hidden variable u, the parameter Implicit: y f(x, y) =0 - can be a multiple valued function of - Hard to specify, modify, control x 5

Parameterization of a Curve Parameterization of a curve: how a change in you along a given curve in xyz space. u moves Parameterization is not unique. It can be slow, fast, with continuous / discontinuous speed, clockwise (CW) or CCW parameterization u =0 u =1 u =0 u =1 u =0.3 u =0.8 6

Polynomial Interpolation An n-th degree polynomial fits a curve to n+1 points - called Lagrange Interpolation - result is a curve that is too wiggly, change to any control point affects entire curve (non-local) - this method is poor source:wikipedia Lagrange interpolation, degree=15 We usually want the curve to be as smooth as possible - minimize the wiggles - high-degree polynomials are bad 7

Polynomial Approximation Polynomials are computable functions f(t) = p i=0 c i t i = Taylor expansion up to degree g(h) = p i=0 p i=0 p c i i (t) 1 i! g(i) (0) h i + O h p+1 Error for approximation g by polynomial f f(t) f(t i )=g(t i ), 0 t 0 < <t p h 1 p (p+1) g(t) max f (t t i ) = O h (p+1) (p + 1)! i=0 8

Spline Surfaces Piecewise polynomial approximation f (u, v) = n i=0 m c ij Ni n (u) Nj m (v) j=0 9

Spline Surfaces Piecewise polynomial approximation Geometric constraints" Large number of patches Continuity between patches Trimming Topological constraints" Rectangular patches Regular control mesh 10

Splines: Piecewise Polynomials A spline is a piecewise polynomial: Curve is broken into consecutive segments, each of which is a low-degree polynomial interpolating (passing through) the control points Cubic piecewise polynomials are the most common: - They are the lowest order polynomials that 1. interpolate two points and 2. allow the gradient at each point to be defined (C 1 continuity is possible) - Piecewise definition gives local control - Higher or lower degrees are possible, of course 11

Piecewise Polynomials Spline: many polynomials pieced together Want to make sure they fit together nicely Continuous in position Continuous in position and tangent vector Continuous in position, tangent, and curvature 12

Splines Types of splines: - Hermite Splines - Bezier Splines - Catmull-Rom Splines - Natural Cubic Splines - B-Splines - NURBS Splines can be used to model both curves and surfaces 13

Cubic Curves in 3D Cubic polynomial:! - - are 3-vectors, u is a scalar Three cubic polynomials, one for each coordinate: - - - In matrix notation:! p(u) =au 3 + bu 2 + cu + d a, b, c, d x(u) =a x u 3 + b x u 2 + c x u + d x z(u) =a z u 3 + b z u 2 + c z u + d z x(u) y(u) z(u) = u 3 u 2 u 1 2 Or simply: = u 3 u 2 u 1 a b c d y(u) =a y u 3 + b y u 2 + c y u + d y p = u 3 u 2 u 1 A 6 4 a x a y a z b x b y b z c x c y c z d x d y d z 3 7 5 14

Cubic Hermite Splines We want a way to specify the end points and the slope at the end points! 15

Deriving Hermite Splines Four constraints: value and slope (in 3-D, position and tangent vector) at beginning and end of interval [0,1] :!! p(0) = p 1 =(x 1,y 1,z 1 ) p(1) = p 2 =(x 2,y 2,z 2 ) p 0 (0) = p 1 =(x 1, y 1, z 1 ) the user constraints! p 0 (1) = p 2 =(x 2, y 2, z 2 ) Assume cubic form: p(u) =au 3 + bu 2 + cu + d Four unknowns: a, b, c, d 16

Deriving Hermite Splines Assume cubic form: p(u) =au 3 + bu 2 + cu + d!! p 1 = p(0) = d p 2 = p(1) = a + b + c + d p 1 = p 0 (0) = c p 2 = p 0 (1) = 3a +2b + c Linear system: 12 equations for 12 unknowns (however, can be simplified to 4 equations for 4 unknowns) a, b, c, d a, b, c, d Unknowns: (each of is a 3-vector) 17

Deriving Hermite Splines d = p 1 a + b + c + d = p 2 c = p 1 3a +2b + c = p 2 Rewrite this 12x12 system as a 4x4 system: 18

The Cubic Hermite Spline Equation After inverting the 4x4 matrix, we obtain:!!! point on the spline! This form is typical for splines - basis matrix and meaning of control matrix change with the spline type parameter vector basis control matrix (what the user gets to pick) 19

Four Basis Functions for Hermite Splines transpose 4 Basis Functions Every cubic Hermite spline is a linear combination (blend) of these 4 functions. 20

Piecing together Hermite Splines It's easy to make a multi-segment Hermite spline: - each segment is specified by a cubic Hermite curve - just specify the position and tangent at each joint (called knot) - the pieces fit together with matched positions and first derivatives - gives C1 continuity 21

Hermite Splines in Adobe Illustrator 22

Bezier Splines Variant of the Hermite spline Instead of endpoints and tangents, four control points - points P 1 and P 4 are on the curve - points P 2 and P 3 are off the curve - p(0) = P 1,p(1) = P 4 - p 0 (0) = 3(P 2 P 1), p 0 (1) = 3(P 4 P 3) Basis matrix is derived from the Hermite basis (or from scratch) Convex Hull property: curve contained within the convex hull of control points Scale factor 3 is chosen to make velocity approximately constant 23

The Bezier Spline Matrix Hermite basis Bezier to Hermite Bezier control matrix Bezier basis Bezier control matrix 24

Bezier Blending Functions p(t) = 2 6 4 (1 t) 3 3t(1 t) 2 3t 2 (1 t) t 3 3 7 5 T 2 6 4 p 1 p 2 p 3 p 4 3 7 5 Also known as the order 4, degree 3 Bernstein polynomials Nonnegative, sum to 1 The entire curve lies inside the polyhedron bounded by the control points 25

DeCasteljau Construction Efficient algorithm to evaluate Bezier splines. Similar to Horner rule for polynomials. Can be extended to interpolations of 3D rotations. 26

Catmull-Rom Splines Roller-coaster (next programming assignment) With Hermite splines, the designer must arrange for consecutive tangents to be collinear, to get C 1 continuity. Similar for Bezier. This gets tedious. Catmull-Rom: an interpolating cubic spline with built-in C 1 continuity. Compared to Hermite/Bezier: fewer control points required, but less freedom. Catmull-Rom spline 27

Constructing the Catmull-Rom Spline Suppose we are given n control points in 3-D: p 1,p 2,...,p n For a Catmull-Rom spline, we set the tangent at pi to for for some (often ) s (p i+1 p i 1 ) i =2,...,n 1 s s =0.5 s is tension parameter: determines the magnitude (but not direction!) of the tangent vector at point p i What about endpoint tangents? Use extra control points p 0,p n+1 Now we have positions and tangents at each knot. This is a Hermite specification. Now, just use Hermite formulas to derive the spline Note: curve between pi and pi+1 is completely determined by p i 1,p i,p i+1,p i+2 28

Catmull-Rom Spline Matrix basis control matrix Derived in way similar to Hermite and Bezier Parameter s is typically set to s=1/2 29

Splines with More Continuity? So far, only C 1 continuity How could we get C 2 continuity at control points? Possible answers: - Use higher degree polynomials degree 4 = quartic, degree 5 = quintic, but these get computationally expensive, and sometimes wiggly - Give up local control natural cubic splines A change to any control point affects the entire curve - Give up interpolation cubic B-splines Curve goes near, but not through, the control points 30

Comparison of Basic Cubic Splines Type Local Control Continuity Interpolation Hermite YES C1 YES Bezier YES C1 YES Catmull-Rom YES C1 YES Natural NO C2 YES B-Splines YES C2 NO Summary: Cannot get C2, interpolation and local control with cubics 31

Natural Cubic Splines If you want 2nd derivatives at joints to match up, the resulting curves are called natural cubic splines It s a simple computation to solve for the cubics' coefficients. (See Numerical Recipes in C book for code.) Finding all the right weights is a global calculation (solve tridiagonal linear system) 32

B-Splines Give up interpolation - the curve passes near the control points - best generated with interactive placement (because it s hard to guess where the curve will go) Curve obeys the convex hull property C2 continuity and local control are good compensation for loss of interpolation 33

B-Spline Basis We always need 3 more control points than the number of spline segments M Bs = 1 6 2 6 4 1 3 3 1 3 6 3 0 3 0 3 0 1 4 1 0 3 7 5 G Bsi = 2 6 4 P i 3 P i 2 P i 1 3 7 5 P i 34

Other Common Types of Splines Non-Uniform Splines Non-Uniform Rational Cubic curves (NURBS) NURBS are very popular and used in many commercial packages 35

How to Draw Spline Curves Basis matrix equation allows same code to draw any spline type Method 1: brute force - Calculate the coefficients - For each cubic segment, vary u from 0 to 1 (fixed step size) - Plug in u value, matrix multiply to compute position on curve - Draw line segment from last position to current position What s wrong with this approach? - Draws in even steps of u - Even steps of u does not mean even steps of x - Line length will vary over the curve - Want to bound line length too long: curve looks jagged too short: curve is slow to draw 36

Drawing Splines, 2 Method 2: recursive subdivision - vary step size to draw short lines!!!! Subdivide(u0,u1,maxlinelength)! umid = (u0 + u1)/2! x0 = F(u0)! x1 = F(u1)! if x1 - x0 > maxlinelength!! Subdivide(u0,umid,maxlinelength)!! Subdivide(umid,u1,maxlinelength)! else drawline(x0,x1) Variant on Method 2 - subdivide based on curvature - replace condition in if statement with straightness criterion - draws fewer lines in flatter regions of the curve 37

Summary Piecewise cubic is generally sufficient Define conditions on the curves and their continuity Most important: - basic curve properties (what are the conditions, controls, and properties for each spline type) - generic matrix formula for uniform cubic splines p(u) =ubg - given a definition, derive a basis matrix (do not memorize the matrices themselves) 38

http://cs420.hao-li.com Thanks! 39