Game Development Reference
In-Depth Information
13.6.1
Rules of the Game
Our spline is composed of n segments, denoted q 0 , q 1 , . . . , q n−1 . The ith
segment q i is a function that accepts a local parameter, named s i , which
is normalized to vary from 0 to 1 over the length of the segment. In other
words, for each segment there is a curve function q i (s i ) exactly like the
ones we studied in the first part of this chapter; the only differences are the
cosmetic renaming of the function from p to q i and the argument from t
to s i .
We use two different notations to refer to the entire spline. One way is
to just drop the subscripts from the notation above, so the function q (s)
refers to the entire spline, and the parameter s (without subscript) is a
global parameter. As s varies from 0 to n, the function q (s) traces out the
entire spline.
The composite function q (s) is very simple. Basically we take the integer
portion of s to get the index i, describing which segment we are on, and
then the fractional portion is used as s i and plugged into the segment q i .
So the first segment q 0 (s 0 ) defines the spline on the interval between q (0)
and q (1), the second segment defines the spline from q (1) to q (2), and so
on. More formally,
i = ⌊s⌋,
(select segment by using the floor function)
A composite curve with
a simple global
parameterization
s i = s − i,
(calculate local parameter)
q (s) = q i (s i ).
(evaluate segment)
Note that, given a particular value for s, we can unambiguously iden-
tify the point q (s) along the spline. However, a particular value of s i is
meaningful only within the context of segment i; this is emphasized by the
subscript.
If we are not concerned with the timing of our curve, then this notation
may be all we need. However, when defining an animation path, we usually
need a level of indirection. We introduce the notation p (t) to refer to the
final curve, a function that returns our position at a given “time” t. It's
just a different parameterization of the same curve; p (t) and q (s) trace out
the same shape, but the s and t values for a particular point along the path
are usually not be the same. We can parameterize the curve so that some
sections are traversed quickly and others more slowly. The range of s is
fixed by the number of knots, but we are free to assign the range of t, the
total duration of the curve, to anything we wish.
In general, we can define p (t) in terms of q (s) by creating a function that
maps a time value t to a parameter value s. When we want to be explicit
that s is a function of t, we use the notation s(t), and this function is called
the time-to-parameter function. If you're a computer programmer, you can
Search WWH ::




Custom Search