lerp method

Vector3 lerp(
  1. Vector3 to,
  2. double weight
)

Linearly interpolates each component of this vector toward to.

weight of 0 returns this vector unchanged; 1 returns to. Values outside [0, 1] extrapolate.

Implementation

Vector3 lerp(Vector3 to, double weight) {
  return Vector3(
    x + (to.x - x) * weight,
    y + (to.y - y) * weight,
    z + (to.z - z) * weight,
  );
}