summaryrefslogtreecommitdiff
path: root/util.lua
diff options
context:
space:
mode:
authorthe lemons <citrons@mondecitronne.com>2023-04-24 15:20:36 -0500
committerthe lemons <citrons@mondecitronne.com>2023-04-24 15:20:36 -0500
commit425c5dae3521479a694528dff33d32989662dda7 (patch)
tree5623e58763c41bd6a3c2e86691295751e21326b3 /util.lua
parent0d2f8775b11b604adc0f9adf73c8f6379e075ad5 (diff)
obj:avel_to_accel (broken)
Diffstat (limited to 'util.lua')
-rw-r--r--util.lua8
1 files changed, 8 insertions, 0 deletions
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