Java Tutorial

Java Control Statements

Object Oriented Programming

Java Built-in Classes

Java File Handling

Java Error & Exceptions

Java Multithreading

Java Synchronization

Java Networking

Java Collections

Java List Interface

Java Queue Interface

Java Map Interface

Java Set Interface

Java Data Structures

Java Collections Algorithms

Java Miscellaneous

Advanced Java

Java APIs & Frameworks

Java Useful Resources

Java - atan2() Method



Description

The method converts rectangular coordinates (x, y) to polar coordinate (r, theta) and returns theta.

Syntax

double atan2(double y, double x)

Parameters

Here is the detail of parameters −

  • X − X co-ordinate in double data type.

  • Y − Y co-ordinate in double data type.

Return Value

  • This method returns theta from polar coordinate (r, theta).

Example

public class Test { 

   public static void main(String args[]) {
      double x = 45.0;
      double y = 30.0;

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

This will produce the following result −

Output

0.982793723247329
java_numbers.htm
Advertisements