在上述代码中,我们首先将角度转换为弧度,然后使用Math.cos方法计算余弦值。最后,我们使用System.out.println方法打印结果。 正切函数(tangent function) 正切函数表示一个角的正切值,可以用以下公式表示: tan(x) = opposite / adjacent 1. 在Java中,可以使用Math类的tan方法计算一个角的正切值。下面是一个示例代码...
int field2; @Expression("f1 * sin(f2) * log2(f1 + f2) + der(cos(f1), f1) * pi + int(tan(f2), f2, 0, e)") double field3; @Test public void example1Test() { Example1 example1 = new Example1(); example1.field1 = "2.2"; example1.field2 = 5; Calculator calculator =...
System.out.println("==="); double cos = Math.toRadians(45); System.out.println(cos); System.out.println(Math.cos(cos)); System.out.println("==="); double tan = Math.toRadians(45); System.out.println(tan); System.out.println(Math.tan(tan)); System.out.println("==="); double ...
publicclassTest{publicstaticvoidmain(String[]args){doublea=Math.toRadians(90);//把数字90 转换成 90度System.out.println(Math.sin(a));//计算sin 90度doubleb=Math.toRadians(30);System.out.println(Math.cos(b));doublec=Math.toRadians(20);System.out.println(Math.tan(c));}}...
@Expression("f1 * sin(f2) * log2(f1 + f2) + der(cos(f1), f1) * pi + int(tan(f2), f2, 0, e)") doublefield3; } @Test publicvoidexample1Test{ Example1 example1 =newExample1; example1.field1 ="2.2"; example1.field2 =5; ...
(cos(f1), f1) * pi + int(tan(f2), f2, 0, e)")double field3;}@Testpublicvoidexample1Test(){Example1 example1=newExample1();example1.field1="2.2";example1.field2=5;Calculator<Example1>calculator=MXFactory.createCalculator(Example1.class);calculator.calculate(example1);System.out....
根号有Math.sqrt()cos 也有Math.cos() Math.sin() Math.tan()
@Expression("f1 * sin(f2) * log2(f1 + f2) + der(cos(f1), f1) * pi + int(tan(f2), f2, 0, e)") double field3; } @Test public void example1Test() { Example1 example1 = new Example1(); example1.field1 = "2.2"; ...
你输出的45.00你自己认为是度数45°,其实是double = 45.00 你需要先转化45.00到度数,然后再用上边的 a / Math.cos(Math.toRadians(45.00))static double toRadians(double angdeg)Converts an angle measured in degrees to an approximately equivalent angle measured in radians.
tanAngleValue1/180;//求弧度值double tanValue1=Math.Tan(tanRadianValue1);//tan值Console.WriteLine(tanValue1);//tan值double tanValue2=1;//正切值double tanRadianValue2=Math.Atan(tanValue2);//求弧度值double tanAngleValue2=tanRadianValue2/Math.PI*180;//求角度Console.WriteLine(tanAngleValue2...