Surfaces of Revolution

text only
 
progress indicator progress indicator progress indicator progress indicator

Knot Vectors

In the previous section, I mentioned that there are two types of knot vectors, open and periodic, and that there are two flavors, uniform and nonuniform. I will explain these in more detail and show the basis functions they yield. I'll only show the final basis functions of degree k, but you can derive the lower-degree functions if you want. Each of the illustrations is a screenshot from the source code developed for this chapter. At the end of the chapter, I'll explain how you can use the code to visualize basis functions of any degree.

Open knot vectors yield basis functions that are most similar to those seen in the last chapter, so I'll start with them.

Open Knot Vectors

Open knot vectors are characterized as having k repeated knot values at the beginning and end of the vector. The rest of the vector can be either uniform or nonuniform. Note that it is possible to have the repeated values at the ends and still be considered a uniform knot vector. Some examples are shown next .

  • k = 3 [X] = [0 0 0 1 2 3 3 3] (uniform)

  • k = 4 [X] = [0 0 0 0 1 1 1 1] (uniform)

  • k = 3 [X] = [0 0 0 1 1 2 2 2] (nonuniform)

  • k = 2 [X] = [0 0 1 2 3 3 3 4 5 6 6] (nonuniform)

Multiple knot values at the ends ensure that the first and last points on the curve correspond to the first and last control points. They essentially pull the curve ends to the ends of the control polygon. This happens because the duplicate values effectively constrain the ranges of the first and last control points and increase their relative influence within those ranges. This also ensures that the slopes at the ends of the curve equal the slopes of the first and last sides of the control polygon. This gives them the same end conditions as Bezier curves and makes them easier to join with other curves.

Note 

The constraint given as Equation 4.2 will always be true when dealing with open knot vectors. You do not need to explicitly check for this.

In the last section, I showed that Bezier curves were just a special case of B-splines by using an open knot vector. If you want to define a cubic B-spline with only four points and you want the end conditions given by an open knot vector, you might as well just use a Bezier curve. The advantage of B-splines is that you can have many more control points and keep the end conditions, but still set your degree to something reasonable. For example, a Bezier curve with ten control points would yield a tenth-degree curve. The knot vector for an equivalent B-spline would be

  • [X] = [0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1]

A B-spline with ten control points could yield a cubic curve (k = 4) with the following knot vector.

  • [X] = [0 0 0 0 1 2 3 4 5 6 6 6 6]

There are several advantages. You have control over the degree of the curve and you also have more local control. Figure 4.8 shows the Bezier equivalent curve (k = 10) and the cubic (k = 4) B-spline for the same set of ten control points. Notice the level of local control.


Figure 4.8: Comparing Bezier and B-spline curves.

The primary reason for choosing to use an open knot vector is the fact that you can pull the curve to the end points of the control polygon. This is good for joining curves and it makes it trivial to find the end-points of the curve. But it can be a double-edged sword. Figure 4.9 shows the basis functions used to draw the B-spline in Figure 4.8.


Figure 4.9: Basis functions from Figure 4.8.

As you can see, each basis function curve is a little different. This has ramifications when joining curves or when you create closed shapes with B-splines. In those cases, it may be advantageous to have a set of basis functions that are all similar.

Periodic Knot Vectors

In Chapter 2, "Trigonometric Functions," I introduced the idea of periodic functions like sine and cosine. Those functions are periodic because each individual wave can be thought of as a translation of the same basic sinusoidal wave. Knot vectors are periodic if they yield periodic basis functions. For example, the following uniform periodic knot vector (k = 4, N = 10) yields the periodic basis functions shown in Figure 4.10.


Figure 4.10: Periodic basis functions.
  • [X] = [1 2 3 4 5 6 7 8 9 10 11 12 13 14]

Periodic knot vectors do not necessarily need to be uniform. Figure 4.11 shows the periodic basis functions given by the following nonuniform periodic knot vector (k = 4, N = 4). Although it might be difficult to see in Figure 4.11, each basis function is the same shape as the other, only some are shifted so that you can only see a portion of them.


Figure 4.11: Periodic basis functions.
  • [X] = [0 1 2 3 6 7 8 9]

Note 

I don't take advantage of this in the sample code for this chapter, but the fact that the basis functions are all of the same shape could lead to optimizations when you are computing the basis functions. If they are all the same shape, why not compute one and translate it instead of computing all of them? I leave it to the highly motivated reader to optimize accordingly .

Figures 4.10 and 4.11 reveal a potential problem with periodic knot vectors. Look near the ends of the parametric ranges. The sums of the basis functions are not equal to 1.0, as dictated by Equation 4.2. This means that Equation 4.7 will not produce valid curve points for the entire range of [0, 9]. You need to find the reduced range for which Equation 4.2 is true. Generally, the usable parametric range for a knot vector that starts at 0 is [x k , x N+1 ]. You can compute the reduced parametric range for a periodic knot vector with Equation 4.8.

(4.8) Parametric limits of the basis functions in Figure 4.12. 

Notice that the maximum value is less than 6 as opposed to less than or equal to 6. Once that is taken into account, the basis functions shown in Figure 4.11 produce the curve shown in Figure 4.12.


Figure 4.12: B-spline curve based on a periodic knot vector.

Figure 4.12 shows that the end points of the curve are nowhere near the endpoints of the control polygon. Also, the slope at the end of the curve is not the same as the slope of the last span of the control polygon. This could cause problems if you need to know where the end point is, but it does create interesting opportunities as well. I will address this again when I talk about closed shapes. There are ways to force the end points of a periodic curve to move to the end points of the control polygon (or anywhere else). Instead of talking about that specifically , this would be a good time to talk about spline manipulation in general.

progress indicator progress indicator progress indicator progress indicator


Focus on Curves and Surfaces
Focus On Curves and Surfaces (Focus on Game Development)
ISBN: 159200007X
EAN: 2147483647
Year: 2003
Pages: 104
Authors: Kelly Dempski

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net