summaryrefslogtreecommitdiff
path: root/test-client/util.ts
diff options
context:
space:
mode:
Diffstat (limited to 'test-client/util.ts')
-rw-r--r--test-client/util.ts6
1 files changed, 6 insertions, 0 deletions
diff --git a/test-client/util.ts b/test-client/util.ts
index 994e6acf..99f0c013 100644
--- a/test-client/util.ts
+++ b/test-client/util.ts
@@ -2,3 +2,9 @@ export interface V2 { x: number, y: number }
export function length(p: V2): number { return Math.sqrt(p.x * p.x + p.y * p.y) }
export function normalize_mut(p: V2) { const l = length(p); if (l == 0) return; p.x /= l; p.y /= l }
export function normalize(p: V2): V2 { let l = length(p); if (l == 0) l = 1; return { x: p.x / l, y: p.y / l } }
+export function lerp_v2_mut(current: V2, target: V2, dt: number) {
+ current.x = target.x + (current.x - target.x) * Math.exp(-dt)
+ current.y = target.y + (current.y - target.y) * Math.exp(-dt)
+}
+export function floor_v2(p: V2): V2 { return { x: Math.floor(p.x), y: Math.floor(p.y) } }
+export function ceil_v2(p: V2): V2 { return { x: Math.ceil(p.x), y: Math.ceil(p.y) } }