diff --git a/vec2.lua b/vec2.lua index f964074..9f88c5a 100644 --- a/vec2.lua +++ b/vec2.lua @@ -433,6 +433,20 @@ function vec2:abs() return self:copy():absi() end +----------------------------------------------------------- +-- sign +----------------------------------------------------------- + +function vec2:signi() + self.x = math.sign(self.x) + self.y = math.sign(self.y) + return self +end + +function vec2:sign() + return self:copy():signi() +end + ----------------------------------------------------------- -- truncation/rounding -----------------------------------------------------------