1、 检尺径自4~12厘米的小径原木材积由公式 V=0.7854L(D+0.45L+0.2)2÷10000确定。
2、 检尺径自14厘米以上的原木材积由公式 V=0.7854L[D+0.5L+0.005L2+0.000125L(14-L)2×(D-10)]2÷10000确定。两式中:V---材积,立方米;L---检尺长,米;D---检尺径,厘米。
package com.github.pig.auth;
import java.math.BigDecimal;
public class ExpressionUtil {
public static double v1(double L, double D) {
System.out.println("长度:"+L+"直径:"+D);
return 0.7854 * L * Math.pow((D + 0.45 * L + 0.2), 2) / 10000.0;
}
public static double v2(double L, double D) {
return 0.7854
* L
*Math.pow((D + 0.5 * L + 0.005 *Math.pow( L, 2) + 0.000125 * L * Math.pow((14 - L), 2)
* (D - 10)), 2) / 10000;
}
public static double calculation(double L, double D) {
double result = 0.0;
if (D >= 4 && D<= 12) {
result = v1(L, D);
}
if (D > 14) {
result = v2(L, D);
}
BigDecimal b = new BigDecimal(result);
double f1 = b.setScale(4, BigDecimal.ROUND_FLOOR).doubleValue();
return f1;
}
public static void main(String[] args) {
System.out.println(calculation(2.6,22));
}
}