直角三角形两条直角边
(x,y)
直角边x
的对角为A
double tan = Math.atan2(x, y);
double angleA = 180 * tan /Math.PI;
如果x = 100 y = 100
,那么angleA
为45;需要注意的地方是 Math.atan2(x,y)
调用的 参数顺序
最后的角度要用180 * tan / Math.PI
来转换一下。
通过两条直角边算斜边长度
double z = Math.hypot(x, y);
通过斜边和角度 算两条直角边
//角度直接用的tan值,没有换成成角度
double hypotenuse ; //斜边长度
double tan ; //角度 ,tan值
hypotenuse*Math.cos(tan); //角度邻边
hypotenuse*Math.sin(tan); //角度对边