From d36dca3aba34e989eec6686660c0490548baad67 Mon Sep 17 00:00:00 2001 From: Lean Rada Date: Sat, 28 Aug 2021 02:22:35 +0800 Subject: Optimize vector length calculations (#11549) --- builtin/common/misc_helpers.lua | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'builtin/common/misc_helpers.lua') diff --git a/builtin/common/misc_helpers.lua b/builtin/common/misc_helpers.lua index 64c8c9a67..c2452fe00 100644 --- a/builtin/common/misc_helpers.lua +++ b/builtin/common/misc_helpers.lua @@ -209,14 +209,7 @@ end -------------------------------------------------------------------------------- function math.hypot(x, y) - local t - x = math.abs(x) - y = math.abs(y) - t = math.min(x, y) - x = math.max(x, y) - if x == 0 then return 0 end - t = t / x - return x * math.sqrt(1 + t * t) + return math.sqrt(x * x + y * y) end -------------------------------------------------------------------------------- -- cgit v1.2.3