How can I make a spline that does not exceed?

I have a list of line segments that go through a track model and I am looking to achieve two things:

  • smooth the general shape of the path
  • be able to evaluate a position by questioning 0.0 at 1.0

I've implemented the Catmull-Rom spline using the TreeSpline Unity class (this is not explicitly mentioned in the documentation but you can see it here), it works except for one thing: some places have an overtaking:

enter the description of the image here


  • purple: line segments of origin
  • white: result of the TreeSpline Evaluation

After looking a little, it seems that monotonous cubic interpolation would be a solution to my problem. However, formulas only show how to use 2D points, not 3D points that I use.


How can I adapt Wikipedia article formulas to 3D points?

(I am also open to alternative approaches)


Thanks to @Jay, it's better now:

enter the description of the image here