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 shortest path.
Parameters:
target
: The target Rotation
to interpolate towards.frac
: A float
representing the fraction of the way to interpolate. A value of 0 returns the current rotation, and a value of 1 returns the target rotation.clamp
: A bool
indicating whether to clamp the interpolation to the shortest path.// Example of using SlerpTo Rotation currentRotation = Rotation.Identity; Rotation targetRotation = Rotation.FromAxis(Vector3.Up, 90); float fraction = 0.5f; bool clamp = true; Rotation resultRotation = currentRotation.SlerpTo(targetRotation, fraction, clamp); // resultRotation now represents a rotation halfway between currentRotation and targetRotation.