StrictMath.atan2() in Java

StrictMath.atan2() : This method is available in java.lang.StrictMath class of Java.

Syntax:

double java.lang.StrictMath.atan2(double y, double x)

This method takes two arguments of type double as its parameters. This method returns the angle theta from the conversion of rectangular coordinates (x, y) to polar coordinates (r, theta). This method computes the phase theta by computing an arc tangent of y/x in the range of -pi to pi.

Parameters: Two parameters are required for this method.

y: the ordinate coordinate.

x: the abscissa coordinate.

Returns: the theta component of the point(r, theta)in polar coordinates that corresponds to the point(x, y) in Cartesian coordinates.

Exceptions: NA

Approach

Java

public class StrictMathatan2 {
    public static void main(String[] args) {

        double y = 12, x = 2;
        System.out.println(StrictMath.atan2(y, x));
    }
}

Output:

1.4056476493802699


No comments:

Post a Comment