Describe
atan2 () returns the inverse tangent value of the given X and Y coordinate values.
Grammar
The following is the syntax for the ATAN2 () method:
Import mathmath.atan2 (y, x)
Note:atan2 () is not directly accessible, you need to import the math module, and then call the method through the math static object.
Parameters
- X--a numeric value.
- Y--a numeric value.
return value
Returns the inverse tangent value of the given X and Y coordinate values.
Instance
The following shows an example of using the Atan2 () method:
#!/usr/bin/python3import Mathprint ("atan2 ( -0.50,-0.50):", math.atan2 ( -0.50,-0.50)) print ("Atan2 (0.50,0.50):" , math.atan2 (0.50,0.50)) print ("Atan2 (5,5):", math.atan2 (5,5)) print ("Atan2 ( -10,10):", math.atan2 (- 10,10) Print ("Atan2 (10,20):", math.atan2 (10,20))
When the above instance is run, the output is:
Atan2 ( -0.50,-0.50): -2.356194490192345atan2 (0.50,0.50): 0.7853981633974483atan2 (5,5) : 0.7853981633974483atan2 ( -10,10): -0.7853981633974483atan2 (10,20): 0.4636476090008061
Python atan2 () function