2
$\begingroup$

I'm working on a program which uses Kochanek-Bartels ("TCB") splines.

My question is: How do I deal with the first/last points of the spline?

This type of spline needs a 'previous' and 'next' point at each node to generate the curve tangents, but the first and last points on the curve don't have them. How do graphics programs deal with this problem?

$\endgroup$

1 Answer 1

0
$\begingroup$

There are a couple different approaches to endpoint interpolation with splines.

One way is to add an additional point to either end of the curve, which is not part of the original data set. Moving this invisible "guide" point around will change the shape of the end segments of the curve. So, if you have $n$ actual data points, you'd use $n+2$ points for the spline interpolation, with $2$ "guide" points. (Note that you would have the curve itself not pass through these guide points, but just use them for tangent calculations.)

Another way is to take a one-sided difference. This, in a sense, "clamps" the calculation within the boundaries of the data set. For example, with an equation like this: $$p_i-p_{i-1}+p_{i+1}$$ For the $n=0$ case, you can just take $$p_0-p_0+p_1$$ By replacing out-of-bounds points with a boundary point. Similarly, for $i=n$, we get $p_n-p_{n-1}+p_n$.

This means any $i-1$ is calculated as $\max(i-1,0)$ and $i+1$ is $\min(i+1,n)$, for points $p_0,p_1,\dots,p_n$.

I've found that a one-sided difference tends to give visually reasonable results and doesn't require choosing any "guide" points.

$\endgroup$
2
  • $\begingroup$ I was looking for a way to generate them algorithmically, but I guess there really isn't one. $\endgroup$ Commented Aug 25 at 17:03
  • $\begingroup$ @ChiftiSaidi What I described is how to generate them algorithmically. If you're looking for something more specific you'd need to give more information on the program which you're doing this in. $\endgroup$
    – e4494s
    Commented Nov 5 at 16:29

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.