Game Development Reference
In-Depth Information
think of p (t) as the public interface, and q (s) as an internal implementation
detail. We are engaging in a fundamental practice of computer science:
breaking down complexity by introducing a level of indirection.
With the above notation established, the basic game plan for evaluating
p (t) is as follows:
1. Map the time value t into a value of s by evaluating the time-to-
parameter function s(t).
2. Extract the integer portion of s as i, and the fractional portion as s i .
3. Evaluate the curve segment q i (s i ).
Of course, if we don't care about the timing of the spline (perhaps we only
care about its shape), then we have no need of the first step, and we can just
use the trivial mapping of s(t) = t. Unfortunately, due to space constraints,
this is precisely what we're going to do in this topic. We don't discuss the
subtleties of dealing with the timing.
With the assumption for now that s = t, the first step is trivial. The
second step is also easy, and we devoted the first part of this chapter to the
third step. So we really already know how to evaluate a spline; let's look
at how we might create one.
13.6.2 Knots
Think about the juncture between two segments. For the curve to be
continuous, clearly the ending point of one segment must be coincident with
the starting point of the next segment. ( Section 13.8 addresses additional
desirable criteria.) These shared control points that are interpolated by the
spline are called the knots of the spline. The knot at index i is denoted k i ,
and since there is one more knot than the number of segments, the knots
are numbered k 0 ... k n .
We assume that the segments are connected at the knots. In other
words, q (s) passes through the knots at integer values of s. With this as-
sumption, there's no need for separate notation (or separate storage space
in a computer program) for the beginning point and ending point of each
segment. Instead, each interior knot k i serves a dual role as the start-
ing point of segment q i and the ending point of segment q i−1 . Thus, we
establish the following relations:
q (i) = k i ,
q i (0) = k i ,
q i (1) = k i+1 .
Note that k i specifies a single point, whereas the notation q i refers to an
entire segment, which is a function of a local parameter s i that yields a
point. All of this notation is depicted in Figure 13.18.
Search WWH ::




Custom Search