nlerp¶
- giant.rotations.nlerp(quaternion0, quaternion1, time, time0=0, time1=1)[source]¶
This function performs normalized linear interpolation of rotation quaternions.
NLERP of quaternions involves first performing a linear interpolation between the two vectors, and then normalizing the interpolated result to have unit length. That is:
where
is the interpolated quaternion, is the starting quaternion, is the ending quaternion, and is the fractional percent of the way between and that we want to interpolate at ( )When using this function you can either specify the argument time as the fractional percent that you want to interpolate at, or specify the keyword arguments time0 and time1 to be the times corresponding to the first and second quaternion respectively and the function will compute the fractional percent for you. When using this method it is also possible to specify all three of time, time0, and time1 as python datetime objects.
Warning
NLERP is a very fast and efficient interpolation method that is fine for short interpolation intervals; however, it does not perform a constant angular velocity interpolation (and instead performs a constant linear velocity interpolation), therefore it is not well suited to interpolating over long time intervals. If you need to interpolate over larger time intervals it is better to use the
slerp()
function which does perform constant angular velocity interpolation (but is less efficient).- Parameters:
quaternion0 (Sequence | ndarray | Rotation) – The starting quaternion(s)
quaternion1 (Sequence | ndarray | Rotation) – The ending quaternion(s)
time (Real | datetime) – The time to interpolate the quaternions at, as a fractional percent or as the actual time between time0 and time1
time0 (Real | datetime) – the time(s) corresponding to the first quaternion(s). Leave at 0 if you are specifying time as a fractional percent
time1 (Real | datetime) – the time(s) corresponding to the second quaternion(s). Leave at 1 if you are specifying time as a fractional percent
- Returns:
The interpolated quaternion(s)
- Return type:
ndarray | Rotation