Numerical Computation

Slides:



Advertisements
Similar presentations
Lecture Notes #11 Curves and Surfaces II
Advertisements

Interpolation A method of constructing a function that crosses through a discrete set of known data points. .
Cubic Curves CSE167: Computer Graphics Instructor: Steve Rotenberg UCSD, Fall 2006.
ICS 415 Computer Graphics Bézier Splines (Chapter 8)
Cubic Curves CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2005.
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.
© University of Wisconsin, CS559 Spring 2004
Jehee Lee Seoul National University
CS 445 / 645 Introduction to Computer Graphics Lecture 22 Hermite Splines Lecture 22 Hermite Splines.
1 Curves and Surfaces. 2 Representation of Curves & Surfaces Polygon Meshes Parametric Cubic Curves Parametric Bi-Cubic Surfaces Quadric Surfaces Specialized.
Bezier Curves and Splines David Eno MAT 499 Fall ‘06.
Lecture 29 of 42 Bezier Curves and Splines Wednesday, 02 April 2008
Computer graphics & visualization Key frame Interpolation.
1Notes  Assignment 0 is being marked  Textbook reference for arc-length parameterization:  Section 3.2.
Informationsteknologi Monday, December 10, 2007Computer Graphics - Class 161 Today’s class Curve fitting Evaluators Surfaces.
Curves Chiew-Lan Tai. Curves 2 Reading Required Hearn & Baker, 8-8 – 8-10, 8-12 Foley, 11.2.
Introduction We have dealt with polylines and mesh shapes. We want a way to describe curved shapes which will make them easy to draw.
1 Dr. Scott Schaefer Curves and Interpolation. 2/61 Smooth Curves How do we create smooth curves?
1 Lecture 13 Modeling Curved Lines and Surfaces. 2 Types of Surfaces Ruled Surfaces B-Splines and Bezier Curves Surfaces of Revolution.
Modelling: Curves Week 11, Wed Mar 23
Splines III – Bézier Curves
Computer Graphics Lecture 13 Curves and Surfaces I.
Polynomials. 2 Content Evaluation Root finding Root Bracketing Interpolation Resultant.
Curve Modeling Bézier Curves
11/19/02 (c) 2002, University of Wisconsin, CS 559 Last Time Many, many modeling techniques –Polygon meshes –Parametric instancing –Hierarchical modeling.
CS 376 Introduction to Computer Graphics 04 / 23 / 2007 Instructor: Michael Eckmann.
Interactive Graphics Lecture 9: Slide 1 Interactive Graphics Lecture 9: Introduction to Spline Curves.
CS 376 Introduction to Computer Graphics 04 / 30 / 2007 Last Lecture :( Instructor: Michael Eckmann.
Scientific Computing Linear and Quadratic Splines.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
CSE167: Computer Graphics Instructor: Steve Rotenberg UCSD, Fall 2005
Review of Interpolation. A method of constructing a function that crosses through a discrete set of known data points.
Bézier Algorithms & Properties Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Wednesday, March 3, 2004.
CS 376 Introduction to Computer Graphics 04 / 20 / 2007 Instructor: Michael Eckmann.
Chapter VI Parametric Curves and Surfaces
INTERPOLATION & APPROXIMATION. Curve algorithm General curve shape may be generated using method of –Interpolation (also known as curve fitting) Curve.
June D Object Representation Shmuel Wimer Bar Ilan Univ., School of Engineering.
1 CS 430/536 Computer Graphics I Curve Drawing Algorithms Week 4, Lecture 8 David Breen, William Regli and Maxim Peysakhov Geometric and Intelligent Computing.
Geometric Modelling 2 INFO410 & INFO350 S Jack Pinches
COLLEGE OF ENGINEERING UNIVERSITY OF PORTO COMPUTER GRAPHICS AND INTERFACES / GRAPHICS SYSTEMS JGB / AAS Representation of Curves and Surfaces Graphics.
CS 376 Introduction to Computer Graphics 04 / 25 / 2007 Instructor: Michael Eckmann.
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.
Bézier Curves & Surfaces Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Monday, March 1, 2004.
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.
11/6/ :55 Graphics II Introduction to Parametric Curves and Surfaces Session 2.
Interpolating Splines, Implicit Descriptions Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Friday, March 5,
Review CSE167: Computer Graphics Instructor: Steve Rotenberg UCSD, Fall 2005.
Computing & Information Sciences Kansas State University Lecture 31 of 42CIS 636/736: (Introduction to) Computer Graphics Lecture 32 of 42 Wednesday, 11.
Parametric Curves CS 318 Interactive Computer Graphics John C. Hart.
CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai.
CS 450: Computer Graphics PARAMETRIC SPLINES AND SURFACES
Splines Sang Il Park Sejong University. Particle Motion A curve in 3-dimensional space World coordinates.
CS 325 Computer Graphics 04 / 30 / 2010 Instructor: Michael Eckmann.
Foundations of Computer Graphics (Spring 2012) CS 184, Lecture 12: Curves 1
College of Computer and Information Science, Northeastern UniversityFebruary 27, CS U540 Computer Graphics Prof. Harriet Fell Spring 2009 Lectures.
Computing & Information Sciences Kansas State University Lecture 30 of 42CIS 636/736: (Introduction to) Computer Graphics Lecture 30 of 42 Wednesday, 09.
Curves University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2013 Tamara Munzner.
CS552: Computer Graphics Lecture 19: Bezier Curves.
Introduction to Parametric Curve and Surface Modeling.
© University of Wisconsin, CS559 Spring 2004
Computer Graphics Lecture 38
© University of Wisconsin, CS559 Spring 2004
Chapter XVII Parametric Curves and Surfaces
Curves and Surfaces.
Implicit Functions Some surfaces can be represented as the vanishing points of functions (defined over 3D space) Places where a function f(x,y,z)=0 Some.
Curve design 455.
Three-Dimensional Object Representation
Lecture 21: B Spline Curve
Introduction to Parametric Curve and Surface Modeling
Presentation transcript:

Numerical Computation Lecture 14: Bezier Curves United International College

Last Time During the last class period we covered: Cubic Splines Readings: Pav, section 6.2 (omit 6.2.1)

Today We will cover: Bezier Curves Readings: These Slides !!

Review So far we have looked at the question of finding a polynomial (or set of polynomials) to interpolate a set of data points {xk ,yk} We have come up with two ways to find a single interpolating polynomial for the data: Lagrange method and Newton’s method. We have computed spline curves that interpolate the data over a partition.

Drawbacks to These Methods These methods are quite useful for a variety of applications, but they have two major drawbacks: 1) They cannot model data that have duplicate y – values

