Polynomial Pieces
The most popular representations for curves in computer graphics are piecewise functions where each curve piece is represented by a polynomial. Piecewise linear representations (a line segment is a polynomial of order 1) are a special case of this. In this section, we look over the mathematics of the individual polynomial pieces. In the next section, we discuss how to put pieces of polynomials together.
Polynomials are functions of the form:
The degree of a polynomial is the highest power of the parameter. A polynomial of order 4 may be of degree 3, but it may be of a lower degree if
We can generalize the canonical form of Equation Equation 2 as:
While canonical form is sufficient for describing any polynomial, the coefficients are not necessarily convenient. Throughout this chapter, we will find sets of basis functions such that the coefficients are convenient ways to control the curves represented by the polynomial functions.
For specifying curves, we can either create a separate polynomial for each dimension of the curves’ embedding, or use a vector form of Equations like Equation Equation 3, where the coefficients are points. Note that even in such a case, the basis or blending functions still produce scalar values.
A Line Segment
To introduce the concepts of piecewise polynomial curve representations, we will discuss line segments. In practice, line segments are so simple that the mathematical derivations will seem excessive. However, by understanding this simple case, things will be easier when we move on to more complicated polynomials.
Consider a line segment that connects point to . We could write the parametric function over the unit domain for this line segment as:
The line that we specify is determined by the two end points.
but from now on we’ll stick to vector notation since its cleaner. We will call the vector of control parameters the control points, and each element of a control point.
While describing a line segment by the positions of its endpoints is obvious and usually convenient, there are other ways to describe a line segment. For example:
- the position of the center of the line segment, the orientation, and the length;
- the position of one endpoint and the position of the second point relative to the first;
- the position of the middle of the line segment and one end.
It should be fairly obvious that given one kind of a description of a line segment, we can switch to another.
A different way to describe a line segment is using the canonical form of the polynomial (as discussed in Section Polynomial Notation),
To write the canonical form in as a vector expression, we define a vector that is a vector of the powers of :
Equation Equation 8 describe a curve segment by the set of polynomial coefficients for the simple form of the polynomial. We call such a representation the canonical form. I will denote the parameters of the canonical form by .
While it is mathematically simple, canonical form is not always the most convenient way to specify curves. For example, we might prefer to specify a line segment by the positions of its endpoints. If we want to define to be the beginning of the segment (where the segment is when ) and to be the end of the line segment (where the line segment is at ), we can write:
Matrix Form for Polynomials
While this first example was easy easy enough to solve, for more complicated examples it will be easier to write Equation Equation 9 in the form:
We can solve Equation Equation 12 for by finding the inverse of This matrix we will call the basis matrix, and we will denote it by The basis matrix is very handy since it tells us how to convert between the convenient parameters and the canonical form and therefore gives us an easy way to evaluate the curve:
Another Example: Suppose we want to parameterize the line segment so that is the half-way point (), and is the ending point (). To derive the basis matrix for this parameterization:
Beyond Line Segments
Line segments are simple enough that the effort of finding a basis matrix is silly. However, it was good practice for curves of higher degree. First, let’s consider quadratics (curves of degree 2). The advantage of the canonical form (Equation Equation 2) is that it works for these more complicated curves, just by letting be a larger number.
A quadratic (a degree 2 polynomial) has 3 coefficients (it has order 3), , , and . These coefficients are not convenient for describing the shape of the curve. However, we can use the same basis matrix method to devise more convenient parameters. If we know the value of Equation Equation 2 becomes a linear equation in the parameters,and the linear algebra from the last section still works.
Suppose that we wanted to describe our curves by the position of the beginning (), middle2 (), and end (). Filling the appropriate values into Equation Equation 2:
There is one additional type of constraint (or parameter) that is sometimes convenient to specify: the derivative of the curve (with respect to its free parameter) at a particular value. Intuitively, the derivatives tell us how the curve is changing, so that the first derivative tells us what direction the curve is going, the second derivative tells us how quickly the curve is changing direction, etc. We will see examples of why it is useful to specify derivatives later.
For the quadratic,
For example, consider a case where we want to specify a quadratic curve segment by the position, first, and second derivative at its middle ().
Basis Matrices for Cubics
Cubic polynomials are popular in graphics (See Section Cubics). One reason is that the basis matrix is a matrix, which is something graphics people work with a lot. The derivations for the various forms of cubics are just like the derivations we’ve seen already in this section. We will work through one more example, for practice.
A very useful form of a cubic polynomial is the Hermite form, where we specify the position and 1st derivative at the beginning and end. That is,
Blending Functions
If we know the basis matrix () we can multiply it by the parameter vector () to get a vector of functions
Blending functions provide a nice abstraction for describing curves. Any type of curve that can be represented as a weighted linear combination of its control points, where those weights are computed as some arbitrary functions of the free parameter.
Another common term for blending function is basis function.
Interpolating Polynomials
In general, a polynomial of order can interpolate a set of values. If we are given a vector of values to interpolate, and a corresponding vector of sites, we can use the methods described in the previous sections to determine an by basis matrix, that would give us a function such that For any given vector we would need to set up and solve an by linear system. This would provide us with a set of basis functions that would perform interpolation so the interpolating function is:
These interpolating basis functions can be derived in other ways. One particularly elegant way to define them is the Lagrange Form.
Interpolating polynomials provide a mechanism for defining curves that interpolate a set of points. Figure Figure (See below) shows some examples. While it is possible to create a single polynomial to interpolate any number of points, we rarely use high order polynomials to represent curves in computer graphics. Instead, interpolating splines (piecewise polynomial functions) are preferred. Some reasons for this are considered in Section Cardinal.
Figure 1:
Interpolating polynomials through multiple points. Notice the extra wiggles and overshooting between points. In Figure (See below), the 6th point is added completely changing the shape of the curve due to the non-local nature of interpolating polynomials.Figure 2:
Interpolating Polynomial through 6 pointsFigure 3:
Interpolating Polynomial through 5 and 6 pointsExercises
For each of the following, find the constraint matrix, the basis matrix, and the blending functions. You should not invert matrices by hand - use a program such as MATLAB or OCTAVE (a free MATLAB-like system).
- A Line Segment: Parameterized with being 25% of the way along the segment (), and being 75% of the way.
- A Quadratic: Parameterized with being the position of the beginning point (), being the 1st derivative at the beginning point, and being the 2nd derivative at the beginning point.
- A Cubic: With its control points being positions that are equally spaced ( has has , has , and has ).
- A Quintic: (a degree 5 polynomial, so the matrices will be ) Where is the beginning position, is the beginning derivative, is the middle () position, is the 1st derivative at the middle, is the position at the end, and is the 1st derivative at the end.
- Lagrange Polynomials: The Lagrange Form (Equation Equation 33) can be used to represent the interpolating cubic of Excursive 3. Use it at several different parameter values to confirm that it does produce the same results as the basis functions derived in Excursive 3.
I am being very sloppy about whether vectors are row vectors or column vectors. In general, the sense of a vector should be obvious from its context, and I’ll skip all of the transpose symbols for vectors. ↩︎
Notice that this is the middle of the parameter space, which might not be the middle of the curve itself. ↩︎