次の計算を使用して測定値を計算しましたが、問題は計算を度数ではなくラジアンで出力することです.私の質問は、計算を出力度数に変換する方法です.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!");
}
}
}