Python atan2 () function
description
atan2 () Returns the arctangent of X and Y coordinate values.
grammar
The following is the syntax atan2 () method:
import math math.atan2(y, x)
Note: atan2 () is not directly accessible, you need to import math module, and then call the method by math static objects.
parameter
- x - a value.
- y - a value.
return value
Returns the arctangent of X and Y coordinate values.
Examples
The following shows an example of the use of atan2 () method:
#!/usr/bin/python import math print "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)
After running the above example output is:
atan2(-0.50,-0.50) : -2.35619449019 atan2(0.50,0.50) : 0.785398163397 atan2(5,5) : 0.785398163397 atan2(-10,10) : -0.785398163397 atan2(10,20) : 0.463647609001