Generating control-point tangents for a Catmull-Rom spline

3.2k Views Asked by At

From Wikipedia, we have a few variations for calculating tangents when creating a spline based only on positions of control-points:

Finite difference

$$\mathbf m_k=\frac{\mathbf p_{k+1}-\mathbf p_k}{2(t_{k+1}-t_k)}+\frac{\mathbf p_k-\mathbf p_{k-1}}{2(t_k-t_{k-1})}$$

Cardinal

$$\mathbf m_k=(1-c)\frac{\mathbf p_{k+1}-\mathbf p_{k-1}}{t_{k+1}-t_{k-1}}$$

Catmull–Rom

$$\mathbf m_k=\frac{\mathbf p_{k+1}-\mathbf p_{k-1}}{t_{k+1}-t_{k-1}}$$

In all cases, $\mathbf m_k$ is the tangent vector to control point $\mathbf p_k$ and $t_k$ is the parameter value $0 \leq t \leq 1$ for $\mathbf p_k$ on the spline.


The problem I have is, this method requires knowing $t_k$ to find $\mathbf m_k$. But you can't calculate $t_k$ until you know the lengths of each section of the spline, which in turn relies on knowing the tangent vectors.

Am I misunderstanding something basic, or does this chicken-and-egg situation really exist?

1

There are 1 best solutions below

0
On

The $t$ values are free variables. Within certain limits, you can use whatever values you like. The simplest choice is just $t_k=k$; in other words $t_k - t_{k-1} = 1$. This doesn't work very well unless the points are fairly equi-distant from each other. Another popular choice is to use chord-lengths: $t_k - t_{k-1} = dist(P_{k-1}, P_k)$. Yet another approach is the centripedal one: $t_k - t_{k-1} = \sqrt{dist(P_{k-1}, P_k)}$