gpt4 book ai didi

java - 在Java中将余弦/正弦转换为角度

转载 作者:太空宇宙 更新时间:2023-11-04 07:06:02 26 4
gpt4 key购买 nike

一个简单的问题。我似乎找不到将余弦转换为辐射或度数的函数。在下面的代码中

public class angle{

public static void main (String[] args){
int a = 30;
int b = 40;
int y = 88;
double c = Math.sqrt((a*a) + (b*b) - (2*a*b*Math.cos(Math.toRadians(y))));
System.out.println("C = " + c);
double L = ((b*b) + (c*c) - (a*a))/(2*b*c);
System.out.println("Cos Alpha = " + L);
double B = ((a*a) + (c*c) - (b*b))/(2*a*c);
System.out.println("Cos Beta = " + B);

}
}

我有 L 和 B 作为余弦,但我需要它们作为辐射度。有人知道我应该使用什么功能吗?提前致谢。

最佳答案

Math类(class)适合您的需求。例如,下面的类计算角度的余弦。查看所有其他方法。

public class CosineTest{ 

public static void main(String args[]){
double degrees = 45.0; // put your value here
double radians = Math.toRadians(degrees); // look to the Math class..a lot of nice stuff here

System.out.format("The cosine of %.1f degrees is %.4f%n",
degrees, Math.cos(radians));

}
}

关于java - 在Java中将余弦/正弦转换为角度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21364703/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com