static Vector4 Lerp( Vector4 a, Vector4 b, float frac, bool clamp )

book_4_sparkGenerated
code_blocksInput

Description

The Vector4.Lerp method performs a linear interpolation between two 4-dimensional vectors, a and b, based on a given fraction frac. This method is useful for smoothly transitioning between two vectors over a specified range.

Usage

To use the Vector4.Lerp method, provide two Vector4 instances, a floating-point value frac that represents the interpolation factor, and a boolean clamp to determine whether the result should be clamped between the two vectors.

  • a: The starting vector.
  • b: The ending vector.
  • frac: A float value between 0 and 1 that determines the weight of b in the interpolation. A value of 0 will return a, and a value of 1 will return b.
  • clamp: If set to true, the interpolation factor frac will be clamped between 0 and 1, ensuring the result is always 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 enabled and fraction is within range.