RLerp() is intended to smoothly interpolate between two rotations.
I've always assumed RLerp used a quaternion solution, but in practice it appears to interpolate the pitch, yaw and roll components individually - fine in most cases, but breaks down with complex rotations or when you need six degrees of freedom.
This is just an alternative to RLerp that shouldn't suffer from gimbal lock.
And this is the longhand version to better understand it:
I've always assumed RLerp used a quaternion solution, but in practice it appears to interpolate the pitch, yaw and roll components individually - fine in most cases, but breaks down with complex rotations or when you need six degrees of freedom.
This is just an alternative to RLerp that shouldn't suffer from gimbal lock.
Code:
static function Rotator RLerpQuat( Rotator A, Rotator B, float Alpha, bool bShortestPath ) { return QuatToRotator( QuatSlerp( QuatFromRotator( A ), QuatFromRotator( B ), Alpha, bShortestPath ) ); }
Code:
static function Rotator RLerpQuat( Rotator A, Rotator B, float Alpha, bool bShortestPath ) { local Quat Q, QA, QB; QA = QuatFromRotator( A ); // Quaternion for rotation A QB = QuatFromRotator( B ); // Quaternion for rotation B Q = QuatSlerp( A, B, Alpha, bShortestPath ); // Spherical linear interpolation between A and B return QuatToRotator( Q ); // Convert back to rotation }
Comment