class Vector { constructor(public x: number, public y: number) {} copy(){ return new Vector(this.x, this.y); } static Add(v1: Vector, v2: Vector){ return new Vector(v1.x + v2.x, v1.y + v2.y); } static Sub(v1: Vector, v2: Vector){ return new Vector(v1.x - v2.x, v1.y - v2.y); } static Mult(v: Vector, n: number){ return new Vector(v.x * n, v.y * n); } add(v: Vector){ this.x += v.x; this.y += v.y; } addC(x: number, y: number){ this.x += x; this.y += y; } mult(n: number){ this.x *= n; this.y *= n; } mag(){ return Math.sqrt(this.x * this.x + this.y * this.y); } normalize(){ this.mult(1 / this.mag()); } }