數值方法 2008, Applied Mathematics NDHU 1 Spline interpolation.

Slides:



Advertisements
Similar presentations
數值方法 2008, Applied Mathematics NDHU 1 Nonlinear systems Newton’s method The steepest descent method.
Advertisements

BEZIER CURVES Part II. Assume we are given two endpoints labelled E1 and E2 and two control points labelled C1 and C2. create a smooth curve whose endpoints.
CS 445 / 645 Introduction to Computer Graphics Lecture 23 Bézier Curves Lecture 23 Bézier Curves.
March 1, 2009Dr. Muhammed Al-Mulhem1 ICS 415 Computer Graphics Hermite Splines Dr. Muhammed Al-Mulhem March 1, 2009 Dr. Muhammed Al-Mulhem March 1, 2009.
Lecture 10 Curves and Surfaces I
Chapter 2 Functions and Graphs
ICS 415 Computer Graphics Bézier Splines (Chapter 8)
CS 445/645 Fall 2001 Hermite and Bézier Splines. Specifying Curves Control Points –A set of points that influence the curve’s shape Knots –Control points.
Dr. S.M. Malaek Assistant: M. Younesi
ES 240: Scientific and Engineering Computation. InterpolationPolynomial  Definition –a function f(x) that can be written as a finite series of power functions.
Offset of curves. Alina Shaikhet (CS, Technion)
1cs426-winter-2008 Notes  Ian Mitchell is running a MATLAB tutorial, Tuesday January 15, 5pm-7pm, DMP 110 We won’t be directly using MATLAB in this course,
ENDS 375 Foundations of Visualization Geometric Representation 9/30/04.
RASTER CONVERSION ALGORITHMS FOR CURVES: 2D SPLINES 2D Splines - Bézier curves - Spline curves.
Now its time to graph our functions!! Graphing Linear Functions.
6.2 Graphs of Polynomials. The Degree of Polynomials The degree of a polynomial is the value of the largest exponent. y = 5x 4 + 3x 2 – 7 Degree = 4 y.
數值方法 2008, Applied Mathematics NDHU 1 Simpson rule Composite Simpson rule.
數值方法 2008 Applied Mathematics, NDHU1  Bisection method for root finding  Binary search  fzero Lecture 4.
數值方法 2008 Applied Mathematics, NDHU1  Bisection method for root finding  Binary search  fzero Lecture 4.
CS 450: COMPUTER GRAPHICS REVIEW: DRAWING ELLIPSES AND OTHER CURVES SPRING 2015 DR. MICHAEL J. REALE.
A D V A N C E D C O M P U T E R G R A P H I C S CMSC 635 January 15, 2013 Spline curves 1/23 Curves and Surfaces.
Interactive Graphics Lecture 9: Slide 1 Interactive Graphics Lecture 9: Introduction to Spline Curves.
Scientific Computing Linear and Quadratic Splines.
V. Space Curves Types of curves Explicit Implicit Parametric.
Review of Interpolation. A method of constructing a function that crosses through a discrete set of known data points.
Splines Vida Movahedi January 2007.
Quadratic Surfaces. SPLINE REPRESENTATIONS a spline is a flexible strip used to produce a smooth curve through a designated set of points. We.
Splines and applications
COM335 TOPIC 5 DRAWING CURVES. COM335 Two types of curve : Regular curves Which have a simple equation. For example the circle x 2 + y 2 = r 2 The equation.
Chapter 4 Representations of Curves and Surfaces.
Lecture 10 2D plotting & curve fitting Subplots Other 2-D Plots Other 2-D Plots Curve fitting © 2007 Daniel Valentine. All rights reserved. Published by.
41 - 4/24/2000AME 150L1 Solving Engineering Problems, Integrating Equations.
數值方法 2008, Applied Mathematics NDHU 1 Numerical Integration.
Jump to first page Chapter 3 Splines Definition (3.1) : Given a function f defined on [a, b] and a set of numbers, a = x 0 < x 1 < x 2 < ……. < x n = b,
Computer Programming (TKK-2144) 13/14 Semester 1 Instructor: Rama Oktavian Office Hr.: M.13-15, W Th , F
Ship Computer Aided Design MR 422. Geometry of Curves 1.Introduction 2.Mathematical Curve Definitions 3.Analytic Properties of Curves 4.Fairness of Curves.
Basic Theory (for curve 02). 1.3 Parametric Curves  The main aim of computer graphics is to display an arbitrary surface so that it looks real.  The.
Course 8 Contours. Def: edge list ---- ordered set of edge point or fragments. Def: contour ---- an edge list or expression that is used to represent.
Polynomials, Curve Fitting and Interpolation. In this chapter will study Polynomials – functions of a special form that arise often in science and engineering.
Mohiuddin Ahmad SUNG-BONG JANG Interpolation II (8.4 SPLINE INTERPOLATION) (8.5 MATLAB’s INTERPOLATION Functions)
數值方法 2008 Applied Mathematics, NDHU1  Lagrange polynomial  Polynomial interpolation Lecture 4II.
Curves: ch 4 of McConnell General problem with constructing curves: how to create curves that are “smooth” CAD problem Curves could be composed of segments.
In the name of God Computer Graphics Bastanfard. Curve Function(2) Other method is approximate it using a poly-line. Just locate a set of points along.
Interactive Graphics Lecture 10: Slide 1 Interactive Computer Graphics Lecture 10 Introduction to Surface Construction.
數值方法 2008, Applied Mathematics NDHU1 Chaos time series.
Basis of Mathematical Modeling LECTURE 3 Numerical Analysis with MATLAB Dr. N.K. Sakhnenko, PhD, Professor Associate.
數值方法 2008, Applied Mathematics NDHU 1 Numerical Differentiation.
數值方法, Applied Mathematics NDHU 1 Linear system. 數值方法, Applied Mathematics NDHU 2 Linear system.
Curves University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2013 Tamara Munzner.
Object Modeling: Curves and Surfaces CEng 477 Introduction to Computer Graphics.
CSCI480/582 Lecture 9 Chap.2.2 Cubic Splines – Hermit and Bezier Feb, 11, 2009.
Chapter 2 Functions and Graphs
Chapter 10-2: Curves.
Copyright © Cengage Learning. All rights reserved.
Graphing Linear Equations
Lecture 5 Polynomial Approximation
Interpolation Methods
Lecture 10 2D plotting & curve fitting
© University of Wisconsin, CS559 Spring 2004
Chapter XVII Parametric Curves and Surfaces
MATH 2140 Numerical Methods
Spline Interpolation Class XVII.
Least Squares Fitting A mathematical procedure for finding the best-fitting curve to a given set of points by minimizing the sum of the squares of the.
Interpolation Methods
SKTN 2393 Numerical Methods for Nuclear Engineers
Type to enter a caption. Computer Graphics Week 10 Lecture 1.
Spline representation. ❖ A spline is a flexible strip used to produce a smooth curve through a designated set of points. ❖ Mathematically describe such.
Type to enter a caption. Computer Graphics Week 10 Lecture 2.
Presentation transcript:

