Python math.atan2() Method
Example
Return the arc tangent of y/x in radians:
# Import math Library
import math
# Return the arc tangent of y/x
in radians
print (math.atan2(8, 5))
print (math.atan2(20, 10))
print
(math.atan2(34, -7))
Try it Yourself »
Definition and Usage
The math.atan2()
method returns the arc tangent of y/x. Where x and y are the coordinates of a point (x,y).
The number returned represents the counterclockwise angle in radians (not degrees) between the positive X-axis and the point (x, y).
The number we get in return is between PI and -PI.
Syntax
math.atan2(y,x)
Parameter Values
Parameter | Description |
---|---|
y | Required. Specifies the dividend |
x | Required. Specifies the divisor |
Technical Details
Return Value: | A float value, representing arc tangent of y/x in radians, which is between PI and -PI |
---|---|
Python Version: | 1.4 |