diff options
| author | Josh Kingsley <josh@joshkingsley.me> | 2025-10-25 20:46:35 +0300 |
|---|---|---|
| committer | Josh Kingsley <josh@joshkingsley.me> | 2025-10-25 22:09:48 +0300 |
| commit | 5404a95c15e176d25728bf1a319ddb9828b23625 (patch) | |
| tree | 639d175e15170618d36c0b22b3c8ad7764925175 /web/src/math/Coord.ts | |
| parent | 2a4d7a7fc3b968ed8cdfd958a5e65fbe140042da (diff) | |
refactor(web): re-organize files
Diffstat (limited to 'web/src/math/Coord.ts')
| -rw-r--r-- | web/src/math/Coord.ts | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/web/src/math/Coord.ts b/web/src/math/Coord.ts new file mode 100644 index 0000000..db7ee6d --- /dev/null +++ b/web/src/math/Coord.ts @@ -0,0 +1,23 @@ +/** A coord on a grid whose origin is in the top left. */ +export default class Coord { + private readonly _x: number; + private readonly _y: number; + + constructor(x: number, y: number) { + this._x = x; + this._y = y; + } + + get x(): number { + return this._x; + } + + get y(): number { + return this._y; + } + + /** Get the squared distance of this point from the origin. */ + squaredDistanceFromOrigin(): number { + return this._x * this._x + this._y * this._y; + } +} |