數值方法 2008, Applied Mathematics NDHU 1 Spline interpolation

 Spline  A flexible piece of wood, hard rubber, or metal used in drawing curves  Spline (mathematics) - Wikipedia, the free encyclopedia Spline (mathematics) - Wikipedia, the free encyclopedia 數值方法 2008, Applied Mathematics NDHU 2

 Before computers were used, numerical calculations were done by hand. Functions such as the step function were used but polynomials were generally preferred. With the advent of computers, splines first replaced polynomials in interpolation, and then served in construction of smooth and flexible shapes in computer graphics. [5]step function [5] 數值方法 2008, Applied Mathematics NDHU 3

Control Polygon  數值方法 2008, Applied Mathematics NDHU 4

Spline  Spline Pictures Spline Pictures 數值方法 2008, Applied Mathematics NDHU 5

Spline approximation  Matlab Spline toolbox  Input  paired data (x,y)  x_in : a set of horizontal coordinates  Output:  y_out, spline Interpolation at x_in 數值方法 2008, Applied Mathematics NDHU 6

7 Example I: three input arguments Input: x = 0:10; y = sin(x); x_in = 0:.25:10; Output: y_out = spline(x,y,x_in); Figure: plot(x,y,'o',x_in,y_out)

數值方法 2008, Applied Mathematics NDHU 8

