
正文
java中角度计算代码 java中角度如何表示
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
用java算sin 30°怎么编啊
java的Math类提供了各种常用计算方法,sin也是其中之一,所以你可以直接用Math.sin来计算正弦值。
代码如下:
import java.math.*;
public class sin
{
public static void main(String args[])
{
System.out.println(Math.sin(Math.PI*30/180));
}
}
需要注意的是,参数传入的是PI,所以要先用30除以180获得PI值
相关问答
Q1: java中角度怎么表示
java表示角度是用弧度来表示,比如30°,java写法如下:
int angel =30;
Math.PI * angel / 180;
Q2: JAVA计算三角函数公式
已经知道两条边和一个直角了,可以把另一条边求出来(根据A2+B2=C2),然后根据公式
cosA=(a2+b2-c2)/(2ab) 其中A为边a b的夹角!
Q3: Java编写计算器,计算器中计算sin,cos,tan的代码怎么写啊
public class SanJiao {
public static void main(String[] args) {
double a = Math.toRadians(90);//把数字90 转换成 90度
System.out.println(Math.sin(a));//计算sin 90度
double b = Math.toRadians(30);
System.out.println(Math.cos(b));
double c = Math.toRadians(20);
System.out.println(Math.tan(c));
}
}
运行输出
1.0
0.8660254037844387
0.36397023426620234
Q4: java程序计算三角形的角度,不知道哪里错了?
三角形的内角之和为 180度。
假设有三角形如下:
代码如下:
//Scanner sc = new Scanner(System.in);
//System.out.print("请输入坐标:");
double x1,y1,x2,y2,x3,y3;
x1 = 7; //sc.nextDouble();
y1 = 1; //sc.nextDouble();
x2 = 1; //sc.nextDouble();
y2 = 11; //sc.nextDouble();
x3 = 13; //sc.nextDouble();
y3 = 11; //sc.nextDouble();
double a,b,c;
a = Math.sqrt(Math.pow((x1-x2),2)+Math.pow((y1-y2),2));
b = Math.sqrt(Math.pow((x1-x3),2)+Math.pow((y1-y3),2));
c = Math.sqrt(Math.pow((x3-x2),2)+Math.pow((y3-y2),2));
double cosa,cosb,cosc;
cosa = (b*b+c*c-a*a)/(2*b*c);
cosb = (a*a+c*c-b*b)/(2*a*c);
cosc = (a*a+b*b-c*c)/(2*a*b);
System.out.println("a角度:"+Math.toDegrees(Math.acos(cosa)));
System.out.println("b角度:"+Math.toDegrees(Math.acos(cosb)));
System.out.println("c角度:"+Math.toDegrees(Math.acos(cosc)));
输出如下:
Q5: java arccos
java arccos是什么,让我们一起了解一下?
arccos是java中数学运算的三角函数方法,cos() 三角余弦,通过编程Java代码实现,常用的还有sin()为 三角正弦,tan() 三角正切,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中角度计算代码的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于java中角度如何表示、java中角度计算代码的信息别忘了在本站进行查找喔。






