From 425c5dae3521479a694528dff33d32989662dda7 Mon Sep 17 00:00:00 2001 From: the lemons Date: Mon, 24 Apr 2023 15:20:36 -0500 Subject: obj:avel_to_accel (broken) --- util.lua | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'util.lua') diff --git a/util.lua b/util.lua index 24b4214..452e6d5 100644 --- a/util.lua +++ b/util.lua @@ -31,4 +31,12 @@ function M.rot(a, x, y) return x*math.cos(a) - y*math.sin(a), x*math.sin(a) + y*math.cos(a) end +function M.magnitude(v) + local s = 0 + for _, a in ipairs(v) do + s = s + a*a + end + return math.sqrt(s) +end + return M -- cgit v1.2.3