Description
The LerpTo
method is used to interpolate between the current rotation and a target rotation. This method performs a linear interpolation, which means it calculates a point between two rotations based on a given fraction. The interpolation can be clamped to ensure the result does not exceed the target rotation.
Usage
To use the LerpTo
method, you need to have an instance of the Rotation
struct. Call the method on this instance, passing the target rotation, the interpolation fraction, and a boolean indicating whether to clamp the result.
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 not exceed the target rotation.
Example
// Example of using LerpTo method
Rotation currentRotation = Rotation.Identity;
Rotation targetRotation = Rotation.FromAxis(Vector3.Up, 90);
float fraction = 0.5f;
bool clamp = true;
Rotation resultRotation = currentRotation.LerpTo(targetRotation, fraction, clamp);
// resultRotation is now halfway between currentRotation and targetRotation.