math.atan2

Full name
math.atan2
Library
math
Syntax

math.atan2(y, x)

Description

The math.atan2 function returns the arctangent, in radians, of the quotient of the arguments passed to the function: atan(y/x).

Once the point (x, y) is located in the plane, the angle returned is the one formed by the positive x axis and the line that passes through the origin of coordinates and through the point (x, y) :

math.atan2

Author: Sbyrnes321

Note that, for positive x values, the result of this function matches that of the math.atan(y/x) function.

Result

The math.atan2 function returns a real number in the closed interval [-π/2, π/2].

Examples

We can calculate the angle whose tangent is 1/2 with the following code:

math.atan2(1, 2)
0.4636476090008061
Submitted by admin on Fri, 02/05/2021 - 08:54