diff options
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) |
