## And Now, A Two-Point Cubic Spline

The simple quadratic spline discussed my previous post seems to be sufficient for interpolating particle positions between two GADGET-2 snapshots for the purposes of making animations, but it's also *possible* to use a cubic spline for the task. The advantages of using a cubic spline are (1) it can be more accurate—especially in cases where the acceleration changes sign *once* between snapshots, and (2) the derivatives at the end-points of the spline match the derivatives specified in the input data. In the case of the quadratic spline, if the acceleration (second derivative) changes sign even once during the interval, the interpolation is poor and the derivative of the spline at the end points is not guaranteed to match the specified value. Thus, in the case of the quadratic spline, the derivative is generally discontinuous when moving from one interval to another. This doesn't matter too much when making animations with reasonably small intervals, but it would be important for certain other situations. The disadvantage of the cubic spline is that it adds complexity.

Cubic spline interpolation seems to be quite popular. Derivations of the general method can be found in most textbooks on numerical methods. I'll just discuss the specific result that's useful for my application—the cubic spline in terms of the end-point positions and velocities. To derive the result, we just have to slightly modify the derivation given in the previous post. We add a jerk term (third derivative of the position with respect to time) to the third and fourth Taylor expansions,

and solve the system of equations for . There are, of course, several ways of doing this. I'll skip the details and show the end result. I defined

In terms of these definitions,

This can be written more compactly as

where

As an example, the cubic function generated by this technique when given values corresponding to at and is

In the plot below, is the blue curve and is the dotted black curve.

Tags: animation, interpolation

March 8th, 2015 at 12:15 pm

When government is ineligible and the country have to go through employment problem than its national are compulsive to do underemployment as it is the last option for them and for their survival.

February 3rd, 2016 at 2:44 am

There is no better post to understand a two point spline than this amazing post. It has all the information described briefly. I want to thank you for sharing such good article here.

August 12th, 2018 at 6:20 am

Nice Post

August 12th, 2018 at 7:27 am

Great Information..

August 12th, 2018 at 7:34 am

Really Nice..

August 12th, 2018 at 7:40 am

Thanks for sharing..