Cubic Splines; Bézier Curves

Similar documents
Global polynomial interpolants suffer from the Runge Phenomenon if the data sites (nodes) are not chosen correctly.

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

1 Piecewise Cubic Interpolation

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.

Q 0 x if x 0 x x 1. S 1 x if x 1 x x 2. i 0,1,...,n 1, and L x L n 1 x if x n 1 x x n

3.1 Interpolation and the Lagrange Polynomial

SPLINE INTERPOLATION

Lecture 10 Polynomial interpolation

Fitting a Natural Spline to Samples of the Form (t, f(t))

Lectures 9-10: Polynomial and piecewise polynomial interpolation

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

Empirical Models Interpolation Polynomial Models

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

Numerical Methods I: Interpolation (cont ed)

Applied Math 205. Full office hour schedule:

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

Interpolation and extrapolation

Module - 02 Lecture 11

Engineering 7: Introduction to computer programming for scientists and engineers

Computational Physics

CONTROL POLYGONS FOR CUBIC CURVES

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

1 Review of Interpolation using Cubic Splines

Chapter 4: Interpolation and Approximation. October 28, 2005

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.

We consider the problem of finding a polynomial that interpolates a given set of values:

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

Fast Convolution; Strassen s Method

Computergrafik. Matthias Zwicker Universität Bern Herbst 2016

Cubic Splines. Antony Jameson. Department of Aeronautics and Astronautics, Stanford University, Stanford, California, 94305

MTH5112 Linear Algebra I MTH5212 Applied Linear Algebra (2017/2018)

Piecewise Polynomial Interpolation

Lecture 20: Bezier Curves & Splines

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

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

directed weighted graphs as flow networks the Ford-Fulkerson algorithm termination and running time

Computing the Hausdorff Distance between Two B-Spline Curves. Zachi Shtain

Alternatives. The D Operator

AP Calculus BC. Free-Response Questions

Numerical Methods I: Polynomial Interpolation

Curve Fitting and Interpolation

CMSC427 Parametric curves: Hermite, Catmull-Rom, Bezier

Polynomial Interpolation Part II

Name: Date: Block: Quarter 2 Summative Assessment Revision #1

Up/down-sampling & interpolation Centre for Doctoral Training in Healthcare Innovation

Cubic Spline. s(x) = s j (x) = a j + b j (x x j ) + c j (x x j ) 2 + d j (x x j ) 3, j = 0,... n 1 (1)

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

The Essentials of CAGD

A first order divided difference

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

Calculus and Parametric Equations

Approximation of Circular Arcs by Parametric Polynomials

MA 323 Geometric Modelling Course Notes: Day 07 Parabolic Arcs

Lösning: Tenta Numerical Analysis för D, L. FMN011,

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

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

Piecewise Polynomial Interpolation

Input: A set (x i -yy i ) data. Output: Function value at arbitrary point x. What for x = 1.2?

Fixed point iteration and root finding

Interpolation and Deformations A short cookbook

Hermite Interpolation with Euclidean Pythagorean Hodograph Curves

n 1 f n 1 c 1 n+1 = c 1 n $ c 1 n 1. After taking logs, this becomes

University of British Columbia Math 307, Final

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

Math Numerical Analysis Mid-Term Test Solutions

Two Applications of Maximum Flow

Lecture 1 INF-MAT : Chapter 2. Examples of Linear Systems

Preliminary Examination in Numerical Analysis

Math 578: Assignment 2

MAT300/500 Programming Project Spring 2019

Reverse engineering using computational algebra

Lecture Note 3: Interpolation and Polynomial Approximation. Xiaoqun Zhang Shanghai Jiao Tong University

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

Scientific Computing: An Introductory Survey

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

Interpolation. Escuela de Ingeniería Informática de Oviedo. (Dpto. de Matemáticas-UniOvi) Numerical Computation Interpolation 1 / 34

CHAPTER 3 Further properties of splines and B-splines

Robotics I. June 6, 2017

Lecture 23: Hermite and Bezier Curves

Interpolation Theory

Lecture 38 Insulated Boundary Conditions

Linear Regression Model. Badr Missaoui

Interpolation and polynomial approximation Interpolation

MA2501 Numerical Methods Spring 2015

There is a unique function s(x) that has the required properties. It turns out to also satisfy

