hypot
fn
T hypot(T)(const T x, const T y) if (isFloatingPoint!T) @safe pure nothrow @nogcCalculates the length of the hypotenuse of a right-angled triangle with sides of length x and y. The hypotenuse is the value of the square root of the sums of the squares of x and y:
sqrt(x2 + y2)
Note that hypot(x, y), hypot(y, x) and hypot(x, -y) are equivalent.
| x | y | hypot(x, y) | invalid? |
|---|---|---|---|
| x | ±0.0 | |x| | no |
| +∞ | y | +∞ | no |
| +∞ | NaN | +∞ | no |
| NaN | y != +∞ | NaN | no |
fn
T hypot(T)(const T x, const T y, const T z) if (isFloatingPoint!T) @safe pure nothrow @nogcCalculates the distance of the point (x, y, z) from the origin (0, 0, 0) in three-dimensional space. The distance is the value of the square root of the sums of the squares of x, y, and z:
sqrt(x2 + y2 + z2)
Note that the distance between two points (x1, y1, z1) and (x2, y2, z2) in three-dimensional space can be calculated as hypot(x2-x1, y2-y1, z2-z1).
Parameters
x | floating point value |
y | floating point value |
z | floating point value |
Returns
The square root of the sum of the squares of the given arguments.