static float Lerp( float from, float to, float frac, bool clamp )
static System.Double Lerp( System.Double from, System.Double to, System.Double frac, bool clamp )

robot_2Generated
code_blocksInput

Description

The Lerp method in the MathX class performs linear interpolation between two values. It calculates a value that is a specified fraction between a starting value and an ending value. This method is useful for smoothly transitioning between two values over time.

Usage

To use the Lerp method, provide the starting value from, the ending value to, the interpolation fraction frac, and a boolean clamp to determine if the result should be clamped between the from and to values.

The frac parameter should be a value between 0 and 1, where 0 returns the from value, 1 returns the to value, and any value in between returns a linear interpolation between the two.

If clamp is set to true, the result will be clamped to the range defined by from and to. If clamp is false, the result can exceed this range.

Example

// Example usage of MathX.Lerp
float startValue = 0.0f;
float endValue = 10.0f;
float fraction = 0.5f;
bool shouldClamp = true;

float result = MathX.Lerp(startValue, endValue, fraction, shouldClamp);
// result will be 5.0f if clamping is enabled, otherwise it will be the same
// since 0.5 is within the range of 0.0 to 10.0.