Android 使用数学函数(Math函数)

xiaoxiao2021-02-28  150

在编写代码时   有时候要用到函数来解决一些角度问题

之前上网查了很久,发现他们写的有的不好用......所以自己总结一下,方便自己,方便他人。

我该写成了工具类了,直接把工具类贴出来吧~~

public class MathUtils { public static double sinX (int x){ return Math.sin(Math.PI * x / 180); } public static double cosX (int x){ return Math.cos(Math.PI * x / 180); } }

OK,传入的int的参数就是角度了   

注意:是0~360的那个角度   不是弧度 

想要弧度的话  自己做一下数学转换就可以了。

转载请注明原文地址: https://www.6miu.com/read-22665.html

最新回复(0)