2
$\begingroup$

I was not sure whether this is a computer science question or a math question, so I posted it here, hope that it is alright.

I am trying to learn the technique of Hermite interpolation. I do understand that it is a generalization of Newton polynomial interpolation, which also considers derivatives to ensure continuity of the interpolated curve at the provided points.

In the book Computer Animation — Algorithms and Techniques by Rick Parent, there is a definition of Hermite interpolation that looks like this:

Hermite interpolation generates a cubic polynomial from one point to another. In addition to specifying the beginning and ending points $(P_i,P_{i+1})$, the user needs to supply beginning and ending tangent vectors $(P'_i,P'_{i+1})$ as well.

Here, just the first derivatives are considered, and the aim is to find a polynomial of degree 3 by finding appropriate coefficients $a_3,a_2,a_1,a_0$ such that we have $a_3x^3 + a_2x^2 + a_1x + a_0$. These are found by solving a system of linear equations. So far, so good.

Now, in the book, the matrices look like this:

The general matrix form for a curve is $P(u) = U^TMB$. In the case of Hermite interpolation, $$ U^T = \begin{bmatrix} u^3 & u^2 & u & 1 \end{bmatrix} \\ M = \begin{bmatrix} 2 & -2 & 1 & 1 \\ -3 & 3 & -2 & -1 \\ 0 & 0 & 1 & 0 \\ 1 & 0 & 0 & 0 \end{bmatrix} \\ B = \begin{bmatrix} P_i \\ P_{i+1} \\ P'_i \\ P'_{i+1} \end{bmatrix} $$

I do not understand the matrix $M$, I do not see where the values are coming from. Are these fixed, or can I somehow compute them?

$\endgroup$
1
  • 1
    $\begingroup$ @Yuval Filmus : thank you for taking the time to edit my post and replacing the pictures I took with this nice looking format. It is better this way and I will do so myself for my future posts $\endgroup$
    – sschimper
    Commented Jan 30, 2021 at 10:53

1 Answer 1

2
$\begingroup$

We are looking for a curve $$ P(u) = a_3 u^3 + a_2 u^2 + a_1 u + a_0 $$ which satisfies the following properties:

  1. $P(0) = P_i$.
  2. $P(1) = P_{i+1}$.
  3. $P'(0) = P'_i$.
  4. $P'(1) = P'_{i+1}$.

In terms of the coefficients $a_0,a_1,a_2,a_3$, these are:

  1. $a_0 = P_i$.
  2. $a_3 + a_2 + a_1 + a_0 = P_{i+1}$.
  3. $a_1 = P'_i$.
  4. $3a_3 + 2a_2 + a_1 = P'_{i+1}$.

In matrix form, this reads: $$ \begin{pmatrix} P_i \\ P_{i+1} \\ P'_i \\ P'_{i+1} \end{pmatrix} = \begin{pmatrix} 0 & 0 & 0 & 1 \\ 1 & 1 & 1 & 1 \\ 0 & 0 & 1 & 0 \\ 3 & 2 & 1 & 0 \end{pmatrix} \begin{pmatrix} a_3 \\ a_2 \\ a_1 \\ a_0 \end{pmatrix} $$ Inverting the matrix, we get $$ \begin{pmatrix} a_3 \\ a_2 \\ a_1 \\ a_0 \end{pmatrix} = \begin{pmatrix} 2 & -2 & 1 & 1 \\ -3 & 3 & -2 & -1 \\ 0 & 0 & 1 & 0 \\ 1 & 0 & 0 & 0 \end{pmatrix} \begin{pmatrix} P_i \\ P_{i+1} \\ P'_i \\ P'_{i+1} \end{pmatrix} $$ Therefore the equation of the curve is $$ P(u) = \begin{pmatrix} u^3 & u^2 & u & 1 \end{pmatrix} \begin{pmatrix} a_3 \\ a_2 \\ a_1 \\ a_0 \end{pmatrix} = \begin{pmatrix} u^3 & u^2 & u & 1 \end{pmatrix} \begin{pmatrix} 2 & -2 & 1 & 1 \\ -3 & 3 & -2 & -1 \\ 0 & 0 & 1 & 0 \\ 1 & 0 & 0 & 0 \end{pmatrix} \begin{pmatrix} P_i \\ P_{i+1} \\ P'_i \\ P'_{i+1} \end{pmatrix} $$

$\endgroup$
1
  • $\begingroup$ thank you very much. Your answer is very helpful. I see it now. Have a nice day! :) $\endgroup$
    – sschimper
    Commented Jan 30, 2021 at 10:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.