The Rotation.Lerp
method performs a linear interpolation between two rotations, a
and b
, based on a given fraction frac
. This method is useful for smoothly transitioning between two orientations over time.
The Rotation.Lerp
method performs a linear interpolation between two rotations, a
and b
, based on a given fraction frac
. This method is useful for smoothly transitioning between two orientations over time.
To use the Rotation.Lerp
method, provide two Rotation
objects, a
and b
, a float
value frac
that represents the interpolation factor, and a bool
clamp
to determine if the interpolation should be clamped between 0 and 1. The method returns a new Rotation
that is the result of the interpolation.
The frac
parameter should typically be between 0 and 1, where 0 returns a
and 1 returns b
. If clamp
is set to true
, the frac
value will be clamped to this range.
// Example of using Rotation.Lerp Rotation startRotation = Rotation.FromAxis(Vector3.Up, 0); Rotation endRotation = Rotation.FromAxis(Vector3.Up, 90); float interpolationFactor = 0.5f; bool shouldClamp = true; Rotation resultRotation = Rotation.Lerp(startRotation, endRotation, interpolationFactor, shouldClamp); // resultRotation now represents a rotation halfway between startRotation and endRotation.