diff options
| author | Elizabeth Hunt <me@liz.coffee> | 2026-05-17 11:53:35 -0700 |
|---|---|---|
| committer | Elizabeth Hunt <me@liz.coffee> | 2026-05-17 11:54:05 -0700 |
| commit | 661156ce988131eb4896a7af4d00a42b520305e7 (patch) | |
| tree | 23b64b8f224f25aeb9c789a54da13f29c22b91c5 /math.lua | |
| parent | 7d415c4958f584c031922ed77a3559d15bf2dc1b (diff) | |
| download | dyl8-661156ce988131eb4896a7af4d00a42b520305e7.tar.gz dyl8-661156ce988131eb4896a7af4d00a42b520305e7.zip | |
This is REAL Artificial Intelligence and definitely REALLY COMPLICATED
Diffstat (limited to 'math.lua')
| -rw-r--r-- | math.lua | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -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) |
