* Find the distance between this and another vector. * @param {Vector} v: Vector to find distance to * @param {2 | 3} d: 2D or 3D distance * @returns {number} Distance
(v: Vector, d: 2 | 3 = 3)
| 108 | * @returns {number} Distance |
| 109 | */ |
| 110 | distance(v: Vector, d: 2 | 3 = 3) { |
| 111 | //2D distance |
| 112 | if (d === 2) return Math.sqrt(Math.pow(this.x - v.x, 2) + Math.pow(this.y - v.y, 2)); |
| 113 | //3D distance |
| 114 | else return Math.sqrt(Math.pow(this.x - v.x, 2) + Math.pow(this.y - v.y, 2) + Math.pow(this.z - v.z, 2)); |
| 115 | } |
| 116 | /** |
| 117 | * Lerp between this vector and another vector. |
| 118 | * @param {Vector} v: Vector to lerp to |
no outgoing calls
no test coverage detected