Rediger

Del via


WorksheetFunction.Atan2 method (Excel)

Returns the arctangent, or inverse tangent, of the specified x- and y-coordinates. The arctangent is the angle from the x-axis to a line containing the origin (0, 0) and a point with coordinates (x_num, y_num). The angle is given in radians between -pi and pi, excluding -pi.

Syntax

expression.Atan2 (Arg1, Arg2)

expression A variable that represents a WorksheetFunction object.

Parameters

Name Required/Optional Data type Description
Arg1 Required Double The x-coordinate of the point.
Arg2 Required Double The y-coordinate of the point.

Return value

Double

Remarks

A positive result represents a counterclockwise angle from the x-axis; a negative result represents a clockwise angle.

The following conditions apply:

  • Where x > 0 ATAN2(x,y) = ATAN(y/x)

  • Where y >= 0, x < 0 ATAN2(x,y) = ATAN(y/x)+PI()

  • Where y < 0, x < 0 ATAN2(x,y) = ATAN(y/x) - PI()

  • Where y > 0, x = 0 ATAN2(x,y) = PI()/2

  • Where y < 0, x = 0 ATAN2(x,y) = -PI()/2

  • If both x and y are 0, Atan2 returns an error value.

To express the arctangent in degrees, multiply the result by 180/PI( ) or use the Degrees method.

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.