slerpLongPath
Performs Spherical Linear Interpolation (Slerp) between two quaternions, start and endInput, by an interpolant tOriginal, ensuring that the interpolation takes the long path if a shorter rotational path exists.
The "long path" means that if the direct 3D rotation angle between start and endInput is less than 180 degrees, this function will interpolate through an angle greater than 180 degrees (effectively going "the other way around" on the 4D sphere that represents rotations).
The process involves:
Clamping
tOriginalto[0.0, 1.0]. Exactt=0ort=1returns normalized inputs.Adjusting
endInput(by negating it ifdot(start, endInput) > 0) to ensure the 4D angle used for Slerp is obtuse (>= 90 degrees), which corresponds to the long path for 3D rotation.If the
startand the (adjusted)endquaternions are nearly opposite (4D angle close to 180 degrees,cosThetaEffectiveclose to -1), this function falls back to Normalized Linear Interpolation (Nlerp) for numerical stability.Otherwise, the standard Slerp formula is applied using the obtuse 4D angle.
The final result is normalized to ensure it remains a unit quaternion.
Both start and endInput should ideally be unit quaternions.
Return
A new unit Quat representing the spherically interpolated rotation along the long path.