该方法将直角坐标(x,y)转换为极坐标(r,theta),并返回theta。
句法
- double atan2(double y, double x)
参数
- X - X co-ordinate in double data type
- Y - Y co-ordinate in double data type
返回值
此方法从极坐标(r,theta)返回theta。
例子
下面是一个使用这个方法的例子 -
- class Example {
- static void main(String[] args){
- double x = 45.0;
- double y = 30.0;
- System.out.println( Math.atan2(x, y) );
- }
- }
当我们运行上面的程序,我们将得到以下结果 -
- 0.982793723247329
转载本站内容时,请务必注明来自W3xue,违者必究。