1
$\begingroup$

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?

  • 0
    @J.M. OK so it is a 'real' problem requiring some approximation... I've taken the simple approach of using straight-line length between $\mathbf p_k$ & $\mathbf p_{k+1}$. If you want the points, submit your comment as an answer. – 2012-02-03

1 Answers 1

3

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)}$