hhyyppoott() -- Mathematics Function (libm)

Compute hypotenuse of right triangle
#iinncclluuddee <mmaatthh.hh>
ddoouubbllee hhyyppoott(_x, _y) ddoouubbllee _x, _y;

hhyyppoott()  computes  the hypotenuse,  or  distance from  the  origin, of  its
arguments _x and _y. The result  is the square root of the sum of the squares
of _x and _y.

_E_x_a_m_p_l_e
The following  example demonstrates the  functions hhyyppoott() and  aattaann22(). It
converts  an X/Y  pair of rectangular  coordinates into  polar coordinates.
Thus, an X/Y pair of 1,1 produces a range of 1.41 and 45degrees; and an X/Y
pair of 3,4 would produce a  range of five and 36.87degrees.  The following
sketch illustrates this:

    X-Axis
    |^            (x,y)
    +-----------+
    |          /|
    |         / |
    |      e /  |
    |     g /   |
    |    n /    |
    |   a /     |
    |  R /      |
    |   /       |
    |  /        |
    | /        |
    |/  | Angle |
    +-----------+  -> Y-Axis

This example was written by Brent Seidel (brent_seidel@chthone.stat.com):

#include <stdio.h>
#include <math.h>

main()
{
    double x, y, angle, range;
    char    buffer[100];

    printf("Enter the X/Y pair: ");
    fflush(stdout);
    gets(buffer);
    sscanf(buffer, "%lf,%lf", &x, &y);

    range = hypot(x, y);
    angle = atan2(x, y);
    printf("The range is %f\n", range);
    printf("The angle is %f radians or %f degrees.\n",
        angle, angle * 180.0/PI);
}

_S_e_e _A_l_s_o
ccaabbss(), lliibbmm
