• date post

19-Mar-2016
• Category

## Documents

• view

33

0

TAGS:

• #### 01t2 p0

Embed Size (px)

description

Interpolating Splines, Implicit Descriptions. Glenn G. Chappell CHAPPELLG@member.ams.org U. of Alaska Fairbanks CS 481/681 Lecture Notes Friday, March 5, 2004. Review: Bézier Algorithms [1/3]. - PowerPoint PPT Presentation

### Transcript of Interpolating Splines, Implicit Descriptions

• Interpolating Splines,Implicit DescriptionsGlenn G. Chappell CHAPPELLG@member.ams.orgU. of Alaska Fairbanks

CS 481/681 Lecture NotesFriday, March 5, 2004

CS 481/681

• Review:Bzier Algorithms [1/3]The de Casteljau Algorithm computes a point on a Bzier curve using this repeated lirping procedure.

Each lirp is done using the same value of t.x, y, and z are computed separately.lirplirplirplirplirplirplirplirplirplirpP0P1P2P3P4Point on curve

CS 481/681

• Review:Bzier Algorithms [2/3]Another way to draw a Bzier curve is to use the polynomial that describes it to compute coordinates of points.If there are n control points (P0, P1, , Pn1), then a Bzier curve is parameterized by a polynomial of degree n1. For four control points the polynomial is P0(1t)3 + P13(1t)2t + P23(1t)t2 + P3t3.This is made up of pieces called Bernstein polynomials.B30(t) = (1t)3.B31(t) = 3(1t)2t.B32(t) = 3(1t)t2.B33(t) = t3.The pattern:Descending powers of (1t).Ascending powers of t.Coefficients are binomial coefficients. Found in Pascals Triangle.

CS 481/681

• Review:Bzier Algorithms [3/3]The way we described Bzier surfaces last time suggests how to extend curve-drawing algorithms to surfaces.Say we have a grid of 9 control points, as shown.The horizontal curves have the following formulas: P0,0(1t)2 + P0,12(1t)t + P0,2t2 P1,0(1t)2 + P1,12(1t)t + P1,2t2 P2,0(1t)2 + P2,12(1t)t + P2,2t2 Now we use points on these curves as control points. Let our vertical parameter be s. We obtain the following formula for a Bzier patch: [ P0,0(1t)2 + P0,12(1t)t + P0,2t2 ](1s)2 + [ P1,0(1t)2 + P1,12(1t)t + P1,2t2 ]2(1s)s + [ P2,0(1t)2 + P2,12(1t)t + P2,2t2 ]s2P0,0P0,1P0,2P1,0P1,1P1,2P2,0P2,1P2,2

CS 481/681

• Review:Bzier Properties [1/3]Two properties of Bzier curves are worth another look:Affine InvarianceConvex-Hull PropertyAn affine transformation is a transformation that can be produced by doing a linear transformation followed by a translation.All of the transformations we have dealt with, except for perspective projection, are affine.Bzier curves have the property that applying an affine transformation to each control points results in the same transformation being applied to every point on the curve.This property is called affine invariance.For example, to rotate a Bzier curve, apply a rotation to the control points.In short: Transformations act the way you want them to.

CS 481/681

• Review:Bzier Properties [2/3]The convex hull of a set of points is the smallest convex region containing them.Informally speaking, lasso (or shrink-wrap) the points; the region inside the lasso is the convex hull.

A Bzier curve lies entirely in the convex hull of its control points.This is called the convex-hull property.This property makes it easy to specify where a curve will not go.Smooth interpolating splines never have this property.P1P0P2P1P0P2PointsConvex hullP1P0P2

CS 481/681

• Review:Bzier Properties [3/3]Bzier curves do not interpolate all their control points.So we can easily specify where it does not go, but not where it does go.Bzier curves also do not have local control.A curve has local control if moving a single control point only changes a small part of the curve (the part near the control point).Moving any control point on a Bzier curve changes the whole curve.This is the main reason we do not use Bzier curves with a large number of control points.Instead, we piece together several 3- or 4-point Bzier curves in a smooth way.This multiple-Bzier curve does have local control.

CS 481/681

• Review:Building Better CurvesThe biggest problems with Bzier curves are:Lack of local control.High degree, if there are a large number of control points.Lack of interpolation (sometimes a problem, sometimes not).Better curve #1: B-spline.Parametric curve described by polynomials based on control points.Has affine invariance & local control.Has same degree regardless of number of control points.Approximating, has convex-hull property.Better curve #2: Catmull-Rom spline.Parametric curve described by polynomials based on control points.Has affine invariance & local control.Has same degree (3) regardless of number of control points.Interpolating, no convex-hull property, (and a bit tough to get just right).Better curve #3: NURBS (Non-Uniform Rational B-Spline).Parametric curve described by rational functions based on control points.Has affine invariance & local control.Very general & adaptable, but thus somewhat tougher to use.Built into GLU.

CS 481/681

