atan2() is an inbuilt method in Java that is used to return the theta component from the polar coordinate. The atan2() method returns a numeric value between –
Syntax :
Math.atan2(double y, double x) where, x and y are X and Y coordinates in double data type.
Returns :
It returns a double value. The double value is
Example: Program demonstrating the atan2() method
Java
// Java program for implementation of // atan2() method import java.util.*;
class GFG {
// Driver Code
public static void main(String args[])
{
// X and Y coordinates
double x = 90.0 ;
double y = 15.0 ;
// theta value from polar coordinate (r, theta)
double theta = Math.atan2(y, x);
System.out.println(theta);
}
} |
Output
0.16514867741462683
Article Tags :