I have a list of line segments that run through a track model and I am looking to achieve two things:
- smooth the overall shape of the path
- being able to evaluate a position by querying from
0.0
to1.0
I have implemented Catmull-Rom spline using the TreeSpline
class from Unity (it's not explicitly in the docs but you can see it here), it does work except for one thing: some places have overshoot:
Legend
- purple: original line segments
- white: result of the
TreeSpline
evaluation
After searching for a bit, it appears that Monotone cubic interpolation would be a solution to my problem. However, the formulas only show on how to do with 2D points, not with 3D points which I'm using.
Question:
How can I adapt the formulas in the Wikipedia article to 3D points instead ?
(I am also open to alternative approaches)
Edit:
Thanks to @Jay it's better now:
y
. Does your track definitely have this property? \$\endgroup\$