- Home /
Animation curve equation ?
Can someone tell me the formula of the curve , it is a bezier(or something eqivalent) , but the formulas I tried couldn't match the curve drawn using the Evaluate method of AnimationCurve . Pls help ,I can even pay for the right formula :)) . I would do anything to see the C++ unity code that's implementing the Evaluate :P .
I'm not allowed for another answer,so I answered on the link "http://answers.unity3d.com/questions/464782/t-is-the-math-behind-animationcurveevaluate.html"
Answer by AlucardJay · Aug 06, 2013 at 01:13 AM
Sorry Dave, I didn't feel this link was informative enough to warrant an answer.
don't worry for Dave, he deleted my comment, without people like him the world would be such a mess :)) ... thks a lot Dave ;) ...
Answer by Paulius-Liekis · Aug 06, 2013 at 09:08 AM
It should be something like this:
float Evaluate(float t, Keyframe keyframe0, Keyframe keyframe1)
{
float dt = keyframe1.time - keyframe0.time;
float m0 = keyframe0.outTangent * dt;
float m1 = keyframe1.inTangent * dt;
float t2 = t * t;
float t3 = t2 * t;
float a = 2 * t3 - 3 * t2 + 1;
float b = t3 - 2 * t2 + t;
float c = t3 - t2;
float d = -2 * t3 + 3 * t2;
return a * keyframe0.value + b * m0 + c * m1 + d * keyframe1.value;
}
Answer by dood2 · Aug 05, 2013 at 07:00 PM
My guess is cubic Hermite splines: http://en.wikipedia.org/wiki/Cubic_Hermite_spline
well, yes ,cubic bezier is similar to hermite, the former is described with control points the later with tangents,indeed the animation curve of unity is dealing with tangents , even so the formula is not the classical one , I tried myself different ways already ... I just need to replicate 100% the animation curve of unity ...
Your answer
Follow this Question
Related Questions
How can I set the tangents of Keyframes in an AnimationCurve through scripting? 1 Answer
How to make objects running by Curve? 0 Answers
how to shot a soccer ball in curve path according to the swipe type 4 Answers
Controlling the curvature of a Bézier curve 2 Answers
How do i redraw an entire curve with the mouse (as opposed to one single keyframe redraw)? 0 Answers