1 / 22

Interpolating Splines, Implicit Descriptions

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].

brant
Download Presentation

Interpolating Splines, Implicit Descriptions

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Interpolating Splines,Implicit Descriptions Glenn G. ChappellCHAPPELLG@member.ams.org U. of Alaska Fairbanks CS 481/681 Lecture Notes Friday, March 5, 2004

  2. Review:Bézier Algorithms [1/3] • The de Casteljau Algorithm computes a point on a Bézier curve using this repeated lirping procedure. • Each lirp is done using the same value of t. • x, y, and z are computed separately. P0 P1 P2 P3 P4 lirp lirp lirp lirp lirp lirp lirp lirp lirp lirp Point on curve CS 481/681

  3. Review:Bézier Algorithms [2/3] • Another way to draw a Bézier curve is to use the polynomial that describes it to compute coordinates of points. • If there are n control points (P0, P1, …, Pn–1), then a Bézier curve is parameterized by a polynomial of degree n–1. • For four control points the polynomial isP0·(1–t)3 + P1·3(1–t)2t +P2·3(1–t)t2 +P3·t3. • This is made up of pieces called Bernstein polynomials. • B30(t) = (1–t)3. • B31(t) = 3(1–t)2t. • B32(t) = 3(1–t)t2. • B33(t) = t3. • The pattern: • Descending powers of (1–t). • Ascending powers of t. • Coefficients are binomial coefficients. • Found in Pascal’s Triangle. CS 481/681

  4. Review:Bézier Algorithms [3/3] • The way we described Bézier 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·(1–t)2 + P0,1·2(1–t)t +P0,2·t2P1,0·(1–t)2 + P1,1·2(1–t)t +P1,2·t2P2,0·(1–t)2 + P2,1·2(1–t)t +P2,2·t2 • Now we use points on these curves as control points. Let our vertical parameter be s. We obtain the following formula for a Bézier patch:[ P0,0·(1–t)2 + P0,1·2(1–t)t +P0,2·t2 ]·(1–s)2 +[ P1,0·(1–t)2 + P1,1·2(1–t)t +P1,2·t2 ]·2(1–s)s +[ P2,0·(1–t)2 + P2,1·2(1–t)t +P2,2·t2 ]·s2 P0,0 P0,1 P0,2 P1,0 P1,1 P1,2 P2,0 P2,1 P2,2 CS 481/681

  5. Review:Bézier Properties [1/3] • Two properties of Bézier curves are worth another look: • Affine Invariance • Convex-Hull Property • An 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. • Bézier 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 Bézier curve, apply a rotation to the control points. • In short: Transformations act the way you want them to. CS 481/681

  6. Review:Bézier 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 Bézier 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. P0 P2 P0 P2 Points Convex hull P1 P1 P0 P2 P1 CS 481/681

  7. Review:Bézier Properties [3/3] • Bézier curves do not interpolate all their control points. • So we can easily specify where it does not go, but not where it does go. • Bézier 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 Bézier curve changes the whole curve. • This is the main reason we do not use Bézier curves with a large number of control points. • Instead, we piece together several 3- or 4-point Bézier curves in a smooth way. • This multiple-Bézier curve does have local control. CS 481/681

  8. Review:Building Better Curves • The biggest problems with Bézier 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

  9. Interpolating Splines:Overview • We 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 Curves • Interpolating splines that require a vector to be specified at each control point. • Cardinal Splines • Nearly to the goal, but there is a “tension” parameter. • Catmull-Rom Splines • The goal. CS 481/681

  10. 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 you’ll 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. vi Pi+1 Pi vi+1 CS 481/681

  11. 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. vi Pi+1 Pi vi+1 CS 481/681

  12. Interpolating Splines:Hermite Curves — Computations • Again, there is a unique cubic polynomialf(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 + C • Next figure out what the four constraints mean: • Pi = f(0) = D • Pi+1 = f(1) = A + B + C + D • vi = f (0) = C • vi+1 = f (1) = 3A + 2B + C • This gives a system of 4 linear equations in 4 variables (A, B, C, D). Solve to obtain: • A = 2Pi – 2Pi+1 + vi + vi+1 • B = –3Pi + 3Pi+1 – 2vi – vi+1 • C = vi • D = Pi CS 481/681

  13. Interpolating Splines:Hermite Curves — Code • The results: • A = 2Pi – 2Pi+1 + vi + vi+1 • B = –3Pi + 3Pi+1 – 2vi – vi+1 • C = vi • D = Pi • Here is some code using TRANSF: const int ncp; // Number of Control Points pos p[ncp]; // Array of control points vec v[ncp]; // Vector for each control point int i; // subscript, same as i above double 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

  14. Interpolating Splines:Hermite Curves — Notes • In 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? vi vi+2 Pi+1 Pi Pi+2 vi+1 CS 481/681

  15. Interpolating Splines:Cardinal Splines • Hermite 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. • Idea • Let vi be parallel to the vector from Pi–1 to Pi+1. • So vi = k(Pi+1 – Pi–1). • 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 vi Pi–1 Pi+1 CS 481/681

  16. 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. • Properties • Defined 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 can’t have everything. • Use the Hermite-curve code to draw it. CS 481/681

  17. Interpolating Splines:Hitting the Endpoints • One 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 don’t have a vector at the first & last points. • Solution • Instead 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

  18. Interpolating Splines:Surface Patches • We define a Catmull-Rom surface patch using the same ideas that we used to define a Bézier patch. • Start with a rectangular grid of control points. • Compute curves through each horizontal row of control points. • Use corresponding points on these curves as control points for vertical curves. • Put the vertical curves together to make the patch. • See the formula for a Bézier patch to get an idea of how the computation would look. CS 481/681

  19. Implicit Descriptions:Introduction • Recall, a surface can be defined using: • A Polygon List • An Explicit description • Formulas based on parameters. • An Implicit Description • Equations to be solved. • Spline curves & surfaces are a way to create easy-to-define explicit descriptions. • Now, we look at implicit descriptions. CS 481/681

  20. Implicit Descriptions:Why? • One problem with explicit descriptions is that they generally assume some kind of rectangular grid on a surface. • Can you put a rectangular grid on an arbitrary object? • What about a surface that can change topology? • Implicit descriptions do not have these problems. • Of course, they have other problems … CS 481/681

  21. Implicit Descriptions:What They Look Like [1/2] • Strictly speaking, an implicit description is an equation to be solved. • In practice, however, things look a bit different. • Typically, we specify “potential” values at various points in space. • We want to approximate the surface consisting of all points at a particular “threshold” value. • This is called an isosurface. • Thus, we want solutions to this equation:potential(x, y, z) = threshold_value • However, we do not define the potential everywhere, so it might not be clear exactly what we are approximating. CS 481/681

  22. Implicit Descriptions:What They Look Like [2/2] • Specifying potential values generally takes one of two forms: • Specify potentials at every point in a 3-D grid. • Specify potentials at a very limited set of points. • The former method is well studied, and somewhat reasonable algorithms exist to draw approximations of the surface. • The latter method is up-and-coming … • Time for a blackboard picture. CS 481/681

More Related