Documentation/Calc Functions/ATAN2

    From The Document Foundation Wiki


    Function name:

    ATAN2

    Category:

    Mathematical

    Summary:

    Calculates the inverse trigonometric tangent (arctangent or arctan) for the specified x and y coordinates. That is, the angle (in radians) between the x-axis and a line from the origin to the specified (x, y) point. The value returned is the principal value and lies in the range (-π, π] radians.

    Syntax:

    ATAN2(Number X; Number Y)

    Returns:

    Returns a real number in the range (-π, π] that is the inverse trigonometric tangent in radians for the specified x and y coordinates.

    If the function returns a positive angle it represents a counterclockwise angle from the x-axis, while a negative result represents a clockwise angle.

    Arguments:

    Number X is a real number, or a reference to a cell containing that number, that is the value of the x coordinate.

    Number Y is a real number, or a reference to a cell containing that number, that is the value of the y coordinate.

    • If either Number X or Number Y is non-numeric, then ATAN2 returns a #VALUE! error.
    • If Number X and Number Y are both equal to 0, then ATAN2 returns the value 0.

    Additional details:

    The following illustration shows the geometry used by ATAN2 (φ is the angle calculated).

    ATAN2 arguments.png
    • To return the angle in degrees, use the DEGREES function.
    • Alternatively multiply by 180/PI() to convert the result from radians to degrees.
    • Beware that computer programming languages often use the opposite order of arguments for their atan2() functions.

    Examples:

    Formula Description Returns
    =ATAN2(−5; 9)

    The function calculates the angle (in radians) between the x-axis and a line from the origin to the point (−5, 9).

    2.07789483118723
    =DEGREES(ATAN2(12.3; 12.3))

    Calculate the angle (in degrees) between the x-axis and a line from the origin to the point (12.3, 12.3).

    45
    =ATAN2(D1; D2)

    where cells D1 and D2 both contain the value 0.

    The function returns 0.

    0
    =ATAN2(−5; −3)*180/PI()

    Calculate the angle (in degrees) between the x-axis and a line from the origin to the point (−5−3).

    −149.036243467926
    DEGREES(ATAN2(−8; 5))

    Calculate the angle (in degrees) between the x-axis and a line from the origin to the point (−8, 5).

    147.994616791916

    Related LibreOffice functions:

    ACOS

    ACOT

    ASIN

    ATAN

    TAN

    ODF standard:

    Section 6.16.10, part 2

    Related (or similar) Excel functions:

    ATAN2