Groovy - atan2()


Advertisements

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

Syntax

double atan2(double y, double x)

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

Following is an example of the usage of this method −

class Example {     
   static void main(String[] args){
      double x = 45.0;
      double y = 30.0;
		
      System.out.println( Math.atan2(x, y) );
   } 
}

When we run the above program, we will get the following result −

0.982793723247329
groovy_numbers.htm
Advertisements