From 2fd14e1bd53918b3c4fcdfbc81294ff8b7afe1fa Mon Sep 17 00:00:00 2001 From: SmallJoker Date: Fri, 5 Dec 2014 23:18:52 +0100 Subject: Add Lua helper functions vector.apply(v) math.sign(x, tolerance) --- builtin/common/misc_helpers.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'builtin/common/misc_helpers.lua') diff --git a/builtin/common/misc_helpers.lua b/builtin/common/misc_helpers.lua index 0b608126e..e1dc28965 100644 --- a/builtin/common/misc_helpers.lua +++ b/builtin/common/misc_helpers.lua @@ -212,6 +212,17 @@ function math.hypot(x, y) return x * math.sqrt(1 + t * t) end +-------------------------------------------------------------------------------- +function math.sign(x, tolerance) + tolerance = tolerance or 0 + if x > tolerance then + return 1 + elseif x < -tolerance then + return -1 + end + return 0 +end + -------------------------------------------------------------------------------- function get_last_folder(text,count) local parts = text:split(DIR_DELIM) -- cgit v1.2.3