Deriving custom cubic spline

335 Views Asked by At

A cubic Bezier curve can be expressed in the following form: $$P(t) = GBT(t) = \left[ {\begin{array}{*{20}{c}} {{P_1}}&{{P_2}}&{{P_3}}&{{P_4}} \end{array}} \right]\left[ {\begin{array}{*{20}{c}} 1&{ - 3}&3&{ - 1}\\ 0&3&{ - 6}&3\\ 0&0&3&{ - 3}\\ 0&0&0&1 \end{array}} \right]\left[ {\begin{array}{*{20}{c}} 1\\ t\\ {{t^2}}\\ {{t^3}} \end{array}} \right]$$where $G$ is a vector of $4$ control points, $B$ is a matrix of Bernstein polynomial coefficients and $T$ is a time vector.

The task is to derive the spline matrix (similar to $B$) for a cubic spline $P(t)$ that satisfies the following conditions:

  1. It interpolates the first control point ${P_1}$ at time $t = 0$.
  2. Its tangent $P'(t)$ at $t = 0$ matches $3 \cdot ({P_2} - {P_1})$ like a cubic Bezier curve.
  3. It interpolates the third and fourth control points such that $P(2/3) = {P_3}$ and $P(1) = {P_4}$.

I know that i have to use the constraints to construct a system of linear equations. However, i'm having problems with building such system.

1

There are 1 best solutions below

4
On BEST ANSWER

The general equation for a cubic curve is $at^3+bt^2+ct+d.$ Thus, we must simply equate our given information with this form, then solve the linear system for the coefficients. $$\begin{cases} P(0) = d = P_1\\ P'(0) = c = 3(P_2-P_1)\\ P\left(\frac23\right) = a\left(\frac23\right)^3+b\left(\frac23\right)^2+c\left(\frac23\right)+d=P_3&\\ P(1) = a+b+c+d=P_4\end{cases}$$

Can you construct the matrices and solve this the rest of the way?


It seems like your confused about the $P_1, P_2, \cdots$. These are just constants in the matrix, and should be treated exactly the same as you would treat any other constant. Your variables, which you are solving for, are $a, b, c, \text{ and } d$.

The matrix you end up with should be:

$$\begin{matrix}a & b & c & d& &&&&\\\end{matrix}\\ \left[\begin{array}{rrrr|r} 0 & 0 & 0 & 1 & P_1\\ 0 & 0 & 1 & 0 & 3(P_2-P_1)\\ \frac{8}{27} & \frac49 & \frac23 & 1 & P_3\\ 1 & 1 & 1 & 1 & P_4\\ \end{array}\right]$$