From d8cd59e90f5ece39f099b628f176ef2ac27dee2a Mon Sep 17 00:00:00 2001 From: rolux Date: Thu, 21 Jun 2012 13:39:19 +0200 Subject: [PATCH] add Ox.hypot --- source/Ox/js/Math.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/source/Ox/js/Math.js b/source/Ox/js/Math.js index 92544ad3..157606d1 100644 --- a/source/Ox/js/Math.js +++ b/source/Ox/js/Math.js @@ -69,6 +69,19 @@ Ox.divideInt = function(number, by) { }); }; +/*@ +Ox.hypot Returns the square root of the sum of the squares of its arguments + (x, y[, z]) -> Square root of the sum of the squares of its arguments + > Ox.hypot(3, 4) + 5 + > Ox.hypot(1, 1, 1) + Math.sqrt(3) +@*/ +Ox.hypot = function(x, y, z) { + z = z || 0; + return Math.sqrt(x * x + y * y + z * z) || 0; +}; + /*@ Ox.limit Limits a number by a given mininum and maximum `Ox.limit(num, min, max)` is a shorthand for `Math.min(Math.max(num, min),