Finite element function approximation

Numerical Analysis Lecture Notes

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

Review for the Midterm Exam

Tutorial for the supercritical pressure pipe with STAR-CCM+

G-code and PH curves in CNC Manufacturing

Regression: Lecture 2

Lecture 7: Interpolation

Interpolation and Deformations A short cookbook

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

Lecture 04: Secret Sharing Schemes (2) Secret Sharing

Curves, Surfaces and Segments, Patches

Reading. w Foley, Section 11.2 Optional

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

Transcription:

Cubic Splines; Bézier Curves 1 Cubic Splines piecewise approximation with cubic polynomials conditions on the coefficients of the splines 2 Bézier Curves computer-aided design and manufacturing MCS 471 Lecture 8(b) Numerical Analysis Jan Verschelde, 6 July 2018 Numerical Analysis (MCS 471) Cubic Splines; Bézier Curves L-8(b) 6 July 2018 1 / 18

Cubic Splines; Bézier Curves 1 Cubic Splines piecewise approximation with cubic polynomials conditions on the coefficients of the splines 2 Bézier Curves computer-aided design and manufacturing Numerical Analysis (MCS 471) Cubic Splines; Bézier Curves L-8(b) 6 July 2018 2 / 18

piecewise approximation with cubic polynomials f 1 f 0 f 2 f 3 f 5 f 4 x 0 x 1 x 2 x 3 x 4 x 5 Input: (x i, f i ), i = 0, 1,..., n, x 0 < x 1 < < x n. Interpolating splines S i through internal nodes x 1, x 2,..., x n 1 : S i 1 (x i 1 ) = S i (x i ) same value, S i 1 (x i 1) = S i (x i) same slope, S i 1 i 1) = S i (x i ) same concavity. Numerical Analysis (MCS 471) Cubic Splines; Bézier Curves L-8(b) 6 July 2018 3 / 18

cubic splines Input: n + 1 data points (x 0, f 0 ), (x 1, f 1 ),..., (x n, f n ). Interpolating cubic splines: S i (x) = f i + b i (x x i ) + c i (x x i ) 2 + d i (x x i ) 3, on [x i, x i+1 ], i = 0, 1,..., n 1. We see S i (x i ) = f i. Additional conditions: S i (x i+1 ) = f i+1, i = 0, 1,..., n 1, S i 1 (x i) = S i (x i), i = 1, 2,..., n 1, S i 1 i) = S i (x i ), i = 1, 2,..., n 1. So we have n + (n 1) + (n 1) = 3n 2 conditions for 3n coefficients. Two degrees of freedom. For a natural spline, we require S 0 (x 0) = 0 and S n(x n ) = 0. Numerical Analysis (MCS 471) Cubic Splines; Bézier Curves L-8(b) 6 July 2018 4 / 18

Cubic Splines; Bézier Curves 1 Cubic Splines piecewise approximation with cubic polynomials conditions on the coefficients of the splines 2 Bézier Curves computer-aided design and manufacturing Numerical Analysis (MCS 471) Cubic Splines; Bézier Curves L-8(b) 6 July 2018 5 / 18

deriving conditions S i (x) = f i + b i (x x i ) + c i (x x i ) 2 + d i (x x i ) 3, S i (x) = b i + 2c i (x x i ) + 3d i (x x i ) 2, S i (x) = 2c i + 6d i (x x i ). Consider S i (x i ) = 2c i c i = S i (x i )/2, and then: S i (x i+1 ) = 2c i + 6d i (x i+1 x i ) S i (x i ) = 2c i S i (x i+1 ) S i (x i ) = 6d i (x i+1 x i ) d i = S i (x i+1 ) S i (x i ) 6(x i+1 x i ) Numerical Analysis (MCS 471) Cubic Splines; Bézier Curves L-8(b) 6 July 2018 6 / 18

