[fix] corrected an isNan test.
This commit is contained in:
parent
fa33c3d823
commit
5e3d230724
@ -1088,7 +1088,7 @@ public abstract class RocketComponent implements ChangeSource, Cloneable, Iterab
|
|||||||
if (EPSILON > Math.abs(newX)) {
|
if (EPSILON > Math.abs(newX)) {
|
||||||
newX = 0.0;
|
newX = 0.0;
|
||||||
}
|
}
|
||||||
if (Double.NaN == newX) {
|
if (Double.isNaN(newX)){
|
||||||
throw new BugException("setAxialOffset is broken -- attempted to update as NaN: " + this.toDebugDetail());
|
throw new BugException("setAxialOffset is broken -- attempted to update as NaN: " + this.toDebugDetail());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,29 +7,88 @@ public enum AxialMethod implements DistanceMethod {
|
|||||||
ABSOLUTE (Application.getTranslator().get("RocketComponent.Position.Method.Axial.ABSOLUTE")){
|
ABSOLUTE (Application.getTranslator().get("RocketComponent.Position.Method.Axial.ABSOLUTE")){
|
||||||
@Override
|
@Override
|
||||||
public boolean clampToZero() { return false; }
|
public boolean clampToZero() { return false; }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getAsPosition(double offset, double innerLength, double outerLength){
|
||||||
|
return offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getAsOffset(double position, double innerLength, double outerLength){
|
||||||
|
return position;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// subject component will trail the target component, in the increasing coordinate direction
|
// subject component will trail the target component, in the increasing coordinate direction
|
||||||
AFTER (Application.getTranslator().get("RocketComponent.Position.Method.Axial.AFTER")),
|
AFTER (Application.getTranslator().get("RocketComponent.Position.Method.Axial.AFTER")){
|
||||||
|
@Override
|
||||||
|
public boolean clampToZero() { return false; }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getAsPosition(double offset, double innerLength, double outerLength){
|
||||||
|
return outerLength + offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getAsOffset(double position, double innerLength, double outerLength){
|
||||||
|
return outerLength - position;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
// measure from the top of the target component to the top of the subject component
|
// measure from the top of the target component to the top of the subject component
|
||||||
TOP (Application.getTranslator().get("RocketComponent.Position.Method.Axial.TOP")){
|
TOP (Application.getTranslator().get("RocketComponent.Position.Method.Axial.TOP")){
|
||||||
@Override
|
@Override
|
||||||
public boolean clampToZero() { return false; }
|
public boolean clampToZero() { return false; }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getAsPosition(double offset, double innerLength, double outerLength){
|
||||||
|
return offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getAsOffset(double position, double innerLength, double outerLength){
|
||||||
|
return position;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// This coordinate is measured from the middle of the parent component to the middle of this component
|
// This coordinate is measured from the middle of the parent component to the middle of this component
|
||||||
MIDDLE (Application.getTranslator().get("RocketComponent.Position.Method.Axial.MIDDLE")){
|
MIDDLE (Application.getTranslator().get("RocketComponent.Position.Method.Axial.MIDDLE")) {
|
||||||
@Override
|
@Override
|
||||||
public boolean clampToZero() { return false; }
|
public boolean clampToZero() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getAsPosition(double offset, double innerLength, double outerLength){
|
||||||
|
return (outerLength - innerLength) / 2 - offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getAsOffset(double position, double innerLength, double outerLength){
|
||||||
|
return position + (innerLength - outerLength) / 2;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// This coordinate is measured from the bottom of the parent component to the bottom of this component
|
// This coordinate is measured from the bottom of the parent component to the bottom of this component
|
||||||
BOTTOM (Application.getTranslator().get("RocketComponent.Position.Method.Axial.BOTTOM")){
|
BOTTOM (Application.getTranslator().get("RocketComponent.Position.Method.Axial.BOTTOM")){
|
||||||
@Override
|
@Override
|
||||||
public boolean clampToZero() { return false; }
|
public boolean clampToZero() { return false; }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getAsPosition(double offset, double innerLength, double outerLength){
|
||||||
|
return outerLength - innerLength - offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getAsOffset(double position, double innerLength, double outerLength){
|
||||||
|
return position + (innerLength - outerLength);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// just as a reminder:
|
// just as a reminder:
|
||||||
// public T[] getEnumConstants()
|
// public T[] getEnumConstants()
|
||||||
|
|
||||||
@ -37,13 +96,16 @@ public enum AxialMethod implements DistanceMethod {
|
|||||||
|
|
||||||
public final String description;
|
public final String description;
|
||||||
|
|
||||||
private AxialMethod( final String newDescription ) {
|
AxialMethod( final String newDescription ) {
|
||||||
this.description=newDescription;
|
this.description=newDescription;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public abstract boolean clampToZero();
|
||||||
public boolean clampToZero() { return true; }
|
|
||||||
|
public abstract double getAsOffset(double position, double innerLength, double outerLength);
|
||||||
|
|
||||||
|
public abstract double getAsPosition(double offset, double innerLength, double outerLength);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return description;
|
return description;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user