|
发表于 2017-9-25 23:24:43
|
显示全部楼层
第四章4.6 我觉得做法是这样的,交流补充
public class t {
/**
* Creates a new instance of <code>t</code>.
*/
public t() {
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
double a=Math.random()*360;
double x1=40*Math.cos(Math.toRadians(a));
double y1=40*Math.sin(Math.toRadians(a));
double b=Math.random()*360;
double x2=40*Math.cos(Math.toRadians(b));
double y2=40*Math.sin(Math.toRadians(b));
double c=Math.random()*360;
double x3=40*Math.cos(Math.toRadians(c));
double y3=40*Math.sin(Math.toRadians(c));
double d1=Math.sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
double d2=Math.sqrt((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3));
double d3=Math.sqrt((x3-x2)*(x3-x2)+(y3-y2)*(y3-y2));
double A=Math.toDegrees(Math.acos((d1*d1-d2*d2-d3*d3)/(-2*d2*d3)));
double B=Math.toDegrees(Math.acos((d2*d2-d1*d1-d3*d3)/(-2*d1*d3)));
double C=Math.toDegrees(Math.acos((d3*d3-d2*d2-d1*d1)/(-2*d2*d1)));
System.out.println("("+x1+","+y1+")"+"("+x2+","+y2+")"+"("+x3+","+y3+")");
System.out.print(A+" "+B+" "+C);
// TODO code application logic here
}
}
|
|