Math中的方法
double b
b=sin(double a) 返回a角的三角正弦。
b=cos(double a) 返回a角的三角余弦。
java arctan是什么,让我们一起了解一下?
arctan是java中数学运算的三角函数方法,tan() 三角正切,通过编程Java代码实现,常用的还有cos() 三角余弦,sin()为 三角正弦,asin() 正弦的反函数,cos() 余弦的反函数,tan() 正切的反函数。
他的源代码如下:
public class MainTest { public static void main(String[] args) { //求sin值 double sin = Math.sin(3.14) System.out.println("sin3.14=" + sin) //求cos值 double cos = Math.cos(0) System.out.println("cos0=" + cos) //求tan值 double tan = Math.tan(0.785) System.out.println("tan0.785=" + tan) //求arcsin double arcsin = Math.asin(1) System.out.println("arcsin1 = " + arcsin) //求arccos double arccos = Math.acos(1) System.out.println("arccos = " + arccos) //求arctan double arctan = Math.atan(30) System.out.println("arctan30 = " + arctan) //求弧度 double radians = Math.toRadians(180) System.out.println("180度角的弧度为" + radians) //求角度 double angle = Math.toDegrees(3.141592653589793) System.out.println("π的角度数为" + angle) //求以e为底的指数 double exp = Math.exp(1) System.out.println("以e为底指数为1的数为" + exp) //求以e为底e的平方的对数 double log = Math.log(Math.E * Math.E) System.out.println("以e为底e的平方的对数" + log) //求以10为底100的对数 double log10 = Math.log10(100) System.out.println("以10为底100的对数" + log10) //求100的平方根 double sqrt = Math.sqrt(100) System.out.println("100的平方根是" + sqrt) //求27的立方根 double cbrt = Math.cbrt(27) System.out.println("27的立方根是" + cbrt) //求10除以3的余数 double rest = Math.IEEEremainder(10, 3) System.out.println("10除以3的余数为" + rest) //求0.9向上取整 double ceil = Math.ceil(0.9) System.out.println("0.9向上取整" + ceil) //求2.49向下取整 double floor = Math.floor(2.49) System.out.println("2.49向下取整" + floor) //求最接近参数的整数值(若有两个满足条件的数据则取为偶数的数据) double rint = Math.rint(3.5) System.out.println("最接近参数的整数值" + rint) //获得(1,1)坐标与x轴夹角度数 double atan2 = Math.atan2(1, 1) System.out.println("坐标(1,1)的极坐标为" + atan2) //求3的5次方 double pow = Math.pow(3, 5) System.out.println("3的5次方" + pow) //4舍5入 double round = Math.round(3.5) System.out.println("3.5四舍五入为" + round) //计算2
有这个工具包的,在java.math.Math类常中。
Math.PI 记录的圆周率
Math.sin 正弦函数
Math.asin 反正弦函数
Math.cos 余弦函数
Math.acos 反余弦函数
Math.tan 正切函数
Math.atan 反正切函数
Math.atan2 商的反正切函数
Math.toDegrees 弧度转化为角度
Math.toRadians 角度转化为弧度