JAVAチュートリアルマニュアル
/ Java atan2() 方法
Java atan2() 方法
atan2() 方法用于將矩形坐標 (x, y) 轉換成極坐標 (r, theta),返回所得角 theta。該方法通過計算 y/x 的反正切值來計算相角 theta,范圍為從 -pi 到 pi。
語法
double atan2(double y, double x)
參數(shù)
y -- 縱坐標。
x -- 橫坐標。
返回值
與笛卡兒坐標中點 (x, y) 對應的極坐標中點 (r, theta) 的 theta 組件。
實例
public class Test{ public static void main(String args[]){double x = 45.0;double y = 30.0;System.out.println( Math.atan2(x, y) );}}
編譯以上程序,輸出結果為:
0.982793723247329