Jump to content

Interpolation curve for animation


Recommended Posts

Hi,

 

I am designing an animation library for the web, and I wanted to create an animation interpolation that is more flexible and elegant than using 'sine' or similar.

 

I have spent countless hours trying to solve this, so I'll be extremely thankful for any help offered.

 

My system I devised is this:

 

A partical is at position 0, with velocity 'v' and accelleration 'a'. I want it to move along a function to land at position 'h' with velocity 0 and accelleration 0.

 

Simply put, I want to get a moving object to land somewhere stationry. 'v' and 'a' are provided to the function as attributes so that if the target moves then the curve can adjust without any abruptness.

 

I figured a polynomial of degree 5 would be the simplest curve to do so:

 

[math]f(x) = Px^5 + Qx^4 + Rx^3 + \frac{a}{2} x^2 + vx[/math]

 

If I let the amount of time for the object to land still be t, and using my constraints from above I can get the following equations:

 

[math]Pt^5 + Qt^4 + Rt^3 + \frac{a}{2} t^2 + vt = h[/math]

 

[math]5Pt^4 + 4Qt^3 + 3Rt^2 + at + v = 0[/math]

 

[math]20pt^3 + 12Qt^2 + 6Rt + a = 0[/math]

 

This is a piece of cake to solve if I know what t is. But I want 't' to be automatic, though of course then I have 4 unknowns with 3 equations. The final constraint I want to impose is this:

 

If:

v = 0

a = 0

h = 1

Then t = 1

(see diagram)

 

35iasec.png

[math]f(x) = 6x^5 - 15x^4 + 10x^3[/math]

 

And, given that function, if the animation is paused and a new function is calculated using the same current velocity, accelleration and relative displacement from target 'h', then it should still arrive at the same time.

 

That is, if I update the target position on each frame even though the target has not moved, then the total time taken for the animation should not be comprimised.

 

As far as I can see this should be enough to result in a unique solution for 't', that solution is all I need.

 

If there is a more appropriate system, such as some kind of spline, then please mention it.

 

Thankyou,

BigMoosie

Edited by BigMoosie
Add math markup
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.