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

1
$\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, 2024 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$ Commented Nov 5, 2024 at 16:29

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.