summaryrefslogtreecommitdiff
path: root/math.lua
diff options
context:
space:
mode:
authorElizabeth Hunt <me@liz.coffee>2026-05-17 11:53:35 -0700
committerElizabeth Hunt <me@liz.coffee>2026-05-17 11:54:05 -0700
commit661156ce988131eb4896a7af4d00a42b520305e7 (patch)
tree23b64b8f224f25aeb9c789a54da13f29c22b91c5 /math.lua
parent7d415c4958f584c031922ed77a3559d15bf2dc1b (diff)
downloaddyl8-661156ce988131eb4896a7af4d00a42b520305e7.tar.gz
dyl8-661156ce988131eb4896a7af4d00a42b520305e7.zip
This is REAL Artificial Intelligence and definitely REALLY COMPLICATED
Diffstat (limited to 'math.lua')
-rw-r--r--math.lua9
1 files changed, 8 insertions, 1 deletions
diff --git a/math.lua b/math.lua
index 429e1ab..ddc6644 100644
--- a/math.lua
+++ b/math.lua
@@ -25,7 +25,14 @@ end
function Vec2:normal()
local m = self:magnitude()
if m == 0 then return vec2(self.x, self.y) end
- return self / m
+ return vec2(self / m)
+end
+
+-- 1 picorad == 2pi
+function Vec2:clockwise_rotate(picorads)
+ local m = self:magnitude()
+ local a = atan2(self.x, self.y) + picorads
+ return vec2(m * cos(a), m * sin(a))
end
function Vec2:apply(f)