Latest web development tutorials

Java atan2 () method

Java Number classes Java Number classes


atan2 () method is used to rectangular coordinates (x, y) to polar (r, theta), returns the resulting angle theta. The method by calculating y / x arctangent calculating the phase angle theta, range from -pi to pi.

grammar

double atan2(double y, double x)

parameter

  • y - the ordinate.

  • x - abscissa.

return value

Corresponding to the midpoint of the polar coordinates (r, theta) with the Cartesian coordinates of the midpoint of the component theta (x, y).

Examples

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

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

Compile the above program, the output is:

0.982793723247329

Java Number classes Java Number classes