aboutsummaryrefslogtreecommitdiff
path: root/static/src/vector.ts
blob: 96bd721c4c9876ebe2d077a7997f4ca138410c55 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
export class Vec2 {
  constructor(
    private readonly x: number,
    private 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);
  }
}