Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python atan2() function

Python atan2() function

Python Numbers Python Numbers


Description

atan2() Returns the arc tangent of the given X and Y coordinate values.


Syntax

The syntax of the atan2() method is as follows:



import math



math.atan2(y, x)

**Note:** atan2() cannot be accessed directly; you need to import the math module and call the method through the static math object.


Parameters


Return Value

Returns the arc tangent of the given X and Y coordinate values.


Example

The following shows examples of using the 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)

Running the example above produces:



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

Python Numbers Python Numbers