2011-04-23 60 views
0

我建立y中的以下内容:极地表示,在Java

public class Point2 
{ 
    private double _radius , _alpha;  

    public Point2 (int x , int y) 
    { 
     _radius = Math.sqrt (Math.pow(x,2) + Math.pow (y,2)) ; 
     _alpha = Math.atan(y/x) ; 
    } 

} 

是坚持我的唯一的事情就是_alpha计算。 我在想如何操作这个使用Math类最短的和可读的方式... 我的方式行吗? 日Thnx

回答

1

我不知道Java,但可以肯定的只是使用atan2

_alpha = Math.atan2(y,x); 
+0

atan2是什么? – 2011-04-23 10:52:37

+0

已添加链接。 – YXD 2011-04-23 10:53:53

0

é先生是正确的,ATAN2似乎是要走的路。这里是适当的javadoc for atan2的链接。