Android文檔裡java.lang.Math.atan2的一個錯誤

來源:互聯網
上載者:User

Android文檔裡對Math.atan2這樣解釋的:

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

public static double atan2 (double x, double y)
Since: API Level 1
Returns the closest double approximation of the arc tangent of y/x within the range [-pi..pi]. This is the angle of the polar representation of the rectangular coordinates (x,y). The returned result is within 2 ulps (units in the last place) of the real result.

 

這裡說的是 返回的結果相當於 (第一個參數x,第二個參數y)點對應的角度,對應y/x的值。

 

但是用了下怎麼都不對。尤其是當x,y符號不同時更明顯。

 

對照了一下JDK1.6的文檔說明,原來是這樣的,返回的結果相當於 (第二個參數,第一個參數)對應的角度。

 

double java.lang.Math.atan2(double y, double x)
public static double atan2(double y, double x)
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. Special cases:
If either argument is NaN, then the result is NaN.

 

按JDK中這樣改就對了。

 

Android文檔裡竟然有這樣的錯誤,用Android2.2 SDK也是一樣的效果。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.