deriving conditions continued We have already derived the following: S i (x) = f i + b i (x x i ) + c i (x x i ) 2 + d i (x x i ) 3, c i = S i (x i )/2, d i = (S i (x i+1 ) S i (x i ))/(6(x i+1 x i )). Now we look for conditions on b i : S i (x i+1 ) = f i+1 = f i + b i (x i+1 x i ) + c i (x i+1 x i ) 2 + d i (x i+1 x i ) 3. f i+1 f i x i+1 x i = b i + c i (x i+1 x i ) + d i (x i+1 x i ) 2 = b i + S i (x i ) 2 = b i + S i (x i ) 2 (x i+1 x i ) + S i (x i+1 ) S 6(x i+1 x i ) (x i+1 x i ) + S i (x i+1 ) S 6(x i+1 x i ) i (x i ) (x i+1 x i ) 2 i (x i ) (x i+1 x i ) 2 Numerical Analysis (MCS 471) Cubic Splines; Bézier Curves L-8(b) 6 July 2018 7 / 18

deriving conditions continued f i+1 f i = b i + S i (x i ) x i+1 x i 2 = b i + x i+1 x i 6 (x i+1 x i ) + S i (x i+1 ) S 6(x i+1 x i ) b i = f i+1 f i x i+1 x i x i+1 x i 6 ( 3S i (x i ) + S i (x i+1 ) S i (x i ) ) i (x i ) (x i+1 x i ) 2 (2S i (x i ) + S i (x i+1 )) Denote h i = x i+1 x i, T i = S i (x i ), T i+1 = S i (x i+1 ): b i = f i+1 f i h i h i 6 (2T i + T i+1 ), c i = T i 2, d i = T i+1 T i 6h i. Numerical Analysis (MCS 471) Cubic Splines; Bézier Curves L-8(b) 6 July 2018 8 / 18

deriving conditions continued S i (x) = b i + 2c i (x x i ) + 3d i (x x i ) 2, S i (x i) = b i. Impose slope conditions S i 1 (x i) = S i (x i), h i = x i+1 x i. S i 1 (x i) = b i 1 + 2c i 1 (x i x i 1 ) + 3d i 1 (x i x i 1 ) 2 = f i f i 1 h i 1 h i 1 6 (2T i 1 + T i ) + 2 T i 1 2 h i 1 + 3 T i T i 1 ( 3 = T i 6 h i 1 1 ) ( 6 h i 1 + T i 1 3 6 h i 1 + h i 1 2 ) 6 h i 1 = 2 6 h i 1T i + 1 6 h i 1T i 1 + f i f i 1 h i 1 6h i 1 h 2 i 1 + f i f i 1 h i 1 Numerical Analysis (MCS 471) Cubic Splines; Bézier Curves L-8(b) 6 July 2018 9 / 18

imposing slope conditions S i 1 (x i) = S i (x i) Recall: S i (x) = b i + 2c i (x x i ) + 3d i (x x i ) 2, S i (x i ) = b i = f i+1 f i h i h i 6 (2T i + T i+1 ). Thus we have: 2 6 h i 1T i + 1 6 h i 1T i 1 + f i f i 1 = f i+1 f i 2 h i 1 h i 6 h it i 1 6 h it i+1 1 6 h it i+1 + 2 6 (h i 1 + h i )T i + 1 6 h i 1T i 1 = f i+1 f i f i f i 1 h i h i 1 h i T i+1 + 2(h i 1 + h i )T i + h i 1 T i 1 = 6(f [x i, x i+1 ] f [x i 1, x i ]) for i = 1, 2,..., n, which gives n equations in n + 2 unknowns, with two additional conditions: T 0 = 0, T n+1 = 0. Numerical Analysis (MCS 471) Cubic Splines; Bézier Curves L-8(b) 6 July 2018 10 / 18

an example, for n = 4 A = h 0 2(h 0 + h 1 ) h 1 0 0 0 h 1 2(h 1 + h 2 ) h 2 0 0 0 h 2 2(h 2 + h 3 ) h 3 A T 0 T 1 T 2 T 3 T 4 = 6(f [x 1, x 2 ] f [x 0, x 1 ]) 6(f [x 2, x 3 ] f [x 1, x 2 ]) 6(f [x 3, x 4 ] f [x 2, x 3 ]) With T 0 = 0 and T 4 = 0: a 3-by-3 linear system. b i = f i+1 f i h i h i 6 (2T i + T i+1 ), c i = T i 2, d i = T i+1 T i 6h i. S i (x) = f i + b i (x x i ) + c i (x x i ) 2 + d i (x x i ) 3. Numerical Analysis (MCS 471) Cubic Splines; Bézier Curves L-8(b) 6 July 2018 11 / 18

