## Quadratic Spline Interpolation

While animating my first GADGET-2 galaxy mergers, I discovered that setting the frame rate to the common value of 25 frames per second resulted in movies that were too fast. The complexity of the merger process couldn't be appreciated--even though the snapshot interval was quite small (0.005 simulation time units). I had to interpolate the GADGET-2 snapshots in order to produce intermediate frames that could be used to slow the animation down. Linear interpolation didn't work well enough to meet my standards, so I looked for an efficient quadratic interpolation scheme. I wanted to perform a quadratic interpolation using only two snapshots at a time (a quadratic interpolation using two snapshots is possible in this case because each snapshot contains particle position and velocity information). The first thing that came to mind was simply using the familiar expression

to take a half-step forward from the first snapshot and a half step backward from the second snapshot and then average the two results together to estimate the likely position of each particle in the snapshot like this:

Where is the time interval between snapshots and , is the position of a particle at time after snapshot , , , , and are the positions and velocities of the particle at snapshot and snapshot . This method is slightly better than linear interpolation, but not as good as using a quadratic spline. I tested it out and the results were disappointing. I searched my computational physics and numerical analysis textbooks and searched the web, but I couldn't find what I was looking for, so I derived the method myself. My final result was

This is very closely related to a quadratic Bézier curve. The derivation follows: The Taylor expansion of a function about the point is

It is possible to approximate the value of the function at using a Taylor expansion by swapping with in the expansion above and truncating the series:

Writing expansions for , , and ,

Eliminating using the third and fourth equations:

The first two equations then become

Now we eliminate between the two equations

Solving for and defining yields the result stated above.

This is a decent approximation for the motion of each particle between snapshots. In fact, it's a pretty good approximation for any function with specified end point values and first derivatives *as long as the sign of the second derivative doesn't change during the interval*.

For demonstration purposes, the blue curve below is . The black dashed curve is the interpolating parabola generated by the expression derived above for endpoints at and . The red dashed curve is the interpolating parabola for endpoints at and

Tags: animation, interpolation

October 25th, 2015 at 2:05 am

A children who is interesting in the sports and he is studying some other courses so they never able to become successful and developed. The students should know that what courses they should learn and what the profession they should select in their life.