Python 3 - Méthode Number atan2 ()

La description

le atan2() La méthode renvoie atan (y / x), en radians.

Syntaxe

Voici la syntaxe pour atan2() méthode -

atan2(y, x)

Note - Cette fonction n'est pas accessible directement, nous devons donc importer un module mathématique, puis nous devons appeler cette fonction en utilisant un objet statique mathématique.

Paramètres

  • y - Cela doit être une valeur numérique.

  • x - Cela doit être une valeur numérique.

Valeur de retour

Cette méthode renvoie atan (y / x), en radians.

Exemple

L'exemple suivant montre l'utilisation de la méthode atan2 ().

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

Production

Lorsque nous exécutons le programme ci-dessus, il produit le résultat suivant -

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