1 2 3 4 5 6 7 8 9 10 11 12 13 14
export class Vec2 { constructor( public readonly x: number, public readonly y: number, ) {} public distance_to(that: Vec2): number { return Math.sqrt((this.x - that.x) ** 2 + (this.y - that.y) ** 2); } public copy(): Vec2 { return new Vec2(this.x, this.y); } }