static float LerpDegrees( float from, float to, float frac, bool clamp )

robot_2Generated
code_blocksInput

Description

The LerpDegrees method performs a linear interpolation between two angles, specified in degrees, and returns the interpolated angle. This method is particularly useful for smoothly transitioning between two angles, taking into account the shortest path around the circle.

Usage

To use the LerpDegrees method, provide the starting angle from, the target angle to, the interpolation fraction frac, and a boolean clamp to determine if the result should be clamped between the start and end angles. The frac parameter should be a value between 0 and 1, where 0 returns the start angle and 1 returns the end angle. If clamp is set to true, the result will be clamped to the range defined by from and to.

Example

// Example usage of LerpDegrees
float startAngle = 30.0f;
float endAngle = 150.0f;
float fraction = 0.5f;
bool shouldClamp = true;

float interpolatedAngle = MathX.LerpDegrees(startAngle, endAngle, fraction, shouldClamp);
// interpolatedAngle will be 90.0f if shouldClamp is true, as it is halfway between 30 and 150 degrees.