我已经使用以下计算来计算测量值,但问题是它以弧度而不是度数输出计算。我的问题是如何将计算转换为输出度数。我知道 Math.toDegress 方法,但我在这种情况下无法实现它。这是我的 onCreate 计算完成的地方:
public void onClick(View v) {
// TODO Auto-generated method stub
try {
String getoffsetlength = data.offsetLength.getText().toString();
String getoffsetdepth = data.offsetDepth.getText().toString();
String getductdepth = data.ductDepth.getText().toString();
double tri1,tri2;
double marking1,marking2;
double off1 = Double.parseDouble(getoffsetlength);//length
double off2 = Double.parseDouble(getoffsetdepth);//depth
double off3 = Double.parseDouble(getductdepth);//duct depth
marking1 = Math.sqrt(Math.pow(off1,2) + Math.pow(off2,2));
tri1 = Math.atan(off2 / off1);
tri2 = (180 - tri1) / 2;
marking2 = off3 / Math.tan(tri2);
Intent myIntent = new Intent(MainActivity.this, CalcResult.class);
myIntent.putExtra("number1", marking1);
myIntent.putExtra("number2", marking2);
startActivity(myIntent);
//make a toast
Toast.makeText(getBaseContext(), "Calculating!", Toast.LENGTH_SHORT).show();
} catch (NumberFormatException e) {
// TODO: handle exception
System.out.println("Must enter a numeric value!");
}
}
}