Description
The Vector4.Lerp
method performs a linear interpolation between two Vector4
values, a
and b
, based on a given fraction frac
. This method is useful for smoothly transitioning between two vectors over a specified range. The interpolation can be clamped to ensure the result stays within the bounds of a
and b
.
Usage
To use the Vector4.Lerp
method, provide two Vector4
instances, a fraction value, and a boolean indicating whether to clamp the result. The fraction should be a float
between 0 and 1, where 0 returns a
and 1 returns b
. If clamp
is set to true
, the result will be clamped between a
and 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 clamping is not needed.