Latest web development tutorials

Python atan2 function ()

figure Python figure Python


descrizione

atan2 () Restituisce l'arcotangente di X e Y valori delle coordinate.


grammatica

Quanto segue è il metodo sintassi atan2 ():

import math

math.atan2(y, x)

Nota: atan2 () non è direttamente accessibile, è necessario importare il modulo per la matematica, e quindi chiamare il metodo con oggetti statici matematica.


parametri

  • x - un valore.
  • y - un valore.

Valore di ritorno

Restituisce l'arcotangente di coordinate X e Y valori.


Esempi

Il seguente è un esempio di utilizzo di atan2 () Metodo:

#!/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)

Dopo aver eseguito l'output sopra esempio è:

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

figure Python figure Python