make Ox.hypot n-ary
This commit is contained in:
parent
05f8ed7a48
commit
779463072d
1 changed files with 4 additions and 3 deletions
|
@ -58,9 +58,10 @@ Ox.hypot <f> Returns the square root of the sum of the squares of its arguments
|
||||||
> Ox.hypot(1, 1, 1)
|
> Ox.hypot(1, 1, 1)
|
||||||
Math.sqrt(3)
|
Math.sqrt(3)
|
||||||
@*/
|
@*/
|
||||||
Ox.hypot = function(x, y, z) {
|
Ox.hypot = function() {
|
||||||
z = z || 0;
|
return Math.sqrt(Ox.slice(arguments).reduce(function(sum, number) {
|
||||||
return Math.sqrt(x * x + y * y + z * z) || 0;
|
return sum + number * number;
|
||||||
|
}, 0));
|
||||||
};
|
};
|
||||||
|
|
||||||
/*@
|
/*@
|
||||||
|
|
Loading…
Reference in a new issue