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 distance.
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 distance.
To use the SlerpTo
method, call it on an instance of the Rotation
struct, passing in the target rotation, the interpolation fraction, and a boolean indicating whether to clamp the interpolation.
target
: The target Rotation
to interpolate towards.frac
: A float
representing the fraction of the way to interpolate from the current rotation to the target rotation. A value of 0 will result in no change, while a value of 1 will result in the target rotation.clamp
: A bool
indicating whether to clamp the interpolation fraction between 0 and 1. If true
, the interpolation will not exceed the target rotation.// Example usage of SlerpTo Rotation currentRotation = Rotation.Identity; Rotation targetRotation = Rotation.FromAxis(Vector3.Up, 90); float interpolationFraction = 0.5f; bool shouldClamp = true; Rotation resultRotation = currentRotation.SlerpTo(targetRotation, interpolationFraction, shouldClamp); // resultRotation now represents a rotation halfway between currentRotation and targetRotation.