Java 教程 Java atan2() 方法

jacques · 2022-05-24 23:07:32 · 热度: 22

atan2() 方法用于将矩形坐标 (x, y) 转换成极坐标 (r, theta),返回所得角 theta。该方法通过计算 y/x 的反正切值来计算相角 theta,范围为从 -pi 到 pi。

语法

double atan2(double y, double x)

参数

  • 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

查看更多 Java Number & Math 类 相关内容

猜你喜欢:
暂无回复。
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册