Rotation LerpTo( Rotation target, float frac, bool clamp )

book_4_sparkGenerated
code_blocksInput

Description

The LerpTo method interpolates between the current rotation and a target rotation by a specified fraction. This method is useful for smoothly transitioning from one rotation to another over time.

Usage

To use the LerpTo 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 value between 0 and 1 representing the interpolation fraction. A value of 0 will return the current rotation, while a value of 1 will return the target rotation.
  • clamp: A bool indicating whether to clamp the interpolation to the shortest path.

Example

// Example of using LerpTo
Rotation currentRotation = Rotation.Identity;
Rotation targetRotation = Rotation.FromAxis(Vector3.Up, 90);
float interpolationFraction = 0.5f;
bool shouldClamp = true;

Rotation resultRotation = currentRotation.LerpTo(targetRotation, interpolationFraction, shouldClamp);
// resultRotation now represents a rotation halfway between currentRotation and targetRotation.