- Home /
is it possible to do non-linear rotation interpolation (using Slerp)?
I have a model rotating between two rotations using Quaternion.slerp, and it works just fine. THe problem is, the model is a person and the movement looks a little robotic. I was wondering if it's possible to use Slerp in some way that the rotation isn't linear, i.e., perhaps it is slower at the beginning and end and faster in the middle?
Thanks :)
Answer by Bunny83 · May 25, 2012 at 06:13 PM
Slerp is the short from of "spherical linear interpolation". That means the interpolation itself will be linear. However you can use a non linear t value to drive the slerp. If you move the t value linearly from 0 to 1 it will be a linear movement / rotation.
You can use a Hermit curve for example.
//C#
float Hermit(float t)
{
return 3*t*t - 2*t*t*t;
}
// Where ever you use Slerp
rotation = Quaternion.Slerp(from, to, Hermit(t));
Answer by whydoidoit · May 25, 2012 at 06:01 PM
Take a look on my blog at the SmoothQuaternion - it allows a couple of modes like smooth and damp.
edit
Link replaced with archived link since the blog / domain does no longer exist.
Dont click on this link. It lead to a "Phone Verification" that if you provide your real phone number charge you 25 $ per month ( it says it in small writing on the bottom of the page but I have my browser at 200%)
I've replaced the link with a link to the archived page