export default class V2 { readonly x: number; readonly y: number; constructor(x: number, y: number) { this.x = x; this.y = y; } static get zero() { return new V2(0, 0); } toString() { return `(${this.x}, ${this.y})`; } *[Symbol.iterator]() { yield this.x; yield this.y; } scale(factor: number) { return new V2(this.x * factor, this.y * factor); } get neg() { return this.scale(-1); } add(other: V2) { return new V2(this.x + other.x, this.y + other.y); } sub(other: V2) { return this.add(other.neg); } }