compute a numerical example Exercise 1: Compute the natural cubic spline through the points (1, 1), (2, 5), (3, 6), and (4, 0). Verify that your solution satisfies all conditions, as listed on slide #4. Numerical Analysis (MCS 471) Cubic Splines; Bézier Curves L-8(b) 6 July 2018 12 / 18

uniqueness of the cubic spline Observe that the system in the T i s is diagonally dominant. This implies that the linear system has a unique solution. Theorem For inputs (x i, f i ), i = 0, 1,..., n, x 0 < x 1 < < x n, there is a unique piecewise approximation with cubic splines S i : interpolating: S i (x i ) = f i, i = 0, 1,..., n 1, S n 1 (x n ) = f n, at all internal nodes, for i = 1, 2,..., n 1: S i 1 (x i 1 ) = S i (x i ), S i 1 (x i 1) = S i (x i), S i 1 (x i 1) = S i (x i ), natural: S 0 (x 0) = 0, S n 1 (x n) = 0. Numerical Analysis (MCS 471) Cubic Splines; Bézier Curves L-8(b) 6 July 2018 13 / 18

numerical conditioning Exercise 2: Consider the matrix for n = 6: 2(h 0 + h 1 ) h 1 0 0 0 h 1 2(h 1 + h 2 ) h 2 0 0 A = 0 h 2 2(h 2 + h 3 ) h 3 0 0 0 h 3 2(h 3 + h 4 ) h 4, 0 0 0 h 4 2(h 4 + h 5 ) where h i is the distance between x i and x i+1, for i = 0, 1,..., 5. 1 Generate random values for all h i s and compute the condition number of A. Is this problem well conditioned? Justify. 2 For which values of h i is the matrix A poorly conditioned? Generate an example and justify your choice for the distances. Numerical Analysis (MCS 471) Cubic Splines; Bézier Curves L-8(b) 6 July 2018 14 / 18

Cubic Splines; Bézier Curves 1 Cubic Splines piecewise approximation with cubic polynomials conditions on the coefficients of the splines 2 Bézier Curves computer-aided design and manufacturing Numerical Analysis (MCS 471) Cubic Splines; Bézier Curves L-8(b) 6 July 2018 15 / 18

Bézier Curves Bézier curves are splines that allow to control the slopes at the knots. y 4 3 2 1 0 0 1 2 3 4 x Input: knot (1, 1) with control (1, 3), knot (2, 2) with control (3, 3). Numerical Analysis (MCS 471) Cubic Splines; Bézier Curves L-8(b) 6 July 2018 16 / 18

a Bézier curve Input: end points (x 1, y 1 ), (x 4, y 4 ); and control points (x 2, y 2 ), (x 3, y 3 ). Set b x = 3(x 2 x 1 ), c x = 3(x 3 x 2 ) b x, d x = x 4 x 1 b x c x, b y = 3(y 2 y 1 ), c y = 3(y 3 y 2 ) b y, d y = y 4 y 1 b y c y, then the Bézier curve (x(t), y(t)), for t [0, 1], is x(t) = x 1 + b x t + c x t 2 + d x t 3 y(t) = y 1 + b y t + c y t 2 + d y t 3. We see that x(0) = x 1 and y(0) = y 1, x (0) = b x and y (0) = b y. x(1) = x 1 + b x + c x + x 4 x 1 b x c x = x 4 x (1) = b x + 2c x + 3(x 4 x 1 b x c x ) = 3(x 4 x 1 ) 2b x c x = 3(x 4 x 1 ) 2b x (3(x 3 x 2 ) b x ) = 3(x 4 x 1 ) 3(x 2 x 1 ) 3(x 3 x 2 ) = 3(x 4 x 3 ). Numerical Analysis (MCS 471) Cubic Splines; Bézier Curves L-8(b) 6 July 2018 17 / 18

an example Input: knot (1, 1) with control (1, 3), knot (2, 2) with control (3, 3). y 4 3 2 1 0 0 1 2 3 4 x Output: x(t) = 1 + 6t 2 5t 3, y(t) = 1 + 6t 6t 2 + t 3. Numerical Analysis (MCS 471) Cubic Splines; Bézier Curves L-8(b) 6 July 2018 18 / 18