In my never-ending quest to build intuition about the relationship between algebra and geometry, I have recently turned my attention once again to cubic curves. The basic question is this: what sorts of shapes can a given symbolic expression generate? In Chapter 4, “How Many Different Cubic Curves Are There?” and Chapter 6, “Cubic Curve Update,” of Jim Blinn's Corner: Dirty Pixels I asked this question about algebraic cubic curves of the form
Ax3+3Bx2y+3Cxy2+Dy3+3Ex2w+6Fxyw+3Gy2w?+3Hxw2+3fyw2+Kw3=0
I am now going to ask the same question about parametric cubic curves of the form
[x?(T)y?(T)w?(T)]=[T3T2T1]?[x3y3w3x2y2w2x1y1w1x0y0w0]
As an auxiliary question, I want to see which curve shapes can be generated both parametrically and algebraically. Many people have played around with this problem1,2, what follows is my own personal take on the subject. I found out a lot of things that surprised me at first, but when I thought about them, they became pretty obvious. I hope I can make them obvious to you, too.
The parametric formula includes cubic Bezier curves, cubic B-spline curves, and so on, but those curves usually only consider a segment of the curve between the parameter values 0 and 1. In this chapter, I want to think about the whole curve as generated by all possible values of T from minus infinity to plus infinity. This holistic approach is guaranteed to generate points at infinity for some value of T or other. Therefore, in order to really understand what's going on with cubic curves, we must be fluent with infinity, both geometric and parametric. This means that we will generalize concepts that use Euclidean coordinates [X Y] into those that use projective homogeneous coordinates [x y w], and we will generalize the parameter T to the homogeneous parameter [t s].
Our ultimate goal will be to transform an arbitrary parametric cubic curve both geometrically and parametrically to match one of a set of canonical simple algebraic forms. How many such forms are possible? It turns out that there are exactly three. In order to see this, we will need some basic tools. The most important of these is the ability to find and catalog the inflection points of a curve. That will be the primary focus of this chapter.
The main thing that a cubic curve can do, that lower-order curves cannot do, is have inflection points. What is an inflection point? Suppose you were driving a car along on the curve. An inflection point would be the place where you switch between “turning right” and “turning left.” Circles do not have inflection points. Sine curves have lots of them. We care about inflection points because they're preserved under perspective transformations. So two curves that differ only by a perspective transformation should have the same number of inflection points.
Algebraically, an inflection point occurs when the second derivative of the curve (the acceleration) is not, at time T, changing the direction of the first derivative (the tangent). See Figure 14.1. This occurs when the second derivative temporarily points in the same direction as the first derivative. A nonhomogeneous expression of this fact is
[˙X˙Y]=α?[¨X¨Y]
We don't really care what alpha is, so it's better to express our test as
˙X¨X=˙Y¨Y
or
˙X¨Y−¨X˙Y=det?[˙X˙Y¨X¨Y]=0
This determinant could also be zero, of course, if either the first or second derivative was itself zero. These locations aren't actually inflection points, but they will be useful special points to find, too.
We want to be able to deal fluidly with all possible points, both finite and infinite, so let's recast this in terms of homogeneous coordinates. For the X coordinate, our old friend the chain rule gives us
X=xw˙X=˙xw−x˙ww2¨X=(¨xw−x¨w)?w2−(˙xw−x˙w)?2w˙ww4
with similar expressions for Y. We can now write the 2×2 matrix in terms of homogeneous coordinates. Factoring out a few w's, we get
1w2[˙xw−x˙w˙yw−y˙w(¨xw−x¨w)−2?(˙xw−x˙w)˙ww(¨yw−y¨w)−2?(˙yw−y˙w)˙ww]
Look at the mess on the second row and imagine what will happen to it as you take the determinant. You can see that the −2 (stuff) terms will cancel out. This leaves us with the much prettier
det?[˙X˙Y¨X¨Y]=1w2det?[˙xw−x˙w˙yw−y˙w¨xw−x¨w¨yw−y¨w]
If you multiply out all the terms in this determinant and look at the result, you'll see a pattern. Several terms will cancel out and you will be left with six terms. A little thought and imagination, which I'll leave in your capable hands, will show that the inflection point-sensing determinant is equivalent to
det?[˙xw−x˙w˙yw−y˙w¨xw−x¨w¨yw−y¨w]=w?det?[xyw˙x˙y˙w¨x¨y¨w]=0
I claimed that a circle has no inflection points. More generally, no conic sections have inflection points. Let's see why by applying Equation (14.1) to a canonical second-order curve whose matrix representation looks like
[xyw]=[T2T1]?[x2y2w2x1y1w1x0y0w0]
To get the first and second derivatives of x, y, and w, you only need to differentiate the T row vector and conclude that
[xyw˙x˙y˙w¨x¨y¨w]=[T2T12T10200]?[x2y2w2x1y1w1x0y0w0]
Since the determinant of a product equals the product of the determinants, we have
det?[xyw˙x˙y˙w¨x¨y¨w]=det?[T2T12T10200]⋅det?[x2y2w2x1y1w1x0y0w0]=−2det?[x2y2w2x1y1w1x0y0w0]
All the T's canceled out. What does this mean? It means that the magic determinant is zero only if the coefficient matrix is singular, independent of T. A singular coefficient matrix means that the curve is degenerate; it's something like a circle squashed flat into a line segment. In this case, the tangent and second derivative point in the same direction along the whole curve. A nonsingular matrix, on the other hand, generates a full-fledged conic section. The magic determinant is never zero and therefore conic sections do not have inflection points.
Now let's bump up to third-order curves and see what we can find out. Here we have
[xyw˙x˙y˙w¨x¨y¨w]=[T3T2T13T22T106T200]?[x3y3w3x2y2w2x1y1w1x0y0w0]
What can we say about the determinant of this quantity? At first, it looks pretty scary. The final 3×3 matrix will have T-cubed terms on the top row, T-squared terms on the second row, and T terms on the bottom row. The determinant of this mess might potentially be sixth order in T. Eeeuw.
What was nice in the second-order discussion was that we could separately evaluate the part containing T and the part containing the polynomial coefficients because the determinant of the product of two matrices equals the product of their determinants. We can't take the determinants of the two matrices here since they aren't square. But we can do something similar. To introduce it, I'll start by dropping down a dimension and examine the product of a 2×3 matrix and a 3×2 matrix.
Let's look at the determinant of the simpler quantity
det?([P1P2P3Q1Q2Q3]??[R1S1R2S2R3S3])
This notation makes it easy to think of the rows of the first matrix as two 3-vectors, P and Q, and think of the columns of the second matrix as two 3-vectors, R and S. The matrix product is then
[P?⋅?RP?⋅?SQ?⋅?RQ?⋅?S]
and the determinant in question is
det??[P?⋅?RP?⋅?SQ?⋅?RQ?⋅?S]??=??(P?⋅?R)?(?Q?⋅?S?)?−?(P?⋅?S)?(Q?⋅?R)
When I first started playing with this, I multiplied everything out, took the determinant, and stared at the result for a while. A pattern began to emerge. The pattern I saw can be neatly summed up in the vector algebraic identity:
?(P?⋅?R)?(?Q?⋅?S?)?−?(P?⋅?S)?(Q?⋅?R?)?=?(R×S)?⋅?(P×Q)
Upon further thought, I realized that this is just an expression of what is called the epsilon-delta rule. I expounded on this at length in Chapters 9 and 10, “Uppers and Downers” (Parts I and II) of Jim Blinn's Corner: Dirty Pixels. As desired, it allows us to turn the determinant of a matrix product into the product of two (almost) determinants (if you think of a cross product as a close relative of a determinant).
Now let's step up to the more heady world of 3×4 and 4×3 matrices. There is a 4D version of the epsilon-delta rule that uses a 4D analog to the cross product. The 4D cross product (which I'll call “crs4”) takes three 4-vectors and generates a 4-vector that is perpendicular to each of them. You calculate the elements of this result by taking four determinants of three 3×3 matrices as follows:
crs4?([x3x2x1x0])?,?[y3y2y1y0]?,?[w3w2w1w0]?=?[D3D2D1D0]
where
D3?=?det?[x2y2w2x1y1w1x0y0w0]?,?D2?=?−?det?[x3y3w3x1y1w1x0y0w0]?,D1?=?det?[x3y3w3x2y2w2x0y0w0]?,?D0?=?−?det?[x3y3w3x2y2w2x1y1w1]?,
In 3D, the cross product is perpendicular (has zero dot product) with the two input vectors. Similarly, the 4D cross product satisfies
[D3D2D1D0]??[x3y3w3x2y2w2x1y1w1x0y0w0]?=?[000]
Note that the crs4 of three column vectors is a row vector. Similarly, the crs4 of three row vectors will be a column vector.
Let's give names to each row of the 3×4 matrix and to each column of the 4×3 matrix. The 4D epsilon-delta rule can be written in this form as
det?([…A……B……C…]??[⋮⋮⋮XYW⋮⋮⋮])?=?crs4??(X,?Y,?W)?⋅?crs4??(A,?B,?C)
In other words, the determinant of the matrix product is the dot product of the two 4D cross products. Again, I discussed this identity more fully in “Uppers and Downers.”
Let's see what this tells us about the inflection points on the curve represented by the coefficient matrix. Our inflection point–finding determinant is
det?[xyw˙x˙y˙w¨x¨y¨w]??=??det?([T3T2T13T22T106T200]??[x3y3w3x2y2w2x1y1w1x0y0w0])
We can now separately evaluate the crs4 of the T matrix to get
crs4??[T3T2T13T22T106T200]??=??[−26T−6T22T3]
(I'll throw out the homogeneous factor of 2 from here on.) Next, the crs4 of the coefficient matrix will be just the 4-element row of numbers [D3D2D1D0] from Equation (14.2). We really can't say more about their values than that—they depend on what we were given for the coefficient matrix. The net result, then, is that an inflection point exists for each value of T that satisfies
[D3D2D1D0]???[−13T−3T2T3]??=??D0T3−3D1T2+3D2T−D3=0
This is only third order in T rather than sixth order, as we originally feared. All the higher-order terms have conveniently canceled out.
What does this mean? Since an inflection point lies at the solution of a cubic polynomial, the inflection point count does all the things that roots of cubic equations can do. The five possibilities appear in Table 14.1.
Table 14.1
Five different root structures of cubic equations
Three distinct roots. | |
This means three distinct inflection points. | |
One distinct and two equal roots. | |
We'll see that the two equal roots do not make an inflection point, but rather a cusp. | |
One root | |
This corresponding to one inflection point. | |
A triple root. | |
(Or, if the triple root is at infinity, the cubic polynomial can look like a nonzero constant.) This occurs if the cubic curve is really a quadratic curve in disguise, for example, if the cubic coefficients are zero: [x3y3w3]=[000]. That will mean that the crs4 of the coefficient matrix will have D2=D1=D0=0. Equation (14.3) then boils down to −D3=0 and no inflection points exist. | |
The polynomial can be identically zero. | |
This happens if all four of the Di values are zero. This means that the curve is a first-order curve (a line) or a zeroth-order curve (a single point) in disguise. |
The epsilon-delta trick also gives us a quickie demonstration of the slightly surprising fact that, if three inflection points exist, then they must be collinear, as they are in Figure 14.2.
Suppose we have three solutions to the inflection point equation, T0, T1, T2. Then the locations of the three inflection points I0, I1, I2, stacked up into a matrix would be
[T03T01T01T13T12T11T13T22T21][x3y3w3x2y2w2x1y1w1x0y0w0]=[…I0……I1……I2…]
The condition that the three inflection points are collinear is that the determinant of the I matrix is zero. Look familiar? It's just the same situation as before. The determinant of the I matrix equals the dot product of the crs4 of the other two. We already know the crs4 of the coefficient matrix; it's [D3D2D1D0]. What is the crs4 of the matrix of T's? We could start taking 3×3 determinants and end up with a big mess of T0's, T1's, and T2's to various powers, but it turns out we already know the answer. The crs4 is just a vector that is perpendicular to each row of the T matrix. Since the Ti's are solutions to Equation (14.3), we know that
[T03T01T01T13T12T11T13T22T21]?[D0−3D13D2−D3]=[000]
So we can evaluate the I determinant as a 4-vector dot product and find that it is identically zero:
det[…I0……I1……I2…]=[D3D2D1D0]?[D0−3D13D2−D3]=0
So the three inflection points are indeed collinear.
There is one more thing we need to do. Consider the following curve equation, which happens to be the one that generated Figure 14.2:
[xyw]=[T3T2T1]?[001100001010]
Now take the crs4 of the coefficient matrix and plug it into Equation (14.3) and you get
[10−10]?[−13T−3T2T3]=−1+3T2=0
Fine. Two roots. What happened to the third inflection point? We can see three inflection points staring at us in Figure 14.2. Well … one of them is hidden at the parameter value T = ∞. This will happen for any curves that have D0 = 0. How can we avoid missing such points? We handle infinite parameter values the same way we handle infinite geometric values, with homogeneous coordinates. Write the parameter T as a 1D homogeneous coordinate t/s=T so that
[T3T2T1]=[t3s3t2s2ts1]=1s2?[t3st2s2ts3]
Toss out the common homogeneous factor of 1/s3, and our homogeneous parametric curve definition is
[xyw]=[t3st2s2ts3]?[x3y3w3x2y2w2x1y1w1x0y0w0]
How does this affect our location of inflection points? It just turns Equation (14.3) into
[D3D2D1D0]?[−s33s2t−3st2t3]=D0t3−3D1st2+3D2s2t−D3s3=0
In our problem case, Equation (14.4) becomes
[10−10]?[−s33s2t−3st2t3]=−s3+3st2=s(√3t+s)?(√3t−s)=0
The three inflection points are, then, at the homogeneous parameters
[t,?s]=[1,0],[1,−√3],[1,√3]
The solution with s = 0 represents the inflection point at T=t/s=∞.
The epsilon-delta rule lets us separate the algebra of the various derivatives of the parameters (which doesn't change from one curve to another) from the algebra on the polynomial coefficients (which does change). In the next chapter, armed with these tools, we'll tackle the problem of transforming an arbitrary parametric cubic to make its coefficient matrix have as many zeros as possible. We'll then look at how many patterns of nonzero elements remain and see what sorts of basic curve shapes are possible.
3.144.110.91