diff options
Diffstat (limited to 'src/Utils.ts')
-rw-r--r-- | src/Utils.ts | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/Utils.ts b/src/Utils.ts index 3af057d82..44f1d55c2 100644 --- a/src/Utils.ts +++ b/src/Utils.ts @@ -3,6 +3,11 @@ import * as uuid from 'uuid'; export function clamp(n: number, lower: number, upper: number) { return Math.max(lower, Math.min(upper, n)); } + +export function ptDistance(p1: { x: number; y: number }, p2: { x: number; y: number }) { + return Math.sqrt((p2.x - p1.x) ** 2 + (p2.y - p1.y) ** 2); +} + export namespace Utils { export function GuestID() { return '__guest__'; |