Open In App

StrictMath atan2() Method in Java

The java.lang.StrictMath.atan2() is an inbuilt method in java which is used to calculate arc tangent of ordinate_val/abscissa_val in the range between -pi and pi. It returns the angle from the conversion of rectangular coordinates (abscissa_val, ordinate_val) to polar coordinates (p, angle).

Syntax :  



public static double atan2(double abscissa_val, double ordinate_val )

Parameters: The method accepts two parameters:  

Return Value: The method returns the theta component of the point (p, angle) in polar coordinates that corresponds to the point (abscissa_val,ordinate_val).
Below programs illustrate the java.lang.StrictMath.atan2() method: 
Program 1:  






// Java program to illustrate the
// java.lang.StrictMath.atan2()
 
import java.lang.*;
 
public class Geeks{
 
public static void main(String[] args) {
 
    double abs_val = 0.3 , ord_val = 50.00;
     
    // It returns the theta component
    // in polar coordinates
    double atan2val = StrictMath.atan2(abs_val,
                                          ord_val);
    System.out.println("Arc tangent value is: "
                                        +atan2val);
 
}
}

Output: 
Arc tangent value is: 0.00599992800155516

 

Program 2: 




// Java program to illustrate the
// java.lang.StrictMath.atan2()
 
import java.lang.*;
 
public class Geeks{
 
public static void main(String[] args) {
 
    double abs_val = 0.3 , ord_val = -50.00;
     
    // It returns the theta component
    // in polar coordinates
 
    double atan2val = StrictMath.atan2(abs_val,
                                          ord_val);
    System.out.println("Arc tangent value is: "
                                        +atan2val);
 
}
}

Output: 
Arc tangent value is: 3.135592725588238

 

Program 3:  




// Java program to illustrate the
// java.lang.StrictMath.atan2()
 
import java.lang.*;
 
public class Geeks{
 
public static void main(String[] args) {
 
    double abs_val = -0.3 ,ord_val = 50.00;
     
    // It returns the theta component
    // in polar coordinates
 
    double atan2val = StrictMath.atan2(abs_val,
                                          ord_val);
    System.out.println("Arc tangent value is: "
                                        +atan2val);
 
}
}

Output: 
Arc tangent value is: -0.00599992800155516

 

Program 4: 




// Java program to illustrate the
// java.lang.StrictMath.atan2()
 
import java.lang.*;
 
public class Geeks{
 
public static void main(String[] args) {
 
    double abs_val = -0.3 , ord_val = -50.00;
     
    // It returns the theta component
    // in polar coordinates
 
    double atan2val = StrictMath.atan2(abs_val,
                                          ord_val);
    System.out.println("Arc tangent value is: "
                                        +atan2val);
 
}
}

Output: 
Arc tangent value is: -3.135592725588238

 


Article Tags :