• Interpolating Splines:OverviewWe would like to define an interpolating spline with lots of convenient properties.We can get pretty much all the good properties, except for the convex-hull property. Remember that smooth, interpolating splines never have this property.Some interpolating splines require additional information, besides their control points. Our goal is not to require this.Our goal is called a Catmull-Rom spline. We will reach this goal in three steps.Hermite CurvesInterpolating splines that require a vector to be specified at each control point.Cardinal SplinesNearly to the goal, but there is a tension parameter.Catmull-Rom SplinesThe goal.

CS 481/681

• Interpolating Splines:Hermite Curves Idea [1/2]The first step toward our goal is an Hermite curve.French again. Say air-MEET. Clear your throat a little during the r, and youll have it perfect.An Hermite curve is an interpolating spline whose formulas are cubic (degree 3) polynomials.We look at the segment between two control points: Pi and Pi+1.At each control point, we specify a velocity (or direction) vector.Call the vectors vi and vi+1.Pi+1Pivivi+1

CS 481/681

• Interpolating Splines:Hermite Curves Idea [2/2]

It turns out that there is a unique cubic polynomial that meets the following four constraints:At t = 0, its value is Pi.At t = 1, its value is Pi+1.At t = 0, its derivative is vi.At t = 1, its derivative is vi+1.Remember that the value of this polynomial is a point in space.So it will have the form f(t) = At3 + Bt2 + Ct + D, where A, B, C, and D are points/vectors.Pi+1Pivivi+1

CS 481/681

• Interpolating Splines:Hermite Curves ComputationsAgain, there is a unique cubic polynomial f(t) = At3 + Bt2 + Ct + D that meets the following four constraints:At t = 0, its value is Pi.At t = 1, its value is Pi+1.At t = 0, its derivative is vi.At t = 1, its derivative is vi+1.How do we find it? First, find the derivative:f (t) = 3At2 + 2Bt + CNext figure out what the four constraints mean:Pi = f(0) = DPi+1 = f(1) = A + B + C + Dvi = f (0) = Cvi+1 = f (1) = 3A + 2B + CThis gives a system of 4 linear equations in 4 variables (A, B, C, D). Solve to obtain:A = 2Pi 2Pi+1 + vi + vi+1B = 3Pi + 3Pi+1 2vi vi+1C = viD = Pi

CS 481/681

• Interpolating Splines:Hermite Curves CodeThe results:A = 2Pi 2Pi+1 + vi + vi+1B = 3Pi + 3Pi+1 2vi vi+1C = viD = PiHere is some code using TRANSF:

const int ncp; // Number of Control Pointspos p[ncp]; // Array of control pointsvec v[ncp]; // Vector for each control pointint i; // subscript, same as i abovedouble t; // parameter value, in [0,1]

vec A = 2.*(p[i] p[i+1]) + v[i] + v[i+1];vec B = -3.*(p[i] p[i+1]) 2*v[i] v[i+1];vec C = v[i];pos D = p[i];pos point_on_hermite_curve = t*t*t*A + t*t*B + t*C + D;

CS 481/681

• Interpolating Splines:Hermite Curves NotesIn practice, Hermite curve segments join to make a smooth curve.

Hermite curves are relatively common.Whenever you see an interpolating curve with direction handles on the control points, you are probably dealing with an Hermite curve.Why did we use cubic polynomials?

Pi+1Pivivi+1Pi+2vi+2

CS 481/681

• Interpolating Splines:Cardinal SplinesHermite curves fall short of our goal, since they require direction vectors to be specified.If we can compute these vectors automatically, based on the control points, then we can meet our goal using Hermite curves.IdeaLet vi be parallel to the vector from Pi1 to Pi+1.

So vi = k(Pi+1 Pi1).The value k is called the tension.The tension can be whatever you want, but usually it is between 0 and 1.Tension 0 makes a polyline.Problem: We cannot define the first & last curve segments.We address this later.Pi+1Pi1Pivi

CS 481/681

• Interpolating Splines:Catmull-Rom Splines (The Goal)Suppose the control points of a cardinal spline are equally spaced along a straight line. What should the tension be?k = seems natural, since it makes the speed constant.A cardinal spline with tension is called a Catmull-Rom spline.PropertiesDefined entirely in terms of control points.Can use any number of control points; always defined by cubic polynomials.Interpolating.Smooth.Local control.Affine invariant.NO convex-hull property, but you cant have everything.Use the Hermite-curve code to draw it.

CS 481/681

• Interpolating Splines:Hitting the EndpointsOne small problem with a Catmull-Rom spline is that we cannot hit the first and last control points (unless they lie in a loop).Each segment needs 4 constraints.Normally, these are the two positions and the two vectors.But we dont have a vector at the first & last points.SolutionInstead of constraining f to be a certain velocity vector, use the constraint f (0) = 0 or f (1) = 0 at the endpoints.Then solve the system again.Then, given any list of control points, we have a uniquely defined curve passing through all of them, in order.There are any number of other proposed variations on the cardinal spline, higher-degree versions, etc.

CS 481/681

• Interpolating Splines:Surface PatchesWe define a Catmull-Rom surface patch using the same ideas that we used to define a Bzier patch.Start with a rectan