Python math.atan2() Method
Python math.atan2(y,x) Returns the arctangent of the given y and x coordinate values, atan(y / x), in radians, with the result between -pi and pi.
Python version: 1.4
Syntax
The syntax of the math.atan2() method is as follows:
math.atan2(y, x)
Parameter Description:
- x -- required, a positive or negative number.
- y -- required, a positive or negative number.
Return Value
Returns a floating-point number representing the arctangent of the y and x coordinate values, with the result between -pi and pi.
Example
The following example returns the arctangent of y/x:
Example
Import the math package
import
math
Output the y/x arctangent values
(
math
.
atan2
(
8
,
5
)
)
(
math
.
atan2
(
20
,
10
)
)
(
math
.
atan2
(
34
,
7
)
)
Output result:
1.0121970114513341
1.1071487177940904
1.7738415440483617
Python math Module