export class Vector3 {
  /**
   * 
   * @param {number} x 
   * @param {number} y 
   * @param {number} z 
   */
  constructor(x, y, z) {
      this.x = x;
      this.y = y;
      this.z = z;
  }

  /**
   * @param {Vector3} other
   */
  equals(other) {
      return this.x === other.x && this.y === other.y && this.z === other.z;
  }

  /**
   * @param {Vector3} other
   */
  add(other) {
      return new Vector3(this.x + other.x, this.y + other.y, this.z + other.z);
  }

  /**
   * @param {Vector3} other
   */
  subtract(other) {
      return new Vector3(this.x - other.x, this.y - other.y, this.z - other.z);
  }

  /**
   * @param {number} scalar
   */
  multiply(scalar) {
      return new Vector3(this.x * scalar, this.y * scalar, this.z * scalar);
  }

  /**
   * @param {number} divisor
   */
  divide(divisor) {
      return new Vector3(this.x / divisor, this.y / divisor, this.z / divisor);
  }

  /**
   * 
   * @returns {Vector3}
   */
  clone() {
      return new Vector3(this.x, this.y, this.z);
  }

  /**
   * 
   * @param {Vector3} other 
   * @param {number} points
   * @returns {Vector3[]}
   */
  lerp(other, points) {
      const step = 1 / points;
      const lerped = [];
      for (let i = 0; i < points; i++) {
          lerped.push(this.add(other.subtract(this).multiply(step * i)));
      }
      return lerped;
  }
}