diff options
author | Lean Rada <godffrey0@gmail.com> | 2021-08-28 02:22:35 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-27 20:22:35 +0200 |
commit | d36dca3aba34e989eec6686660c0490548baad67 (patch) | |
tree | 2a331065267baf52ee6301e4d6c006a82dda8ce4 /builtin/common/misc_helpers.lua | |
parent | a7188bd6f55993d9ca6075b0b6a462c1e7e06412 (diff) | |
download | minetest-d36dca3aba34e989eec6686660c0490548baad67.tar.gz minetest-d36dca3aba34e989eec6686660c0490548baad67.tar.bz2 minetest-d36dca3aba34e989eec6686660c0490548baad67.zip |
Optimize vector length calculations (#11549)
Diffstat (limited to 'builtin/common/misc_helpers.lua')
-rw-r--r-- | builtin/common/misc_helpers.lua | 9 |
1 files changed, 1 insertions, 8 deletions
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 -------------------------------------------------------------------------------- |