Example II: Two input arguments 數值方法 2008, Applied Mathematics NDHU 9 x = -4:4; y = [ ]; cs = spline(x,y); xx = linspace(-4,4,101); plot(x,y,'o'); plot( xx,ppval(cs,xx),'-‘); INPUT OUTPUT FIGURE Polynomial output

數值方法 2008, Applied Mathematics NDHU 10

Example III  2 D splines 數值方法 2008, Applied Mathematics NDHU 11

數值方法 2008, Applied Mathematics NDHU 12 2-D spline demo_2d_spline.m

數值方法 2008, Applied Mathematics NDHU 13 Polygon figure;hold on points = [0 0; 1 0; 1 1; 0 2; -1 1; -1 0; 0 -1; 0 -2].'; plot(points(1,:),points(2,:),'k'), axis([ ]), grid off title('Control polygon')

數值方法 2008, Applied Mathematics NDHU 14 2D spline >> plot(points(1,:),points(2,:),'ok') >> fnplt( cscvn(points), 'g',1.5 )

CSCVN `Natural' or periodic interpolating cubic spline curve  CS = CSCVN(POINTS)   returns a parametric `natural' cubic spline that interpolates to  the given points POINTS(:,i) at parameter values t(i),  i=1,2,..., with t(i) chosen by Eugene Lee's centripetal scheme,  i.e., as accumulated square root of chord-length.   When first and last point coincide and there are no double points,  then a parametric *periodic* cubic spline is constructed instead.  However, double points result in corners. 數值方法 2008, Applied Mathematics NDHU 15

數值方法 2008, Applied Mathematics NDHU 16 For example, x1=[ ];x2=[ ]; plot( x1,x2, ' ok ');hold on curve = cscvn([x1;x2]) ; fnplt( curve )

數值方法 2008, Applied Mathematics NDHU 17 shows a (circular) curve through the four vertices of the standard diamond (because of the periodic boundary conditions enforced), while x1=[ ];x2=[ ]; plot( x1,x2, ' ok ');hold on curve = cscvn([x1;x2]) ; fnplt( curve ) shows a corner at the double point as well as at the curve endpoint.

Spline  A spline is composed of a set of piecewise polynomials  Linear spline  Quadratic spline  Cubic spline 數值方法 2008, Applied Mathematics NDHU 18

Spline approximation  Linear spline  First order piecewise polynomials  Quadratic spline  Second order piecewise polynomials  Cubic spline  Cubic piecewise polynomials 數值方法 2008, Applied Mathematics NDHU 19

數值方法 2008, Applied Mathematics NDHU 20 L=length(x_in) n=length(x) for j=1:L for k=1:n if x(k) >= x_in(j) break end EXIT function y_out=my_spline1(x,y,x_in) i=k-1; a=(y(i+1)-y(i))/(x(i+1)-x(i)); y_out(j)=y(i)+a*(x_in(j)-x(i));

Procedure: my_spline1 Function y_out=my_spline(x,y,x_in) L=length(x_in); for j=1:N A. Find i that satisfies x(i) <= xx(i) <x(i+1) B. Set g to the slop of a line that connects (x(i),y(i)) and (x(i+1),y(i+1)). C. y_out(j) = y(i)+g*(x_in(j)-x(i)) 數值方法 2008, Applied Mathematics NDHU 21

Line interpolating 數值方法 2008, Applied Mathematics NDHU 22 (x(i),y(i)) (x(i+1),y(i+1)) (x_in(j),y_out(j)=?)

Linear spline 數值方法 2008, Applied Mathematics NDHU 23 x = 0:10; y = sin(x); x_in = 0:.25:10; y_out = my_spline1(x,y,x_in); plot(x,y,'o',x_in,y_out) my_spline1.m

數值方法 2008, Applied Mathematics NDHU 24

數值方法 2008, Applied Mathematics NDHU 25 Quadratic Spline

數值方法 2008, Applied Mathematics NDHU 26 Quadratic spline

數值方法 2008, Applied Mathematics NDHU 27 Quadratic splines  Quadratic spline interpolation  Determine all f i

數值方法 2008, Applied Mathematics NDHU 28 quadratic polynomial

Smoothness criteria  The slopes of f i and f i+1 are identical at point P i 數值方法 2008, Applied Mathematics NDHU 29

數值方法 2008, Applied Mathematics NDHU 30 Smoothness Criteria Checking  Check

Fitting criteria  P i denotes point (x i y i )  f i passes points P i and P i+1 數值方法 2008, Applied Mathematics NDHU 31

數值方法 2008, Applied Mathematics NDHU 32 Fitting Criteria Checking - I  Check

數值方法 2008, Applied Mathematics NDHU 33 Fitting Criteria Checking - II  Check

數值方法 2008, Applied Mathematics NDHU 34 Recurrence relations

數值方法 2008, Applied Mathematics NDHU 35

數值方法 2008, Applied Mathematics NDHU 36 Equations for Implementation

數值方法 2008, Applied Mathematics NDHU 37 Re-indexing

數值方法 2008, Applied Mathematics NDHU 38 L=length(x_in) K=length(x) n=K-1; z(1)=0 for j=1:L for k=1:K if x(k) >= x_in(j) break end EXIT function y_out=my_spline1(x,y,x_in) i=k-1 a=(z(i+1)-z(i))/(x(i+1)-x(i));b=z(i);c=y(i) y_out(j)=a*(x_in(j)-x(i))^2+b*(x_in(j)-x(i)) +c; for i=1:n a=(y(i+1)-y(i))/(x(i+1)-x(i)) z(i+1)=2*a-z(i)

Procedure: my_spline2 Function y_out=my_spline2(x,y,x_in) n=length(x)-1;L=length(x_in); for i=1:n Determine z i+1 by eq(1) for j=1:L A. Find j that satisfies x(i) <= x_in(i) <x(i+1) B. substitute x_in(j) to eq(2) C. Set y_out(j) to the result of step B 數值方法 2008, Applied Mathematics NDHU 39

數值方法 2008, Applied Mathematics NDHU 40 Cubic spline

Criteria of cubic spline  Fitting criteria  First order smoothness criteria  Second order smoothness criteria 數值方法 2008, Applied Mathematics NDHU 41

數值方法 2008, Applied Mathematics NDHU 42 Fitting criteria

Smoothness criteria I  The slopes of f i and f i+1 are identical at point P i 數值方法 2008, Applied Mathematics NDHU 43

數值方法 2008, Applied Mathematics NDHU 44 Smoothness criteria II  The curvatures of f i and f i+1 are identical at point P i Pi

Exercise 6 due to 10/29  Problem 3 of Ex 5 數值方法 2008, Applied Mathematics NDHU 45

Problem 2  Draw a flow chart to illustrate linear spline interpolation  Implement the flow chart by matlab codes  Give examples to test your matlab codes 數值方法 2008, Applied Mathematics NDHU 46

Problem 3  Draw a flow chart to illustrate quadratic spline interpolation  Implement the flow chart by matlab codes  Give examples to test your matlab codes 數值方法 2008, Applied Mathematics NDHU 47