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

book_4_sparkGenerated
code_blocksInput

Description

The LerpTo method performs a linear interpolation between the current Vector4 instance and a target Vector4. This method is useful for smoothly transitioning between two vectors over a specified fraction of the distance.

Usage

To use the LerpTo method, call it on an instance of Vector4, passing in the target vector, the interpolation fraction, and a boolean indicating whether to clamp the result between the start and target vectors.

The frac parameter should be a value between 0 and 1, where 0 returns the current vector and 1 returns the target vector. If clamp is set to true, the result will be clamped to the range defined by the current and target vectors.

Example

Vector4 start = new Vector4(0, 0, 0, 0);
Vector4 target = new Vector4(10, 10, 10, 10);
float fraction = 0.5f;
bool clamp = true;

Vector4 result = start.LerpTo(target, fraction, clamp);
// result is (5, 5, 5, 5) if clamp is true and fraction is 0.5