The SlerpTo
method performs a spherical linear interpolation (slerp) between the current rotation and a target rotation. This method is useful for smoothly transitioning between two orientations over a specified fraction of the way.
The SlerpTo
method performs a spherical linear interpolation (slerp) between the current rotation and a target rotation. This method is useful for smoothly transitioning between two orientations over a specified fraction of the way.
To use the SlerpTo
method, call it on an instance of the Rotation
struct, passing in the target rotation, the fraction of interpolation, and a boolean indicating whether to clamp the interpolation to the range [0, 1].
The frac
parameter should be a value between 0 and 1, where 0 returns the current rotation and 1 returns the target rotation. If clamp
is set to true
, the interpolation will be clamped to the range [0, 1].
// Example of using SlerpTo Rotation currentRotation = Rotation.Identity; Rotation targetRotation = Rotation.FromAxis(Vector3.Up, 90); float fraction = 0.5f; bool shouldClamp = true; Rotation resultRotation = currentRotation.SlerpTo(targetRotation, fraction, shouldClamp); // resultRotation is now halfway between currentRotation and targetRotation.