lerpVectors method

Vector3 lerpVectors(
  1. Vector3 v1,
  2. Vector3 v2,
  3. dynamic alpha
)

Sets this vector to be the vector linearly interpolated between v1 and v2 where alpha is the percent distance along the line connecting the two vectors - alpha = 0 will be v1, and alpha = 1 will be v2.

  • v1 - the starting Vector3.
  • v2 - Vector3 to interpolate towards.
  • alpha - interpolation factor, typically in the closed interval 0, 1.

Implementation

Vector3 lerpVectors(Vector3 v1, Vector3 v2, alpha) {
  x = v1.x + (v2.x - v1.x) * alpha;
  y = v1.y + (v2.y - v1.y) * alpha;
  z = v1.z + (v2.z - v1.z) * alpha;

  return this;
}