Java | atan2()

La méthode atan2() convertit les coordonnées rectangulaires (x, y) en coordonnées polaires (r, thêta) et renvoie thêta.
 

Syntaxe

Cette méthode prend un seul argument:

double atan2(double y, double x)

 
 

Paramètres
  • y : Coordonnées X de type double.
  • x : Coordonnées Y de type double.

 

Valeur de retour

Cette méthode renvoie le thêta à partir des coordonnées polaires (r, thêta).
 

Exemple :

Le code suivant montre comment utiliser la méthode atan2():

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
public class Main {
public static void main(String args[]) {
double x = 21.0;
double y = 35.0;
System.out.println(Math.atan2(x, y));
}
}
public class Main { public static void main(String args[]) { double x = 21.0; double y = 35.0; System.out.println(Math.atan2(x, y)); } }
public class Main { 
   public static void main(String args[]) {
     
      double x = 21.0;
      double y = 35.0;

      System.out.println(Math.atan2(x, y));
   }
}

 
Sortie:

0.5404195002705842
QCM-Java

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *