Use higher precision for inches lengths
This commit is contained in:
parent
f4f6200662
commit
463895adb6
@ -4,9 +4,21 @@ package net.sf.openrocket.unit;
|
||||
* Special unit for inches, which always provides 3-decimal precision.
|
||||
*/
|
||||
public class InchUnit extends GeneralUnit {
|
||||
private final double precision;
|
||||
|
||||
public InchUnit(double multiplier, String unit) {
|
||||
this(multiplier, unit, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param multiplier
|
||||
* @param unit
|
||||
* @param precision The precision of the unit, in inches.
|
||||
*/
|
||||
public InchUnit(double multiplier, String unit, double precision) {
|
||||
super(multiplier, unit);
|
||||
this.precision = precision;
|
||||
}
|
||||
|
||||
|
||||
@ -16,5 +28,15 @@ public class InchUnit extends GeneralUnit {
|
||||
val = Math.rint(val * mul) / mul;
|
||||
return val;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getNextValue(double value) {
|
||||
return value + precision;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getPreviousValue(double value) {
|
||||
return value - precision;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ public class UnitGroup {
|
||||
UNITS_LENGTH.addUnit(new GeneralUnit(0.001, "mm"));
|
||||
UNITS_LENGTH.addUnit(new GeneralUnit(0.01, "cm"));
|
||||
UNITS_LENGTH.addUnit(new GeneralUnit(1, "m"));
|
||||
UNITS_LENGTH.addUnit(new InchUnit(0.0254, "in"));
|
||||
UNITS_LENGTH.addUnit(new InchUnit(0.0254, "in", 0.1));
|
||||
UNITS_LENGTH.addUnit(new FractionalUnit(0.0254, "in/64", "in", 64, 1d / 16d, 0.5d / 64d));
|
||||
UNITS_LENGTH.addUnit(new GeneralUnit(0.3048, "ft"));
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user