add Ox.hypot

This commit is contained in:
rolux 2012-06-21 13:39:19 +02:00
parent d04c1d3059
commit d8cd59e90f

View file

@ -69,6 +69,19 @@ Ox.divideInt = function(number, by) {
});
};
/*@
Ox.hypot <f> Returns the square root of the sum of the squares of its arguments
(x, y[, z]) -> <n> 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 <f> Limits a number by a given mininum and maximum
`Ox.limit(num, min, max)` is a shorthand for `Math.min(Math.max(num, min),