1 / 58

ICS 415 Computer Graphics B-Spline curves (Chapter 8)

ICS 415 Computer Graphics B-Spline curves (Chapter 8). Dr. Muhammed Al-Mulhem March 1, 2009. Better Blending Functions. Bezier curves do not provide enough flexibility in curve design. A Bezier curve based on L+1 control points is a combination of L-degree polynomials.

Download Presentation

ICS 415 Computer Graphics B-Spline curves (Chapter 8)

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. ICS 415Computer GraphicsB-Spline curves (Chapter 8) Dr. Muhammed Al-Mulhem March 1, 2009 Dr. Muhammed Al-Mulhem

  2. Better Blending Functions • Bezier curves do not provide enough flexibility in curve design. • A Bezier curve based on L+1 control points is a combination of L-degree polynomials. • High degree polynomials are expensive to compute, and are vulnerable to numerical round-off errors. • We want the designer to be free to use as many control points as desired, even 40 or more. Dr. Muhammed Al-Mulhem

  3. Better Blending Functions • Bezier curves do not offer enough local control of the curve shape. • The figure shows five control points used to fashion a Bezier curve (solid line), which deviates somewhat from the desired curve (dashed line) near t = 1. Dr. Muhammed Al-Mulhem

  4. Better Blending Functions • To correct this, the user would move P2 and P3 up somewhat to force the Bezier curve closer to the desired curve. • But this also affects the shape of the first half of the curve, forcing it away somewhat from the desired version. Dr. Muhammed Al-Mulhem

  5. Better Blending Functions • A change to any control point alters the entire curve. • This arises from the nature of Bernstein polynomials: each is “active” (non-zero) over the entire interval [0, 1]. • The interval over which a function is nonzero is often called its support. Because every Bernstein polynomial has support over the entire interval [0, 1], and the curve is a blend of these functions, each control point has an effect on the curve at all t-values between 0 and 1. • Therefore, adjusting any control point affects the shape of the curve everywhere, with no local control. Dr. Muhammed Al-Mulhem

  6. Better Blending Functions • The four cubic Bézier blending functions: Dr. Muhammed Al-Mulhem

  7. Better Blending Functions • Contrast the set of blending functions at right. • Six blending functions, R0(t), R1(t), ... , R5(t) are shown, each having support that is only a part of the interval [0, 1]. Dr. Muhammed Al-Mulhem

  8. Better Blending Functions • For instance, the support of R0(t) is [0, .25] and that of R3(t) is [.25, 1.0]. • At any value of t, no more than three of the blending functions are active. Dr. Muhammed Al-Mulhem

  9. Better Blending Functions • We use the blending functions to build a curve, V(t), based on six given control points, P0, P1, . . . , P5. • We use the same kind of parametric form as for Bezier curves: Dr. Muhammed Al-Mulhem

  10. Better Blending Functions • At each t the position V(t) depends on no more than three control points. • For all t in [0.75, 1.0] only the points P3, P4, and P5 control the shape of the curve. • If P4 is moved to P’4, only the dashed portion of the curve will change. • These blending functions give some local control to the control points. Dr. Muhammed Al-Mulhem

  11. Wish List for Blending Functions • The blending functions should: • be easy to compute and numerically stable; • sum to one at every t in [a,b]; • have small support to offer local control; • interpolate certain control points, chosen by the designer; • be smooth enough. Dr. Muhammed Al-Mulhem

  12. The functions should be easy to compute and numerically stable. • For rapid curve generation we want the blending functions to be computationally simple. • We also want them to be minimally affected by numerical round-off error. • Consequently, we choose polynomials for the blending functions; the degree of the polynomials should be fairly small. • Other kinds of functions, such as sines and cosines, would be too expensive to use. Dr. Muhammed Al-Mulhem

  13. The functions must sum to one at every t in [a, b]. • V(t) is a weighted sum of points at each t, and this makes sense only if it is an affine sum of points at every t in [a, b]. (Otherwise it is not a point.) Thus we insist that: Dr. Muhammed Al-Mulhem

  14. The functions should have small support for local control. • To achieve local control we want each blending function to be concentrated in t, having support over only a small portion of the interval [a, b]. Dr. Muhammed Al-Mulhem

  15. The functions should interpolate certain control points. • The designer may want V(t) to pass through some of the control points, but only be attracted towards others. • We will need to provide a mechanism that adjusts the blending functions so that certain control points are interpolated. Dr. Muhammed Al-Mulhem

  16. The functions should have sufficient smoothness. • The designer normally wants V(t) to be a smooth curve for any set of control points. • Typically V(t) should be at least 1-smooth, or even 2-smooth, to produce shapes of the desired smoothness. • The smoothness of V(t) depends on the smoothness of the blending functions. • Specifically, if every blending function is 1-smooth in [a, b], then V(t) will also be 1-smooth in [a, b]. Dr. Muhammed Al-Mulhem

  17. The functions should have sufficient smoothness. (2) • The derivative varies continuously from 0 at t = c, where the function starts. • But the derivative at d is discontinuous, jumping abruptly from A to 0. A curve using this blending function would not be 1-smooth at t = d. • Thus it is desirable for blending functions to be smooth internally, and also to start and end with derivatives of 0. Dr. Muhammed Al-Mulhem

  18. The functions should have sufficient smoothness. (3) • Some Rk start and stop with zero derivatives; others do not. • The shapes that begin and end inside [0, 1] do so with zero derivatives, so the curve V(t) will be 1-smooth inside (0,1). • The derivatives may be discontinuous at t = 0 or t = 1 because we never use values of t beyond 0 or 1. Dr. Muhammed Al-Mulhem

  19. Piecewise Polynomial Curves and Splines • There is no single cubic polynomial which can serve as a blending function. • Instead, we piece together several low-degree polynomials. • The curves are defined by different polynomials in different t-intervals and are called piecewise polynomials. Dr. Muhammed Al-Mulhem

  20. Piecewise Polynomial Curves and Splines (2) • The example shape, g(t), helps establish some nomenclature. • g(t) consists of three polynomial segments, defined as Dr. Muhammed Al-Mulhem

  21. Piecewise Polynomial Curves and Splines (3) • The support of g(t) is [0, 3]. • a(t) is defined on the span [0, 1], b(t) on the span [1, 2], and c(t) on the span [2, 3]. • The points where a pair of segments meet are called joints. • The values of t at the joints are called knots. • There are four knots in this example: 0, 1, 2, and 3. Dr. Muhammed Al-Mulhem

  22. Piecewise Polynomial Curves and Splines (4) • g(t) is continuous over its support; because it is built from polynomials, it is certainly continuous inside each span, and a(1) = b(1) = 1/2, and b(2) = c(2) = 1/2. • The derivative of g(t) is continuous everywhere: g(t) is 1-smooth in [0, 3]. • The derivative is continuous inside each span and a’(1) =b’(1) =1, b’(2) = c’(2) = -1. Dr. Muhammed Al-Mulhem

  23. Splines • The shape g(t) here is an example of a spline function, a piecewise polynomial function that is “smooth enough”. • Definition of a Spline Function: An Mth-degree spline function is a piecewise polynomial of degree M that is (M-1)-smooth at each knot. • The example g(t) is a quadratic spline: It is a piecewise polynomial of degree 2 and has a continuous first derivative everywhere. Dr. Muhammed Al-Mulhem

  24. Making Blending Functions from Splines • We use translated versions of g(t), where each blending function gk(t) is formed by translating the basic shape g(t) by a certain amount. • The figure shows seven blending functions g0(t),..,g6(t) formed by translating g(t) by integer amounts: gk(t) = g(t+k) for k = 0, 1, 2, … Dr. Muhammed Al-Mulhem

  25. Making Blending Functions from Splines (2) • Since the knots of the various versions of g(t) occur at integers, this is equivalent to translating; the knots of one curve then line up with knots of the next curve. • These translated versions will form a legitimate set of blending functions only if they add up exactly to 1 at every t. But they do for all t in [2, 7]. Dr. Muhammed Al-Mulhem

  26. Making Blending Functions from Splines (3) • The designer chooses 7 control points and generates the curve from • Only values of t between 2 and 7 can be used. In that range, exactly three of the blending functions are active at any value of t, so there is good local control of the curve’s shape. • In addition, at times t = 2, 3, .., and 7 only two of the functions are active and they both have value 0.5. Therefore, at these t-values V(t) will lie at the midpoint of the line between two of the control points. Dr. Muhammed Al-Mulhem

  27. Making Blending Functions from Splines: Example (4) Dr. Muhammed Al-Mulhem

  28. Properties of the Curve • The designer has some local control of the curve shape, because the interval of support for each blending function is limited to length 3. • The designer knows that the curve must pass through midpoints of the control polygon edges. So the algorithm has some intuitive geometric properties. • Because each blending function is 1-smooth, the whole curve is 1-smooth. • No control points on the curve are interpolated. • All polynomials are of degree two, so they are fast and stable to compute. The degree of the polynomials does not depend on the number of control points. The technique works for any number of control points. Dr. Muhammed Al-Mulhem

  29. More General Blending Functions • We need more control of the curve shape: it must bend more and be smoother than just 1-smooth. This suggests moving to cubic polynomials. • We also want the designer to be able to specify which control points are interpolated. • And we want a single algorithm that would encompass all of the design techniques described above — including Bezier curves. • So we want to develop more general families of blending functions that meet all the properties discussed in the earlier wish list. Dr. Muhammed Al-Mulhem

  30. More General Blending Functions (2) • We continue to use the same parametric form • based on L+1 control points and L+1 blending functions R0(t), ..., RL(t). • We also continue to use piecewise polynomials for the blending functions, but now they are defined on a more general sequence of knots, called the knot vector, T = [t0, t1, t2, …]. • Some knots might have the same value but are still given distinct names. Dr. Muhammed Al-Mulhem

  31. More General Blending Functions (3) • Each blending function Rk(t) is a piecewise polynomial that is zero up to time tk, is non-zero over several spans in the knot vector, and then returns to zero again. • We insist further that each Rk(t) be a spline function, so that it ensures a certain level of smoothness at all t in its support. Dr. Muhammed Al-Mulhem

  32. More General Blending Functions (4) • Given a knot vector, is there some family of blending functions that can be used to generate every possible spline curve that can be defined on that knot vector? • Such a family is called a basis for the splines, meaning that any spline curve whatsoever can be matched by the sum • by choosing the proper control points. Dr. Muhammed Al-Mulhem

  33. More General Blending Functions (5) • There are many such families, but there is one basis in particular whose blending functions have the smallest support and therefore offer the greatest local control. • These are the B-splines, the ‘B’ derived from the word basis. Dr. Muhammed Al-Mulhem

  34. B-Spline Basis Functions • There is a single recursive formula that defines all the B-spline functions of any order. • It is easy to implement in a program and is numerically well behaved. • Some other methods are more computationally efficient. Dr. Muhammed Al-Mulhem

  35. B-Spline Basis Functions (2) • Each B-spline function is based on polynomials of a certain order, m. • If m = 3, the polynomials will be of order 3 and thus of degree 2, and so they will be quadratic B-splines. • If the order is m = 4, the underlying polynomials will be of degree 3, or cubic. • These are the two most important cases, although the formulation allows us to construct B-splines of any order. Dr. Muhammed Al-Mulhem

  36. B-Spline Basis Functions (3) • It is useful to make the order of a B-spline function explicit in the notation, and so we denote the k-th B-spline blending function of order m by Nk,m(t). Dr. Muhammed Al-Mulhem

  37. B-Spline Basis Functions (4) • Summarizing the ingredients, we have • a knot vector T = (t0, t1, t2 . . . ) • (L+1) control points Pk • the order m of the B-spline functions • The B-spline function for k = 0, 1, …, L is given by Dr. Muhammed Al-Mulhem

  38. B-Spline Basis Functions (5) • To get things started, the first-order function must be defined. • It is simply the constant function 1 within its span: Dr. Muhammed Al-Mulhem

  39. B-Spline Basis Functions (6) • This set of functions automatically sums to one at every t, so it is legitimate to use them in forming combinations of points. • Code to calculate the B-spline basis functions recursively is given in your book. Dr. Muhammed Al-Mulhem

  40. Using Multiple Knots in the Knot Vector • Up to this point we have used only B-splines based on equispaced knots. By varying the spacing between knots, the curve designer acquires much greater control of the shape of the final curve. • A central question is what happens to the shapes of the blending functions when two knots are set very close to one another. Dr. Muhammed Al-Mulhem

  41. Using Multiple Knots in the Knot Vector (2) • The figure shows the situation when the knot vector is T = (0, 1, 2, 3, 3+ ε, 4+ ε, . . . ), where ε is a small positive number. Dr. Muhammed Al-Mulhem

  42. Using Multiple Knots in the Knot Vector (3) • The piece of each piecewise polynomial lying in the interval [3, 3+ ε] has become squeezed into a very narrow span. The blending functions are not translations of one another. • If ε = 0, this span will vanish altogether, and a multiple knot will occur at t = 3. • This knot is said to have a “multiplicity of 2.” Dr. Muhammed Al-Mulhem

  43. Using Multiple Knots in the Knot Vector (4) • Two of the linear B-splines are discontinuous, and the quadratic shapes have a discontinuous derivative at t = 3. • In general, an i-smooth curve is reduced to an (i-1)-smooth curve at the multiple knot value. The cubic B-spline curves are 1-smooth everywhere, but not 2-smooth at t = 3. • But if quadratic B-splines are used, the curve will interpolate control point P2 because the blending function N2,3(t) reaches value 1 at t = 3 and all the other blending functions are zero there. • In general, when t approaches a knot of multiplicity greater than one, there is a stronger attraction to the governing control point. Dr. Muhammed Al-Mulhem

  44. Using Multiple Knots in the Knot Vector (5) • Quadratic splines become discontinuous near a knot of multiplicity 3. Cubic splines exhibit a discontinuous derivative near a knot of multiplicity 3, but they also interpolate one of the control points. • By adjusting the multiplicity of each knot, the designer can change the shape of the curve in a predictable fashion. • Neither the equation nor the code need be altered when the knot vector contains multiple knots. As we mentioned, some of the denominators become zero, but the code automatically handles this situation, and no adjustments need be made. Dr. Muhammed Al-Mulhem

  45. Standard Knot Vector • The standard knot vector for a B-spline of order m begins and ends with a knot of multiplicity m and uses unit spacing for the remaining knots. • We start with an example and then see how it arises. Suppose there are eight control points and we want to use cubic (m = 4) B-splines. The standard knot vector turns out to be • T = (0, 0, 0, 0, 1, 2, 3, 4, 5, 5, 5, 5) Dr. Muhammed Al-Mulhem

  46. Standard Knot Vector (2) • Blending functions N0,4(t) and N7,4(t) are discontinuous and have a support of one unit span. • Only N3,4(t) and N4,4(t) have the usual span of four units. • The remaining blending functions have two or three unit spans, and their shapes become more distorted as they approach the first and last knots. Dr. Muhammed Al-Mulhem

  47. Standard Knot Vector (3) • The standard knot vector always ensures interpolation of the first and last control points. • The initial direction of the B-spline curve at t = 0 is along the first segment of the control polygon, and similarly for the final direction. • Note that a B-spline curve can cross itself when the control polygon does. Dr. Muhammed Al-Mulhem

  48. Standard Knot Vector (4) • The standard knot vector for (L+1) control points and order-m B-splines is described as follows • There are L+m+1 knots, denoted as t0, . . . ,tL+m. • The first m knots, t0, . . . , tm - 1, all share the value 0. (The first m blending functions start at t = 0.) • Knots tm, . . . , tL increase in increments of 1, from value 1 through value L - m+1. (The final blending function, NL,m(t), begins at tL = L - m + 1 and has a support of width 1.) • The final m knots, tL+1, . . . , tL+m, all equal L - m + 2. Dr. Muhammed Al-Mulhem

  49. Code for the Standard Knot Vector • void buildKnots (int m, int L, double knot[ ]) • { • // Build the standard knot vector for L+1 control points • // and B-splines of order m • int i; • if (L < (m - 1)) return; // too few control points • for (i = 0; i <= L + m; i++) • if (i < m) knot[i] = 0.0; • else if (i <= L) knot[i] = i - m + 1; // i is at least m here • else knot[i] = L - m + 2; // i exceeds L here • } Dr. Muhammed Al-Mulhem

  50. B-splines and Bezier Curves • Bezier curves are a special case of B-splines. This is so because the B-spline blending functions defined on the standard knot vector are in fact Bernstein polynomials when m = L + 1. That is, Nk,L+1(t) = BkL(t) for k = 0, . . . , L. • Note that by convention the upper parameter of B() is degree, while the second parameter of N() is order. Dr. Muhammed Al-Mulhem

More Related