Description
The Vector4.Lerp
method performs a linear interpolation between two Vector4
values. This method is useful for smoothly transitioning between two vectors based on a specified fraction. The interpolation can be clamped to ensure the result stays within the range of the two vectors.
Usage
To use the Vector4.Lerp
method, provide two Vector4
instances, a
and b
, a frac
value representing the interpolation factor, and a clamp
boolean to determine if the result should be clamped between a
and b
. The frac
parameter should be a float between 0 and 1, where 0 returns a
and 1 returns b
. If clamp
is true, the result will be clamped to the range [a
, b
].
Example
Vector4 start = new Vector4(0, 0, 0, 0);
Vector4 end = new Vector4(10, 10, 10, 10);
float fraction = 0.5f;
bool shouldClamp = true;
Vector4 result = Vector4.Lerp(start, end, fraction, shouldClamp);
// result is (5, 5, 5, 5) if clamped, otherwise it could be outside the range if fraction is outside [0, 1]