Drawbacks to These Methods 2) The final shape of the curve is completely dependent on the data. It would be nice to be able to better control the shape of the interpolating curve without having to move data points.

Bezier Curves Bezier Curves can solve both of these problems ! Definition: A Bezier curve is a parametric curve described by polynomials based on control points. Any number of control points may be used. (usually 4) Degree of polynomials = number of points – 1. (usually =3) Several Bezier curves can easily be glued together in a way that makes the curve as a whole smooth. A Bezier curve passes through its first and last control points, but, in general, no others.

Parametric Curves Definition: A parametric curve is a vector function of a single argument (t). The variable t is called the parameter. Example: p(t) = (x(t), y(t)) is a parametric curve in the plane. Example: p(t) = (x(t), y(t), z(t)) is a parametric curve in space. Example: p(t) = (cos(t), sin(t)) for 0 ≤ t ≤ π produces a circle.

Parametric Curves Example: x(t) = t2–2t, y(t) = t–1, t in [0,3]. By using parametric curves we can create curves with multiple y-values for a given x-value. This solves the first problem discussed above as Drawback 1). y t = 3 (end) (t2–2t, t–1) x t = 0 (start)

Parametric Curves Other Benefits of using Parametric Curves: Every curve can be described as a parametric curve. A parametric curve can be easily computed. A parametric curve is a useful description of motion. We think of the parameter as representing time (thus, “t”).

Parametric Curves - Motion Given a parametric curve p(t) = (x(t), y(t)) p’(t) = (x’(t), y’(t)) velocity vector points in direction of motion p’(t)/||p’(t)|| unit tangent (velocity) vector ||p’(t)|| speed p’(t) p(t) t = 0 t = 1

Bezier Curves Bezier curves are parametric curves, where each of the parametric functions for x(t) and y(t) are polynomials in t (typically degree 2 or 3). Quadratic Bezier Curve: x(t) and y(t) are quadratic polynomials in t. (0 ≤ t ≤ 1) Cubic Bezier Curve: x(t) and y(t) are cubic polynomials in t. (0 ≤ t ≤ 1) x(t) = at3 + bt2 + ct + d y(t) = et3 + ft2 + gt + h

Bezier Curves x(t) = at3 + bt2 + ct + d Cubic Bezier Curve: • p1=(x1,y1) Cubic Bezier Curve: x(t) = at3 + bt2 + ct + d y(t) = et3 + ft2 + gt + h (0 ≤ t ≤ 1) A Bezier curve passes through its first and last control points, so x0 = x(0) y0 = y(0) x3 = x(1) y3 = y(1) How do we find the other points (x(t),y(t)) on the curve? • p2=(x2,y2) (x(t),y(t)) p0=(x0,y0) p3=(x3,y3)

de Casteljau Algorithm p1 The de Casteljau algorithm calculates the points on a Bezier Curve as a recursive series of linear interpolations. (“Lerps”) Step 1: q1 q0 p0 p2 q2 p3

