PHP hypot() Function
Definition and Usage
The hypot() function calculates the length of the hypotenuse of a right triangle.
Syntax
hypot(x,y)
Parameters | Description |
---|---|
x | Required. The length of side x. |
y | Required. The length of side y. |
Description
The hypot() function will calculate the length of the hypotenuse of a right triangle based on the lengths of the two legs x and y. Or the distance from the point (x, y) to the origin. The algorithm of this function is equivalent to sqrt(x*x + y*y).
Example
<?php echo hypot(2,3); echo hypot(3,6); echo hypot(3,6); echo hypot(1,3); ?>
Output:
3.60555127546 6.7082039325 6.7082039325 3.16227766017