de Casteljau Algorithm Step 2: q1 r0 q0 r1 q2

de Casteljau Algorithm Step 3: r0 • r1 p(t)=(x(t),y(t))

de Casteljau Algorithm Expanding this recursive formula gives:

de Casteljau Algorithm Collecting powers of t and simplifying, we get Note: p(0) = p0 and p(1) = p3, so this curve does go through the first and last control points, as was required.

Bezier Curve p1 • p(t) p0 p2 p3

Bernstein Polynomials The polynomials that appear as coefficients of the powers of t are called Bernstein Polynomials.

Bernstein Polynomials

Bernstein Polynomials B03(t) B33(t) B13(t) B23(t)

Bernstein Polynomials

Bernstein Polynomials Definition: The i-th Bernstein polynomial of degree n is defined as Note: If we add up all of the Bernstein polynomials of degree n, we always get 1, no matter what t is.

Bezier Curves Bernstein Formula for a Bezier curve of degree n:

Bezier Curves Bernstein Formula for a cubic Bezier curve:

Matrix Form of Bezier Curves So far we have looked at two methods for computing the Bezier curve: de Casteljau’s Algorithm and Bernstein Polynomials. Now, we will consider a third method, which is the most efficient method. This method involves matrix calculations. Recall the equations for the cubic Bezier curve:

Matrix Form of Bezier Curves If we re-group the terms, so that we have all multipliers of powers of t, we get:

Matrix Form of Bezier Curves

Matrix Form of Bezier Curves

Matrix Form of Bezier Curves

Matlab Function for Bezier Curves function p = bezier(t, p0, p1, p2, p3 ) % bezier computes the bezier curve value p(t) % defined by control points p0, p1, p2, p3 u=[t^3 t^2 t 1]; M = [-1, 3,-3, 1; 3,-6, 3, 0; -3, 3, 0, 0; 1, 0, 0, 0] C = [p0;p1;p2;p3] p=u*M*C end

Matlab Function for Bezier Curves function plot_bezier(p0,p1,p2,p3) %plot_bezier plots the bezier curve through the control % points p0, p1, p2, p3 tvector = 0.0:0.05:1; pts = zeros(length(tvector),2); for i = 1:length(tvector) pts(i,:) = bezier(tvector(i), p0, p1, p2, p3); end C = [p0;p1;p2;p3]; plot(C(:,1), C(:,2),'o',pts(:,1),pts(:,2),'-');

Matlab Function for Bezier Curves

Bezier Surfaces Bezier surfaces are an extension of Bezier curves to 3 dimensions Instead of the curve being parameterized by a single variable t, we use two variables, s and t By definition, we choose to have s and t range from 0 to 1 0,1 t 1,1 0,0 s 1,0

Control Mesh Consider a bicubic Bezier surface (bicubic means that it is a cubic function in both the s and t parameters) A cubic curve has 4 control points, and a bicubic surface has a grid of 16 control points, p0 through p15 p12 p13 p8 t p9 p14 p4 p5 p15 p0 p10 p1 p11 p6 s p7 p2 p3

Bernstein Polynomial Recall that for a Bezier curve we had a formula in terms of the Bernstein polynomials: It seems reasonable to define the Bezier surface in a similar fashion so that the surface is really a family of Bezier curves:

Matrix Form Recall that the matrix form for a Bezier curve is A parametric surface will have three component functions of s and t – one for each of the three dimensions: p(s,t) = (x(s,t), y(s,t), z(s,t))

Matrix Form To simplify the calculation of the parametric surface, we will consider the matrix equation for each of the x, y, and z components separately For example, to evaluate the x component of a Bezier curve, we have:

Matrix Form If we expand the Bernstein formula and isolate the x component of p(s,t) we will get (after a lot of arithmetic!)

Matrix Form

Matrix Form We would have similar formulas for y(s,t) and z(s,t). Notes: Cx stores the coefficients of the bicubic equation for x Gx stores the geometry (x components of the control points) BBez is the basis matrix (Bezier basis) s and t are the vectors formed from the exponents of s and t The matrix form can also take advantage of 4x4 matrix support which is built into modern computer graphics hardware

Programming Assignment Your Programming Assignment is to create two Matlab functions: bezier_surf(s,t,G) This will take two parameters s and t and a 4x4x3 matrix G and will return the vector p(s,t) = (x(s,t), y(s,t), z(s,t)) bezier_surf_plot(G) This will take one parameter – a 4x4x3 matrix G and will plot the Bezier surface defined by these points.

Programming Assignment To assist you in this work, I have included code on the lecture web page that shows how to input and work with a 4x4x3 matrix and gives an example you should use for the matrix G. It also shows what kind of output you should expect. The surface plot should look like the figure on the next page:

Programming Assignment