Merge pull request #2176 from SiboVG/issue-2096
[#2096] Update values after auto is set
This commit is contained in:
commit
17d60c4d9b
@ -389,7 +389,7 @@ class DocumentConfig {
|
|||||||
|
|
||||||
// MassObject
|
// MassObject
|
||||||
setters.put("MassObject:packedlength", new DoubleSetter(
|
setters.put("MassObject:packedlength", new DoubleSetter(
|
||||||
Reflection.findMethod(MassObject.class, "setLengthNoAuto", double.class)));
|
Reflection.findMethod(MassObject.class, "setLength", double.class)));
|
||||||
setters.put("MassObject:packedradius", new DoubleSetter(
|
setters.put("MassObject:packedradius", new DoubleSetter(
|
||||||
Reflection.findMethod(MassObject.class, "setRadius", double.class),
|
Reflection.findMethod(MassObject.class, "setRadius", double.class),
|
||||||
"auto", " ",
|
"auto", " ",
|
||||||
|
@ -23,7 +23,7 @@ public class BodyTubeSaver extends SymmetricComponentSaver {
|
|||||||
net.sf.openrocket.rocketcomponent.BodyTube tube = (net.sf.openrocket.rocketcomponent.BodyTube) c;
|
net.sf.openrocket.rocketcomponent.BodyTube tube = (net.sf.openrocket.rocketcomponent.BodyTube) c;
|
||||||
|
|
||||||
if (tube.isOuterRadiusAutomatic()) {
|
if (tube.isOuterRadiusAutomatic()) {
|
||||||
elements.add("<radius>auto " + tube.getOuterRadiusNoAutomatic() + "</radius>");
|
elements.add("<radius>auto " + tube.getOuterRadius() + "</radius>");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
elements.add("<radius>" + tube.getOuterRadius() + "</radius>");
|
elements.add("<radius>" + tube.getOuterRadius() + "</radius>");
|
||||||
|
@ -13,11 +13,11 @@ public class MassObjectSaver extends InternalComponentSaver {
|
|||||||
|
|
||||||
MassObject mass = (MassObject) c;
|
MassObject mass = (MassObject) c;
|
||||||
|
|
||||||
elements.add("<packedlength>" + mass.getLengthNoAuto() + "</packedlength>");
|
elements.add("<packedlength>" + mass.getLength() + "</packedlength>");
|
||||||
if (mass.isRadiusAutomatic()) {
|
if (mass.isRadiusAutomatic()) {
|
||||||
elements.add("<packedradius>auto " + mass.getRadiusNoAuto() + "</packedradius>");
|
elements.add("<packedradius>auto " + mass.getRadius() + "</packedradius>");
|
||||||
} else {
|
} else {
|
||||||
elements.add("<packedradius>" + mass.getRadiusNoAuto() + "</packedradius>");
|
elements.add("<packedradius>" + mass.getRadius() + "</packedradius>");
|
||||||
}
|
}
|
||||||
elements.add("<radialposition>" + mass.getRadialPosition() + "</radialposition>");
|
elements.add("<radialposition>" + mass.getRadialPosition() + "</radialposition>");
|
||||||
elements.add("<radialdirection>" + (mass.getRadialDirection() * 180.0 / Math.PI)
|
elements.add("<radialdirection>" + (mass.getRadialDirection() * 180.0 / Math.PI)
|
||||||
|
@ -27,7 +27,7 @@ public class NoseConeSaver extends TransitionSaver {
|
|||||||
super.addParams(c, elements);
|
super.addParams(c, elements);
|
||||||
|
|
||||||
if (noseCone.isBaseRadiusAutomatic())
|
if (noseCone.isBaseRadiusAutomatic())
|
||||||
elements.add("<aftradius>auto " + noseCone.getBaseRadiusNoAutomatic() + "</aftradius>");
|
elements.add("<aftradius>auto " + noseCone.getBaseRadius() + "</aftradius>");
|
||||||
else
|
else
|
||||||
elements.add("<aftradius>" + noseCone.getBaseRadius() + "</aftradius>");
|
elements.add("<aftradius>" + noseCone.getBaseRadius() + "</aftradius>");
|
||||||
|
|
||||||
|
@ -46,12 +46,12 @@ public class TransitionSaver extends SymmetricComponentSaver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (trans.isForeRadiusAutomatic())
|
if (trans.isForeRadiusAutomatic())
|
||||||
elements.add("<foreradius>auto " + trans.getForeRadiusNoAutomatic() + "</foreradius>");
|
elements.add("<foreradius>auto " + trans.getForeRadius() + "</foreradius>");
|
||||||
else
|
else
|
||||||
elements.add("<foreradius>" + trans.getForeRadius() + "</foreradius>");
|
elements.add("<foreradius>" + trans.getForeRadius() + "</foreradius>");
|
||||||
|
|
||||||
if (trans.isAftRadiusAutomatic())
|
if (trans.isAftRadiusAutomatic())
|
||||||
elements.add("<aftradius>auto " + trans.getAftRadiusNoAutomatic() + "</aftradius>");
|
elements.add("<aftradius>auto " + trans.getAftRadius() + "</aftradius>");
|
||||||
else
|
else
|
||||||
elements.add("<aftradius>" + trans.getAftRadius() + "</aftradius>");
|
elements.add("<aftradius>" + trans.getAftRadius() + "</aftradius>");
|
||||||
|
|
||||||
|
@ -75,6 +75,16 @@ public class BodyTube extends SymmetricComponent implements BoxBounded, MotorMou
|
|||||||
@Override
|
@Override
|
||||||
public double getOuterRadius() {
|
public double getOuterRadius() {
|
||||||
if (autoRadius) {
|
if (autoRadius) {
|
||||||
|
outerRadius = getAutoOuterRadius();
|
||||||
|
}
|
||||||
|
return outerRadius;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the automatic outer radius, taken from the previous/next component. Returns the default radius if there
|
||||||
|
* is no previous/next component.
|
||||||
|
*/
|
||||||
|
private double getAutoOuterRadius() {
|
||||||
// Return auto radius from front or rear
|
// Return auto radius from front or rear
|
||||||
double r = -1;
|
double r = -1;
|
||||||
SymmetricComponent c = this.getPreviousSymmetricComponent();
|
SymmetricComponent c = this.getPreviousSymmetricComponent();
|
||||||
@ -95,16 +105,6 @@ public class BodyTube extends SymmetricComponent implements BoxBounded, MotorMou
|
|||||||
r = DEFAULT_RADIUS;
|
r = DEFAULT_RADIUS;
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
return outerRadius;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the outer radius that was manually entered, so not the value that the component received from automatic
|
|
||||||
* outer radius.
|
|
||||||
*/
|
|
||||||
public double getOuterRadiusNoAutomatic() {
|
|
||||||
return outerRadius;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the outer radius of the body tube. If the radius is less than the wall thickness,
|
* Set the outer radius of the body tube. If the radius is less than the wall thickness,
|
||||||
|
@ -23,6 +23,7 @@ public abstract class MassObject extends InternalComponent {
|
|||||||
|
|
||||||
protected double radius;
|
protected double radius;
|
||||||
private boolean autoRadius = false;
|
private boolean autoRadius = false;
|
||||||
|
private double volume; // (Packed) volume of the object
|
||||||
|
|
||||||
private double radialPosition;
|
private double radialPosition;
|
||||||
private double radialDirection;
|
private double radialDirection;
|
||||||
@ -40,6 +41,7 @@ public abstract class MassObject extends InternalComponent {
|
|||||||
|
|
||||||
this.length = length;
|
this.length = length;
|
||||||
this.radius = radius;
|
this.radius = radius;
|
||||||
|
updateVolume(radius);
|
||||||
|
|
||||||
this.setAxialMethod( AxialMethod.TOP);
|
this.setAxialMethod( AxialMethod.TOP);
|
||||||
this.setAxialOffset(0.0);
|
this.setAxialOffset(0.0);
|
||||||
@ -50,40 +52,18 @@ public abstract class MassObject extends InternalComponent {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateVolume(double radius) {
|
||||||
|
volume = Math.pow(radius, 2) * length; // Math.PI left out, not needed
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getLength() {
|
public double getLength() {
|
||||||
if (this.autoRadius) {
|
if (autoRadius) {
|
||||||
// Calculate the volume using the non auto radius and the non auto length, and transform that back
|
length = getAutoLength();
|
||||||
// to the auto radius situation to get the auto radius length (the volume in both situations is the same).
|
|
||||||
double volume = Math.pow(this.radius, 2) * this.length; // Math.PI left out, not needed
|
|
||||||
return volume / Math.pow(getRadius(), 2);
|
|
||||||
}
|
}
|
||||||
return length;
|
return length;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getLengthNoAuto() {
|
|
||||||
return length;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the length, ignoring the auto radius setting.
|
|
||||||
* @param length new length
|
|
||||||
*/
|
|
||||||
public void setLengthNoAuto(double length) {
|
|
||||||
for (RocketComponent listener : configListeners) {
|
|
||||||
if (listener instanceof MassObject) {
|
|
||||||
((MassObject) listener).setLengthNoAuto(length);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
length = Math.max(length, 0);
|
|
||||||
if (MathUtil.equals(this.length, length)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.length = length;
|
|
||||||
fireComponentChangeEvent(ComponentChangeEvent.MASS_CHANGE);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLength(double length) {
|
public void setLength(double length) {
|
||||||
for (RocketComponent listener : configListeners) {
|
for (RocketComponent listener : configListeners) {
|
||||||
if (listener instanceof MassObject) {
|
if (listener instanceof MassObject) {
|
||||||
@ -92,26 +72,39 @@ public abstract class MassObject extends InternalComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
length = Math.max(length, 0);
|
length = Math.max(length, 0);
|
||||||
if (this.autoRadius) {
|
|
||||||
// Calculate the volume using the auto radius and the new "auto" length, and transform that back
|
|
||||||
// to the non auto radius situation to set this.length (the volume in both situations is the same).
|
|
||||||
double volume = Math.pow(getRadius(), 2) * length; // Math.PI left out, not needed
|
|
||||||
double newLength = volume / Math.pow(this.radius, 2);
|
|
||||||
if (MathUtil.equals(this.length, newLength))
|
|
||||||
return;
|
|
||||||
this.length = newLength;
|
|
||||||
} else {
|
|
||||||
if (MathUtil.equals(this.length, length)) {
|
if (MathUtil.equals(this.length, length)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.length = length;
|
this.length = length;
|
||||||
}
|
updateVolume(autoRadius ? getAutoRadius() : radius);
|
||||||
|
|
||||||
fireComponentChangeEvent(ComponentChangeEvent.MASS_CHANGE);
|
fireComponentChangeEvent(ComponentChangeEvent.MASS_CHANGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate the length from the current volume.
|
||||||
|
*/
|
||||||
|
private double getAutoLength() {
|
||||||
|
// Calculate the volume using the auto radius and the new "auto" length, and transform that back
|
||||||
|
// to the non auto radius situation to set this.length (the volume in both situations is the same).
|
||||||
|
return volume / Math.pow(radius, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public double getRadius() {
|
public double getRadius() {
|
||||||
if (autoRadius) {
|
if (autoRadius) {
|
||||||
|
radius = getAutoRadius();
|
||||||
|
length = getAutoLength();
|
||||||
|
}
|
||||||
|
return radius;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the radius determined by its parent component.
|
||||||
|
* @return the radius determined by its parent component
|
||||||
|
*/
|
||||||
|
public double getAutoRadius() {
|
||||||
if (parent == null) {
|
if (parent == null) {
|
||||||
return radius;
|
return radius;
|
||||||
}
|
}
|
||||||
@ -126,11 +119,7 @@ public abstract class MassObject extends InternalComponent {
|
|||||||
} else if (parent instanceof RingComponent) {
|
} else if (parent instanceof RingComponent) {
|
||||||
return ((RingComponent) parent).getInnerRadius();
|
return ((RingComponent) parent).getInnerRadius();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return radius;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getRadiusNoAuto() {
|
|
||||||
return radius;
|
return radius;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,6 +137,7 @@ public abstract class MassObject extends InternalComponent {
|
|||||||
|
|
||||||
this.autoRadius = false;
|
this.autoRadius = false;
|
||||||
this.radius = radius;
|
this.radius = radius;
|
||||||
|
updateVolume(radius);
|
||||||
fireComponentChangeEvent(ComponentChangeEvent.MASS_CHANGE);
|
fireComponentChangeEvent(ComponentChangeEvent.MASS_CHANGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,10 +157,6 @@ public abstract class MassObject extends InternalComponent {
|
|||||||
|
|
||||||
autoRadius = auto;
|
autoRadius = auto;
|
||||||
|
|
||||||
// Set the length
|
|
||||||
double volume = (Math.PI * Math.pow(getRadius(), 2) * length);
|
|
||||||
length = volume / (Math.PI * Math.pow(getRadius(), 2));
|
|
||||||
|
|
||||||
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
|
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,14 +52,6 @@ public class NoseCone extends Transition implements InsideColorComponent {
|
|||||||
return isFlipped ? getForeRadius() : getAftRadius();
|
return isFlipped ? getForeRadius() : getAftRadius();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the raw base radius of the nose cone (independent of whether the nose cone is flipped or not).
|
|
||||||
* This method should be used over {@link #getAftRadiusNoAutomatic()} because it works for both normal and flipped nose cones.
|
|
||||||
*/
|
|
||||||
public double getBaseRadiusNoAutomatic() {
|
|
||||||
return isFlipped ? getForeRadiusNoAutomatic() : getAftRadiusNoAutomatic();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the base radius of the nose cone (independent of whether the nose cone is flipped or not).
|
* Sets the base radius of the nose cone (independent of whether the nose cone is flipped or not).
|
||||||
* This method should be used over {@link #setAftRadius(double)} because it works for both normal and flipped nose cones.
|
* This method should be used over {@link #setAftRadius(double)} because it works for both normal and flipped nose cones.
|
||||||
@ -203,7 +195,7 @@ public class NoseCone extends Transition implements InsideColorComponent {
|
|||||||
boolean previousByPass = isBypassComponentChangeEvent();
|
boolean previousByPass = isBypassComponentChangeEvent();
|
||||||
setBypassChangeEvent(true);
|
setBypassChangeEvent(true);
|
||||||
if (flipped) {
|
if (flipped) {
|
||||||
setForeRadius(getAftRadiusNoAutomatic());
|
setForeRadius(getAftRadius());
|
||||||
setForeRadiusAutomatic(isAftRadiusAutomatic(), sanityCheck);
|
setForeRadiusAutomatic(isAftRadiusAutomatic(), sanityCheck);
|
||||||
setForeShoulderLength(getAftShoulderLength());
|
setForeShoulderLength(getAftShoulderLength());
|
||||||
setForeShoulderRadius(getAftShoulderRadius());
|
setForeShoulderRadius(getAftShoulderRadius());
|
||||||
@ -212,7 +204,7 @@ public class NoseCone extends Transition implements InsideColorComponent {
|
|||||||
|
|
||||||
resetAftRadius();
|
resetAftRadius();
|
||||||
} else {
|
} else {
|
||||||
setAftRadius(getForeRadiusNoAutomatic());
|
setAftRadius(getForeRadius());
|
||||||
setAftRadiusAutomatic(isForeRadiusAutomatic(), sanityCheck);
|
setAftRadiusAutomatic(isForeRadiusAutomatic(), sanityCheck);
|
||||||
setAftShoulderLength(getForeShoulderLength());
|
setAftShoulderLength(getForeShoulderLength());
|
||||||
setAftShoulderRadius(getForeShoulderRadius());
|
setAftShoulderRadius(getForeShoulderRadius());
|
||||||
|
@ -77,7 +77,7 @@ public class Transition extends SymmetricComponent implements InsideColorCompone
|
|||||||
@Override
|
@Override
|
||||||
public double getForeRadius() {
|
public double getForeRadius() {
|
||||||
if (isForeRadiusAutomatic()) {
|
if (isForeRadiusAutomatic()) {
|
||||||
return getAutoForeRadius();
|
foreRadius = getAutoForeRadius();
|
||||||
}
|
}
|
||||||
return foreRadius;
|
return foreRadius;
|
||||||
}
|
}
|
||||||
@ -95,14 +95,6 @@ public class Transition extends SymmetricComponent implements InsideColorCompone
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the fore radius that was manually entered, so not the value that the component received from automatic
|
|
||||||
* fore radius.
|
|
||||||
*/
|
|
||||||
public double getForeRadiusNoAutomatic() {
|
|
||||||
return foreRadius;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the new fore radius, with option to clamp the thickness to the new radius if it's too large.
|
* Set the new fore radius, with option to clamp the thickness to the new radius if it's too large.
|
||||||
* @param radius new radius
|
* @param radius new radius
|
||||||
@ -174,7 +166,7 @@ public class Transition extends SymmetricComponent implements InsideColorCompone
|
|||||||
@Override
|
@Override
|
||||||
public double getAftRadius() {
|
public double getAftRadius() {
|
||||||
if (isAftRadiusAutomatic()) {
|
if (isAftRadiusAutomatic()) {
|
||||||
return getAutoAftRadius();
|
aftRadius = getAutoAftRadius();
|
||||||
}
|
}
|
||||||
return aftRadius;
|
return aftRadius;
|
||||||
}
|
}
|
||||||
@ -192,14 +184,6 @@ public class Transition extends SymmetricComponent implements InsideColorCompone
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the aft radius that was manually entered, so not the value that the component received from automatic
|
|
||||||
* zft radius.
|
|
||||||
*/
|
|
||||||
public double getAftRadiusNoAutomatic() {
|
|
||||||
return aftRadius;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the new aft radius, with option to clamp the thickness to the new radius if it's too large.
|
* Set the new aft radius, with option to clamp the thickness to the new radius if it's too large.
|
||||||
* @param radius new radius
|
* @param radius new radius
|
||||||
|
@ -21,20 +21,14 @@ public class MassObjectTest extends BaseTestCase {
|
|||||||
mo.setLength(0.1);
|
mo.setLength(0.1);
|
||||||
Assert.assertEquals(String.format(" No auto %s incorrect radius", mo.getClass().getName()),
|
Assert.assertEquals(String.format(" No auto %s incorrect radius", mo.getClass().getName()),
|
||||||
0.1, mo.getRadius(), MathUtil.EPSILON);
|
0.1, mo.getRadius(), MathUtil.EPSILON);
|
||||||
Assert.assertEquals(String.format(" No auto %s incorrect no auto radius", mo.getClass().getName()),
|
|
||||||
0.1, mo.getRadiusNoAuto(),MathUtil.EPSILON);
|
|
||||||
Assert.assertEquals(String.format(" No auto %s incorrect length", mo.getClass().getName()),
|
Assert.assertEquals(String.format(" No auto %s incorrect length", mo.getClass().getName()),
|
||||||
0.1, mo.getLength(), MathUtil.EPSILON);
|
0.1, mo.getLength(), MathUtil.EPSILON);
|
||||||
Assert.assertEquals(String.format(" No auto %s incorrect no auto length", mo.getClass().getName()),
|
|
||||||
0.1, mo.getLengthNoAuto(), MathUtil.EPSILON);
|
|
||||||
Assert.assertEquals(String.format(" No auto %s incorrect CG", mo.getClass().getName()),
|
Assert.assertEquals(String.format(" No auto %s incorrect CG", mo.getClass().getName()),
|
||||||
0.05, mo.getComponentCG().x, MathUtil.EPSILON);
|
0.05, mo.getComponentCG().x, MathUtil.EPSILON);
|
||||||
|
|
||||||
mo.setLengthNoAuto(0.1);
|
mo.setLength(0.1);
|
||||||
Assert.assertEquals(String.format(" No auto 2 %s incorrect length", mo.getClass().getName()),
|
Assert.assertEquals(String.format(" No auto 2 %s incorrect length", mo.getClass().getName()),
|
||||||
0.1, mo.getLength(), MathUtil.EPSILON);
|
0.1, mo.getLength(), MathUtil.EPSILON);
|
||||||
Assert.assertEquals(String.format(" No auto 2 %s incorrect no auto length", mo.getClass().getName()),
|
|
||||||
0.1, mo.getLengthNoAuto(), MathUtil.EPSILON);
|
|
||||||
Assert.assertEquals(String.format(" No auto %s incorrect CG", mo.getClass().getName()),
|
Assert.assertEquals(String.format(" No auto %s incorrect CG", mo.getClass().getName()),
|
||||||
0.05, mo.getComponentCG().x, MathUtil.EPSILON);
|
0.05, mo.getComponentCG().x, MathUtil.EPSILON);
|
||||||
|
|
||||||
@ -46,12 +40,8 @@ public class MassObjectTest extends BaseTestCase {
|
|||||||
mo.setRadiusAutomatic(true);
|
mo.setRadiusAutomatic(true);
|
||||||
Assert.assertEquals(String.format(" Auto 1 %s incorrect radius", mo.getClass().getName()),
|
Assert.assertEquals(String.format(" Auto 1 %s incorrect radius", mo.getClass().getName()),
|
||||||
0.05, mo.getRadius(), MathUtil.EPSILON);
|
0.05, mo.getRadius(), MathUtil.EPSILON);
|
||||||
Assert.assertEquals(String.format(" Auto 1 %s incorrect no auto radius", mo.getClass().getName()),
|
|
||||||
0.1, mo.getRadiusNoAuto(), MathUtil.EPSILON);
|
|
||||||
Assert.assertEquals(String.format(" Auto 1 %s incorrect length", mo.getClass().getName()),
|
Assert.assertEquals(String.format(" Auto 1 %s incorrect length", mo.getClass().getName()),
|
||||||
0.4, mo.getLength(), MathUtil.EPSILON);
|
0.4, mo.getLength(), MathUtil.EPSILON);
|
||||||
Assert.assertEquals(String.format(" Auto 1 %s incorrect no auto length", mo.getClass().getName()),
|
|
||||||
0.1, mo.getLengthNoAuto(), MathUtil.EPSILON);
|
|
||||||
Assert.assertEquals(String.format(" Auto 1 %s incorrect CG", mo.getClass().getName()),
|
Assert.assertEquals(String.format(" Auto 1 %s incorrect CG", mo.getClass().getName()),
|
||||||
0.2, mo.getComponentCG().x, MathUtil.EPSILON);
|
0.2, mo.getComponentCG().x, MathUtil.EPSILON);
|
||||||
|
|
||||||
@ -59,12 +49,8 @@ public class MassObjectTest extends BaseTestCase {
|
|||||||
parent.setInnerRadius(0.1);
|
parent.setInnerRadius(0.1);
|
||||||
Assert.assertEquals(String.format(" Auto 2 %s incorrect radius", mo.getClass().getName()),
|
Assert.assertEquals(String.format(" Auto 2 %s incorrect radius", mo.getClass().getName()),
|
||||||
0.1, mo.getRadius(), MathUtil.EPSILON);
|
0.1, mo.getRadius(), MathUtil.EPSILON);
|
||||||
Assert.assertEquals(String.format(" Auto 2 %s incorrect no auto radius", mo.getClass().getName()),
|
|
||||||
0.1, mo.getRadiusNoAuto(), MathUtil.EPSILON);
|
|
||||||
Assert.assertEquals(String.format(" Auto 2 %s incorrect length", mo.getClass().getName()),
|
Assert.assertEquals(String.format(" Auto 2 %s incorrect length", mo.getClass().getName()),
|
||||||
0.1, mo.getLength(), MathUtil.EPSILON);
|
0.1, mo.getLength(), MathUtil.EPSILON);
|
||||||
Assert.assertEquals(String.format(" Auto 2 %s incorrect no auto length", mo.getClass().getName()),
|
|
||||||
0.1, mo.getLengthNoAuto(), MathUtil.EPSILON);
|
|
||||||
Assert.assertEquals(String.format(" Auto 2 %s incorrect CG", mo.getClass().getName()),
|
Assert.assertEquals(String.format(" Auto 2 %s incorrect CG", mo.getClass().getName()),
|
||||||
0.05, mo.getComponentCG().x, MathUtil.EPSILON);
|
0.05, mo.getComponentCG().x, MathUtil.EPSILON);
|
||||||
|
|
||||||
@ -73,26 +59,18 @@ public class MassObjectTest extends BaseTestCase {
|
|||||||
mo.setLength(0.075);
|
mo.setLength(0.075);
|
||||||
Assert.assertEquals(String.format(" Auto 3 %s incorrect radius", mo.getClass().getName()),
|
Assert.assertEquals(String.format(" Auto 3 %s incorrect radius", mo.getClass().getName()),
|
||||||
0.075, mo.getRadius(), MathUtil.EPSILON);
|
0.075, mo.getRadius(), MathUtil.EPSILON);
|
||||||
Assert.assertEquals(String.format(" Auto 3 %s incorrect no auto radius", mo.getClass().getName()),
|
|
||||||
0.1, mo.getRadiusNoAuto(), MathUtil.EPSILON);
|
|
||||||
Assert.assertEquals(String.format(" Auto 3 %s incorrect length", mo.getClass().getName()),
|
Assert.assertEquals(String.format(" Auto 3 %s incorrect length", mo.getClass().getName()),
|
||||||
0.075, mo.getLength(), MathUtil.EPSILON);
|
0.075, mo.getLength(), MathUtil.EPSILON);
|
||||||
Assert.assertEquals(String.format(" Auto 3 %s incorrect no auto length", mo.getClass().getName()),
|
|
||||||
0.0422, mo.getLengthNoAuto(), 0.001);
|
|
||||||
Assert.assertEquals(String.format(" Auto 3 %s incorrect CG", mo.getClass().getName()),
|
Assert.assertEquals(String.format(" Auto 3 %s incorrect CG", mo.getClass().getName()),
|
||||||
0.0375, mo.getComponentCG().x, MathUtil.EPSILON);
|
0.0375, mo.getComponentCG().x, MathUtil.EPSILON);
|
||||||
|
|
||||||
mo.setLengthNoAuto(0.05);
|
mo.setLength(0.05);
|
||||||
Assert.assertEquals(String.format(" Auto 4 %s incorrect radius", mo.getClass().getName()),
|
Assert.assertEquals(String.format(" Auto 4 %s incorrect radius", mo.getClass().getName()),
|
||||||
0.075, mo.getRadius(), MathUtil.EPSILON);
|
0.075, mo.getRadius(), MathUtil.EPSILON);
|
||||||
Assert.assertEquals(String.format(" Auto 4 %s incorrect no auto radius", mo.getClass().getName()),
|
|
||||||
0.1, mo.getRadiusNoAuto(), MathUtil.EPSILON);
|
|
||||||
Assert.assertEquals(String.format(" Auto 4 %s incorrect length", mo.getClass().getName()),
|
Assert.assertEquals(String.format(" Auto 4 %s incorrect length", mo.getClass().getName()),
|
||||||
0.0889, mo.getLength(), 0.001);
|
0.05, mo.getLength(), 0.001);
|
||||||
Assert.assertEquals(String.format(" Auto 4 %s incorrect no auto length", mo.getClass().getName()),
|
|
||||||
0.05, mo.getLengthNoAuto(), MathUtil.EPSILON);
|
|
||||||
Assert.assertEquals(String.format(" Auto 4 %s incorrect CG", mo.getClass().getName()),
|
Assert.assertEquals(String.format(" Auto 4 %s incorrect CG", mo.getClass().getName()),
|
||||||
0.044444444444, mo.getComponentCG().x, MathUtil.EPSILON);
|
0.025, mo.getComponentCG().x, MathUtil.EPSILON);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,8 +31,8 @@ public class NoseConeTest extends BaseTestCase {
|
|||||||
assertEquals(0.06, noseCone.getLength(), EPSILON);
|
assertEquals(0.06, noseCone.getLength(), EPSILON);
|
||||||
assertEquals(0.1, noseCone.getAftRadius(), EPSILON);
|
assertEquals(0.1, noseCone.getAftRadius(), EPSILON);
|
||||||
assertEquals(0.1, noseCone.getBaseRadius(), EPSILON);
|
assertEquals(0.1, noseCone.getBaseRadius(), EPSILON);
|
||||||
assertEquals(0.1, noseCone.getAftRadiusNoAutomatic(), EPSILON);
|
assertEquals(0.1, noseCone.getAftRadius(), EPSILON);
|
||||||
assertEquals(0.1, noseCone.getBaseRadiusNoAutomatic(), EPSILON);
|
assertEquals(0.1, noseCone.getBaseRadius(), EPSILON);
|
||||||
assertEquals(0.01, noseCone.getAftShoulderLength(), EPSILON);
|
assertEquals(0.01, noseCone.getAftShoulderLength(), EPSILON);
|
||||||
assertEquals(0.01, noseCone.getShoulderLength(), EPSILON);
|
assertEquals(0.01, noseCone.getShoulderLength(), EPSILON);
|
||||||
assertEquals(0.05, noseCone.getAftShoulderRadius(), EPSILON);
|
assertEquals(0.05, noseCone.getAftShoulderRadius(), EPSILON);
|
||||||
@ -44,7 +44,7 @@ public class NoseConeTest extends BaseTestCase {
|
|||||||
assertFalse(noseCone.isAftRadiusAutomatic());
|
assertFalse(noseCone.isAftRadiusAutomatic());
|
||||||
|
|
||||||
assertEquals(0, noseCone.getForeRadius(), EPSILON);
|
assertEquals(0, noseCone.getForeRadius(), EPSILON);
|
||||||
assertEquals(0, noseCone.getForeRadiusNoAutomatic(), EPSILON);
|
assertEquals(0, noseCone.getForeRadius(), EPSILON);
|
||||||
assertEquals(0, noseCone.getForeShoulderLength(), EPSILON);
|
assertEquals(0, noseCone.getForeShoulderLength(), EPSILON);
|
||||||
assertEquals(0, noseCone.getForeShoulderRadius(), EPSILON);
|
assertEquals(0, noseCone.getForeShoulderRadius(), EPSILON);
|
||||||
assertEquals(0, noseCone.getForeShoulderThickness(), EPSILON);
|
assertEquals(0, noseCone.getForeShoulderThickness(), EPSILON);
|
||||||
@ -60,8 +60,8 @@ public class NoseConeTest extends BaseTestCase {
|
|||||||
|
|
||||||
assertEquals(0.2, noseCone.getAftRadius(), EPSILON);
|
assertEquals(0.2, noseCone.getAftRadius(), EPSILON);
|
||||||
assertEquals(0.2, noseCone.getBaseRadius(), EPSILON);
|
assertEquals(0.2, noseCone.getBaseRadius(), EPSILON);
|
||||||
assertEquals(0.2, noseCone.getAftRadiusNoAutomatic(), EPSILON);
|
assertEquals(0.2, noseCone.getAftRadius(), EPSILON);
|
||||||
assertEquals(0.2, noseCone.getBaseRadiusNoAutomatic(), EPSILON);
|
assertEquals(0.2, noseCone.getBaseRadius(), EPSILON);
|
||||||
assertEquals(0.03, noseCone.getAftShoulderLength(), EPSILON);
|
assertEquals(0.03, noseCone.getAftShoulderLength(), EPSILON);
|
||||||
assertEquals(0.03, noseCone.getShoulderLength(), EPSILON);
|
assertEquals(0.03, noseCone.getShoulderLength(), EPSILON);
|
||||||
assertEquals(0.04, noseCone.getAftShoulderRadius(), EPSILON);
|
assertEquals(0.04, noseCone.getAftShoulderRadius(), EPSILON);
|
||||||
@ -73,7 +73,7 @@ public class NoseConeTest extends BaseTestCase {
|
|||||||
assertFalse(noseCone.isAftRadiusAutomatic());
|
assertFalse(noseCone.isAftRadiusAutomatic());
|
||||||
|
|
||||||
assertEquals(0, noseCone.getForeRadius(), EPSILON);
|
assertEquals(0, noseCone.getForeRadius(), EPSILON);
|
||||||
assertEquals(0, noseCone.getForeRadiusNoAutomatic(), EPSILON);
|
assertEquals(0, noseCone.getForeRadius(), EPSILON);
|
||||||
assertEquals(0, noseCone.getForeShoulderLength(), EPSILON);
|
assertEquals(0, noseCone.getForeShoulderLength(), EPSILON);
|
||||||
assertEquals(0, noseCone.getForeShoulderRadius(), EPSILON);
|
assertEquals(0, noseCone.getForeShoulderRadius(), EPSILON);
|
||||||
assertEquals(0, noseCone.getForeShoulderThickness(), EPSILON);
|
assertEquals(0, noseCone.getForeShoulderThickness(), EPSILON);
|
||||||
@ -99,8 +99,8 @@ public class NoseConeTest extends BaseTestCase {
|
|||||||
assertEquals(0.06, noseCone.getLength(), EPSILON);
|
assertEquals(0.06, noseCone.getLength(), EPSILON);
|
||||||
assertEquals(0.1, noseCone.getForeRadius(), EPSILON);
|
assertEquals(0.1, noseCone.getForeRadius(), EPSILON);
|
||||||
assertEquals(0.1, noseCone.getBaseRadius(), EPSILON);
|
assertEquals(0.1, noseCone.getBaseRadius(), EPSILON);
|
||||||
assertEquals(0.1, noseCone.getForeRadiusNoAutomatic(), EPSILON);
|
assertEquals(0.1, noseCone.getForeRadius(), EPSILON);
|
||||||
assertEquals(0.1, noseCone.getBaseRadiusNoAutomatic(), EPSILON);
|
assertEquals(0.1, noseCone.getBaseRadius(), EPSILON);
|
||||||
assertEquals(0.01, noseCone.getForeShoulderLength(), EPSILON);
|
assertEquals(0.01, noseCone.getForeShoulderLength(), EPSILON);
|
||||||
assertEquals(0.01, noseCone.getShoulderLength(), EPSILON);
|
assertEquals(0.01, noseCone.getShoulderLength(), EPSILON);
|
||||||
assertEquals(0.05, noseCone.getForeShoulderRadius(), EPSILON);
|
assertEquals(0.05, noseCone.getForeShoulderRadius(), EPSILON);
|
||||||
@ -112,7 +112,7 @@ public class NoseConeTest extends BaseTestCase {
|
|||||||
assertFalse(noseCone.isForeRadiusAutomatic());
|
assertFalse(noseCone.isForeRadiusAutomatic());
|
||||||
|
|
||||||
assertEquals(0, noseCone.getAftRadius(), EPSILON);
|
assertEquals(0, noseCone.getAftRadius(), EPSILON);
|
||||||
assertEquals(0, noseCone.getAftRadiusNoAutomatic(), EPSILON);
|
assertEquals(0, noseCone.getAftRadius(), EPSILON);
|
||||||
assertEquals(0, noseCone.getAftShoulderLength(), EPSILON);
|
assertEquals(0, noseCone.getAftShoulderLength(), EPSILON);
|
||||||
assertEquals(0, noseCone.getAftShoulderRadius(), EPSILON);
|
assertEquals(0, noseCone.getAftShoulderRadius(), EPSILON);
|
||||||
assertEquals(0, noseCone.getAftShoulderThickness(), EPSILON);
|
assertEquals(0, noseCone.getAftShoulderThickness(), EPSILON);
|
||||||
@ -128,8 +128,8 @@ public class NoseConeTest extends BaseTestCase {
|
|||||||
|
|
||||||
assertEquals(0.2, noseCone.getForeRadius(), EPSILON);
|
assertEquals(0.2, noseCone.getForeRadius(), EPSILON);
|
||||||
assertEquals(0.2, noseCone.getBaseRadius(), EPSILON);
|
assertEquals(0.2, noseCone.getBaseRadius(), EPSILON);
|
||||||
assertEquals(0.2, noseCone.getForeRadiusNoAutomatic(), EPSILON);
|
assertEquals(0.2, noseCone.getForeRadius(), EPSILON);
|
||||||
assertEquals(0.2, noseCone.getBaseRadiusNoAutomatic(), EPSILON);
|
assertEquals(0.2, noseCone.getBaseRadius(), EPSILON);
|
||||||
assertEquals(0.03, noseCone.getForeShoulderLength(), EPSILON);
|
assertEquals(0.03, noseCone.getForeShoulderLength(), EPSILON);
|
||||||
assertEquals(0.03, noseCone.getShoulderLength(), EPSILON);
|
assertEquals(0.03, noseCone.getShoulderLength(), EPSILON);
|
||||||
assertEquals(0.04, noseCone.getForeShoulderRadius(), EPSILON);
|
assertEquals(0.04, noseCone.getForeShoulderRadius(), EPSILON);
|
||||||
@ -141,7 +141,7 @@ public class NoseConeTest extends BaseTestCase {
|
|||||||
assertFalse(noseCone.isForeRadiusAutomatic());
|
assertFalse(noseCone.isForeRadiusAutomatic());
|
||||||
|
|
||||||
assertEquals(0, noseCone.getAftRadius(), EPSILON);
|
assertEquals(0, noseCone.getAftRadius(), EPSILON);
|
||||||
assertEquals(0, noseCone.getAftRadiusNoAutomatic(), EPSILON);
|
assertEquals(0, noseCone.getAftRadius(), EPSILON);
|
||||||
assertEquals(0, noseCone.getAftShoulderLength(), EPSILON);
|
assertEquals(0, noseCone.getAftShoulderLength(), EPSILON);
|
||||||
assertEquals(0, noseCone.getAftShoulderRadius(), EPSILON);
|
assertEquals(0, noseCone.getAftShoulderRadius(), EPSILON);
|
||||||
assertEquals(0, noseCone.getAftShoulderThickness(), EPSILON);
|
assertEquals(0, noseCone.getAftShoulderThickness(), EPSILON);
|
||||||
@ -153,8 +153,8 @@ public class NoseConeTest extends BaseTestCase {
|
|||||||
|
|
||||||
assertEquals(0.2, noseCone.getAftRadius(), EPSILON);
|
assertEquals(0.2, noseCone.getAftRadius(), EPSILON);
|
||||||
assertEquals(0.2, noseCone.getBaseRadius(), EPSILON);
|
assertEquals(0.2, noseCone.getBaseRadius(), EPSILON);
|
||||||
assertEquals(0.2, noseCone.getAftRadiusNoAutomatic(), EPSILON);
|
assertEquals(0.2, noseCone.getAftRadius(), EPSILON);
|
||||||
assertEquals(0.2, noseCone.getBaseRadiusNoAutomatic(), EPSILON);
|
assertEquals(0.2, noseCone.getBaseRadius(), EPSILON);
|
||||||
assertEquals(0.03, noseCone.getAftShoulderLength(), EPSILON);
|
assertEquals(0.03, noseCone.getAftShoulderLength(), EPSILON);
|
||||||
assertEquals(0.03, noseCone.getShoulderLength(), EPSILON);
|
assertEquals(0.03, noseCone.getShoulderLength(), EPSILON);
|
||||||
assertEquals(0.04, noseCone.getAftShoulderRadius(), EPSILON);
|
assertEquals(0.04, noseCone.getAftShoulderRadius(), EPSILON);
|
||||||
@ -166,7 +166,7 @@ public class NoseConeTest extends BaseTestCase {
|
|||||||
assertFalse(noseCone.isAftRadiusAutomatic());
|
assertFalse(noseCone.isAftRadiusAutomatic());
|
||||||
|
|
||||||
assertEquals(0, noseCone.getForeRadius(), EPSILON);
|
assertEquals(0, noseCone.getForeRadius(), EPSILON);
|
||||||
assertEquals(0, noseCone.getForeRadiusNoAutomatic(), EPSILON);
|
assertEquals(0, noseCone.getForeRadius(), EPSILON);
|
||||||
assertEquals(0, noseCone.getForeShoulderLength(), EPSILON);
|
assertEquals(0, noseCone.getForeShoulderLength(), EPSILON);
|
||||||
assertEquals(0, noseCone.getForeShoulderRadius(), EPSILON);
|
assertEquals(0, noseCone.getForeShoulderRadius(), EPSILON);
|
||||||
assertEquals(0, noseCone.getForeShoulderThickness(), EPSILON);
|
assertEquals(0, noseCone.getForeShoulderThickness(), EPSILON);
|
||||||
@ -180,7 +180,7 @@ public class NoseConeTest extends BaseTestCase {
|
|||||||
AxialStage stage = rocket.getStage(0);
|
AxialStage stage = rocket.getStage(0);
|
||||||
|
|
||||||
NoseCone noseCone = new NoseCone(Transition.Shape.CONICAL, 0.06, 0.01);
|
NoseCone noseCone = new NoseCone(Transition.Shape.CONICAL, 0.06, 0.01);
|
||||||
BodyTube tube1 = new BodyTube(0.06, 0.02);
|
BodyTube tube1 = new BodyTube(0.06, 0.023);
|
||||||
tube1.setOuterRadiusAutomatic(false);
|
tube1.setOuterRadiusAutomatic(false);
|
||||||
BodyTube tube2 = new BodyTube(0.06, 0.03);
|
BodyTube tube2 = new BodyTube(0.06, 0.03);
|
||||||
tube2.setOuterRadiusAutomatic(false);
|
tube2.setOuterRadiusAutomatic(false);
|
||||||
@ -197,11 +197,11 @@ public class NoseConeTest extends BaseTestCase {
|
|||||||
assertFalse(noseCone.isAftRadiusAutomatic());
|
assertFalse(noseCone.isAftRadiusAutomatic());
|
||||||
assertFalse(noseCone.isBaseRadiusAutomatic());
|
assertFalse(noseCone.isBaseRadiusAutomatic());
|
||||||
assertFalse(noseCone.isForeRadiusAutomatic());
|
assertFalse(noseCone.isForeRadiusAutomatic());
|
||||||
assertEquals(noseCone.getAftRadius(), noseCone.getAftRadiusNoAutomatic(), EPSILON);
|
assertEquals(noseCone.getAftRadius(), noseCone.getAftRadius(), EPSILON);
|
||||||
assertEquals(noseCone.getBaseRadius(), noseCone.getBaseRadiusNoAutomatic(), EPSILON);
|
assertEquals(noseCone.getBaseRadius(), noseCone.getBaseRadius(), EPSILON);
|
||||||
assertEquals(noseCone.getForeRadius(), noseCone.getForeRadiusNoAutomatic(), EPSILON);
|
assertEquals(noseCone.getForeRadius(), noseCone.getForeRadius(), EPSILON);
|
||||||
assertEquals(0.01, noseCone.getAftRadiusNoAutomatic(), EPSILON);
|
assertEquals(0.01, noseCone.getAftRadius(), EPSILON);
|
||||||
assertEquals(0, noseCone.getForeRadiusNoAutomatic(), EPSILON);
|
assertEquals(0, noseCone.getForeRadius(), EPSILON);
|
||||||
|
|
||||||
noseCone.setAftRadiusAutomatic(true, true);
|
noseCone.setAftRadiusAutomatic(true, true);
|
||||||
assertFalse(noseCone.isAftRadiusAutomatic());
|
assertFalse(noseCone.isAftRadiusAutomatic());
|
||||||
@ -222,10 +222,10 @@ public class NoseConeTest extends BaseTestCase {
|
|||||||
assertFalse(noseCone.isAftRadiusAutomatic());
|
assertFalse(noseCone.isAftRadiusAutomatic());
|
||||||
assertFalse(noseCone.isBaseRadiusAutomatic());
|
assertFalse(noseCone.isBaseRadiusAutomatic());
|
||||||
assertFalse(noseCone.isForeRadiusAutomatic());
|
assertFalse(noseCone.isForeRadiusAutomatic());
|
||||||
assertEquals(noseCone.getAftRadius(), noseCone.getAftRadiusNoAutomatic(), EPSILON);
|
assertEquals(noseCone.getAftRadius(), noseCone.getAftRadius(), EPSILON);
|
||||||
assertEquals(noseCone.getBaseRadius(), noseCone.getBaseRadiusNoAutomatic(), EPSILON);
|
assertEquals(noseCone.getBaseRadius(), noseCone.getBaseRadius(), EPSILON);
|
||||||
assertEquals(noseCone.getForeRadius(), noseCone.getForeRadiusNoAutomatic(), EPSILON);
|
assertEquals(noseCone.getForeRadius(), noseCone.getForeRadius(), EPSILON);
|
||||||
assertEquals(0, noseCone.getForeRadiusNoAutomatic(), EPSILON);
|
assertEquals(0, noseCone.getForeRadius(), EPSILON);
|
||||||
|
|
||||||
noseCone.setAftRadiusAutomatic(true, true);
|
noseCone.setAftRadiusAutomatic(true, true);
|
||||||
assertFalse(noseCone.usesPreviousCompAutomatic());
|
assertFalse(noseCone.usesPreviousCompAutomatic());
|
||||||
@ -238,24 +238,24 @@ public class NoseConeTest extends BaseTestCase {
|
|||||||
assertTrue(noseCone.isBaseRadiusAutomatic());
|
assertTrue(noseCone.isBaseRadiusAutomatic());
|
||||||
assertFalse(noseCone.isForeRadiusAutomatic());
|
assertFalse(noseCone.isForeRadiusAutomatic());
|
||||||
assertEquals(tube1.getForeRadius(), noseCone.getAftRadius(), EPSILON);
|
assertEquals(tube1.getForeRadius(), noseCone.getAftRadius(), EPSILON);
|
||||||
assertEquals(0.01, noseCone.getAftRadiusNoAutomatic(), EPSILON);
|
assertEquals(0.023, noseCone.getAftRadius(), EPSILON);
|
||||||
assertEquals(tube1.getForeRadius(), noseCone.getBaseRadius(), EPSILON);
|
assertEquals(tube1.getForeRadius(), noseCone.getBaseRadius(), EPSILON);
|
||||||
assertEquals(0.01, noseCone.getBaseRadiusNoAutomatic(), EPSILON);
|
assertEquals(0.023, noseCone.getBaseRadius(), EPSILON);
|
||||||
assertEquals(noseCone.getForeRadius(), noseCone.getForeRadiusNoAutomatic(), EPSILON);
|
assertEquals(noseCone.getForeRadius(), noseCone.getForeRadius(), EPSILON);
|
||||||
assertEquals(0, noseCone.getForeRadiusNoAutomatic(), EPSILON);
|
assertEquals(0, noseCone.getForeRadius(), EPSILON);
|
||||||
|
|
||||||
noseCone.setAftRadiusAutomatic(false, true);
|
noseCone.setAftRadiusAutomatic(false, true);
|
||||||
assertEquals(noseCone.getAftRadius(), noseCone.getAftRadiusNoAutomatic(), EPSILON);
|
assertEquals(noseCone.getAftRadius(), noseCone.getAftRadius(), EPSILON);
|
||||||
assertEquals(noseCone.getBaseRadius(), noseCone.getBaseRadiusNoAutomatic(), EPSILON);
|
assertEquals(noseCone.getBaseRadius(), noseCone.getBaseRadius(), EPSILON);
|
||||||
assertEquals(noseCone.getForeRadius(), noseCone.getForeRadiusNoAutomatic(), EPSILON);
|
assertEquals(noseCone.getForeRadius(), noseCone.getForeRadius(), EPSILON);
|
||||||
assertEquals(0, noseCone.getForeRadiusNoAutomatic(), EPSILON);
|
assertEquals(0, noseCone.getForeRadius(), EPSILON);
|
||||||
|
|
||||||
noseCone.setBaseRadiusAutomatic(true);
|
noseCone.setBaseRadiusAutomatic(true);
|
||||||
assertEquals(0.01, noseCone.getAftRadiusNoAutomatic(), EPSILON);
|
assertEquals(0.023, noseCone.getAftRadius(), EPSILON);
|
||||||
assertEquals(tube1.getForeRadius(), noseCone.getBaseRadius(), EPSILON);
|
assertEquals(tube1.getForeRadius(), noseCone.getBaseRadius(), EPSILON);
|
||||||
assertEquals(0.01, noseCone.getBaseRadiusNoAutomatic(), EPSILON);
|
assertEquals(0.023, noseCone.getBaseRadius(), EPSILON);
|
||||||
assertEquals(noseCone.getForeRadius(), noseCone.getForeRadiusNoAutomatic(), EPSILON);
|
assertEquals(noseCone.getForeRadius(), noseCone.getForeRadius(), EPSILON);
|
||||||
assertEquals(0, noseCone.getForeRadiusNoAutomatic(), EPSILON);
|
assertEquals(0, noseCone.getForeRadius(), EPSILON);
|
||||||
|
|
||||||
noseCone.setForeRadiusAutomatic(true, true);
|
noseCone.setForeRadiusAutomatic(true, true);
|
||||||
assertFalse(noseCone.isForeRadiusAutomatic());
|
assertFalse(noseCone.isForeRadiusAutomatic());
|
||||||
@ -274,11 +274,11 @@ public class NoseConeTest extends BaseTestCase {
|
|||||||
assertTrue(noseCone.isBaseRadiusAutomatic());
|
assertTrue(noseCone.isBaseRadiusAutomatic());
|
||||||
assertFalse(noseCone.isForeRadiusAutomatic());
|
assertFalse(noseCone.isForeRadiusAutomatic());
|
||||||
assertEquals(tube1.getForeRadius(), noseCone.getAftRadius(), EPSILON);
|
assertEquals(tube1.getForeRadius(), noseCone.getAftRadius(), EPSILON);
|
||||||
assertEquals(0.01, noseCone.getAftRadiusNoAutomatic(), EPSILON);
|
assertEquals(0.023, noseCone.getAftRadius(), EPSILON);
|
||||||
assertEquals(tube1.getForeRadius(), noseCone.getBaseRadius(), EPSILON);
|
assertEquals(tube1.getForeRadius(), noseCone.getBaseRadius(), EPSILON);
|
||||||
assertEquals(0.01, noseCone.getBaseRadiusNoAutomatic(), EPSILON);
|
assertEquals(0.023, noseCone.getBaseRadius(), EPSILON);
|
||||||
assertEquals(noseCone.getForeRadius(), noseCone.getForeRadiusNoAutomatic(), EPSILON);
|
assertEquals(noseCone.getForeRadius(), noseCone.getForeRadius(), EPSILON);
|
||||||
assertEquals(0, noseCone.getForeRadiusNoAutomatic(), EPSILON);
|
assertEquals(0, noseCone.getForeRadius(), EPSILON);
|
||||||
|
|
||||||
// Do a flip
|
// Do a flip
|
||||||
noseCone.setFlipped(true);
|
noseCone.setFlipped(true);
|
||||||
@ -311,11 +311,11 @@ public class NoseConeTest extends BaseTestCase {
|
|||||||
assertFalse(noseCone.isAftRadiusAutomatic());
|
assertFalse(noseCone.isAftRadiusAutomatic());
|
||||||
assertFalse(noseCone.isBaseRadiusAutomatic());
|
assertFalse(noseCone.isBaseRadiusAutomatic());
|
||||||
assertFalse(noseCone.isForeRadiusAutomatic());
|
assertFalse(noseCone.isForeRadiusAutomatic());
|
||||||
assertEquals(noseCone.getAftRadius(), noseCone.getAftRadiusNoAutomatic(), EPSILON);
|
assertEquals(noseCone.getAftRadius(), noseCone.getAftRadius(), EPSILON);
|
||||||
assertEquals(noseCone.getBaseRadius(), noseCone.getBaseRadiusNoAutomatic(), EPSILON);
|
assertEquals(noseCone.getBaseRadius(), noseCone.getBaseRadius(), EPSILON);
|
||||||
assertEquals(noseCone.getForeRadius(), noseCone.getForeRadiusNoAutomatic(), EPSILON);
|
assertEquals(noseCone.getForeRadius(), noseCone.getForeRadius(), EPSILON);
|
||||||
assertEquals(0, noseCone.getAftRadiusNoAutomatic(), EPSILON);
|
assertEquals(0, noseCone.getAftRadius(), EPSILON);
|
||||||
assertEquals(0.01, noseCone.getForeRadiusNoAutomatic(), EPSILON);
|
assertEquals(0.01, noseCone.getForeRadius(), EPSILON);
|
||||||
|
|
||||||
noseCone.setAftRadiusAutomatic(true, true);
|
noseCone.setAftRadiusAutomatic(true, true);
|
||||||
assertFalse(noseCone.isAftRadiusAutomatic());
|
assertFalse(noseCone.isAftRadiusAutomatic());
|
||||||
@ -336,10 +336,10 @@ public class NoseConeTest extends BaseTestCase {
|
|||||||
assertFalse(noseCone.isAftRadiusAutomatic());
|
assertFalse(noseCone.isAftRadiusAutomatic());
|
||||||
assertFalse(noseCone.isBaseRadiusAutomatic());
|
assertFalse(noseCone.isBaseRadiusAutomatic());
|
||||||
assertFalse(noseCone.isForeRadiusAutomatic());
|
assertFalse(noseCone.isForeRadiusAutomatic());
|
||||||
assertEquals(noseCone.getAftRadius(), noseCone.getAftRadiusNoAutomatic(), EPSILON);
|
assertEquals(noseCone.getAftRadius(), noseCone.getAftRadius(), EPSILON);
|
||||||
assertEquals(noseCone.getBaseRadius(), noseCone.getBaseRadiusNoAutomatic(), EPSILON);
|
assertEquals(noseCone.getBaseRadius(), noseCone.getBaseRadius(), EPSILON);
|
||||||
assertEquals(noseCone.getForeRadius(), noseCone.getForeRadiusNoAutomatic(), EPSILON);
|
assertEquals(noseCone.getForeRadius(), noseCone.getForeRadius(), EPSILON);
|
||||||
assertEquals(0, noseCone.getAftRadiusNoAutomatic(), EPSILON);
|
assertEquals(0, noseCone.getAftRadius(), EPSILON);
|
||||||
|
|
||||||
noseCone.setBaseRadiusAutomatic(true);
|
noseCone.setBaseRadiusAutomatic(true);
|
||||||
assertTrue(noseCone.usesPreviousCompAutomatic());
|
assertTrue(noseCone.usesPreviousCompAutomatic());
|
||||||
@ -352,25 +352,25 @@ public class NoseConeTest extends BaseTestCase {
|
|||||||
assertTrue(noseCone.isBaseRadiusAutomatic());
|
assertTrue(noseCone.isBaseRadiusAutomatic());
|
||||||
assertTrue(noseCone.isForeRadiusAutomatic());
|
assertTrue(noseCone.isForeRadiusAutomatic());
|
||||||
assertEquals(tube1.getAftRadius(), noseCone.getForeRadius(), EPSILON);
|
assertEquals(tube1.getAftRadius(), noseCone.getForeRadius(), EPSILON);
|
||||||
assertEquals(0.01, noseCone.getForeRadiusNoAutomatic(), EPSILON);
|
assertEquals(0.02, noseCone.getForeRadius(), EPSILON);
|
||||||
assertEquals(tube1.getAftRadius(), noseCone.getBaseRadius(), EPSILON);
|
assertEquals(tube1.getAftRadius(), noseCone.getBaseRadius(), EPSILON);
|
||||||
assertEquals(0.01, noseCone.getBaseRadiusNoAutomatic(), EPSILON);
|
assertEquals(0.02, noseCone.getBaseRadius(), EPSILON);
|
||||||
assertEquals(noseCone.getAftRadius(), noseCone.getAftRadiusNoAutomatic(), EPSILON);
|
assertEquals(noseCone.getAftRadius(), noseCone.getAftRadius(), EPSILON);
|
||||||
assertEquals(0, noseCone.getAftRadiusNoAutomatic(), EPSILON);
|
assertEquals(0, noseCone.getAftRadius(), EPSILON);
|
||||||
|
|
||||||
noseCone.setForeRadiusAutomatic(false, true);
|
noseCone.setForeRadiusAutomatic(false, true);
|
||||||
assertEquals(noseCone.getAftRadius(), noseCone.getAftRadiusNoAutomatic(), EPSILON);
|
assertEquals(noseCone.getAftRadius(), noseCone.getAftRadius(), EPSILON);
|
||||||
assertEquals(noseCone.getBaseRadius(), noseCone.getBaseRadiusNoAutomatic(), EPSILON);
|
assertEquals(noseCone.getBaseRadius(), noseCone.getBaseRadius(), EPSILON);
|
||||||
assertEquals(noseCone.getForeRadius(), noseCone.getForeRadiusNoAutomatic(), EPSILON);
|
assertEquals(noseCone.getForeRadius(), noseCone.getForeRadius(), EPSILON);
|
||||||
assertEquals(0.01, noseCone.getForeRadiusNoAutomatic(), EPSILON);
|
assertEquals(0.02, noseCone.getForeRadius(), EPSILON);
|
||||||
|
|
||||||
noseCone.setBaseRadiusAutomatic(true);
|
noseCone.setBaseRadiusAutomatic(true);
|
||||||
assertEquals(tube1.getAftRadius(), noseCone.getForeRadius(), EPSILON);
|
assertEquals(tube1.getAftRadius(), noseCone.getForeRadius(), EPSILON);
|
||||||
assertEquals(0.01, noseCone.getForeRadiusNoAutomatic(), EPSILON);
|
assertEquals(0.02, noseCone.getForeRadius(), EPSILON);
|
||||||
assertEquals(tube1.getAftRadius(), noseCone.getBaseRadius(), EPSILON);
|
assertEquals(tube1.getAftRadius(), noseCone.getBaseRadius(), EPSILON);
|
||||||
assertEquals(0.01, noseCone.getBaseRadiusNoAutomatic(), EPSILON);
|
assertEquals(0.02, noseCone.getBaseRadius(), EPSILON);
|
||||||
assertEquals(noseCone.getAftRadius(), noseCone.getAftRadiusNoAutomatic(), EPSILON);
|
assertEquals(noseCone.getAftRadius(), noseCone.getAftRadius(), EPSILON);
|
||||||
assertEquals(0, noseCone.getAftRadiusNoAutomatic(), EPSILON);
|
assertEquals(0, noseCone.getAftRadius(), EPSILON);
|
||||||
|
|
||||||
assertTrue(noseCone.isForeRadiusAutomatic());
|
assertTrue(noseCone.isForeRadiusAutomatic());
|
||||||
assertTrue(noseCone.isBaseRadiusAutomatic());
|
assertTrue(noseCone.isBaseRadiusAutomatic());
|
||||||
@ -389,10 +389,10 @@ public class NoseConeTest extends BaseTestCase {
|
|||||||
assertTrue(noseCone.isBaseRadiusAutomatic());
|
assertTrue(noseCone.isBaseRadiusAutomatic());
|
||||||
assertTrue(noseCone.isForeRadiusAutomatic());
|
assertTrue(noseCone.isForeRadiusAutomatic());
|
||||||
assertEquals(tube1.getAftRadius(), noseCone.getForeRadius(), EPSILON);
|
assertEquals(tube1.getAftRadius(), noseCone.getForeRadius(), EPSILON);
|
||||||
assertEquals(0.01, noseCone.getForeRadiusNoAutomatic(), EPSILON);
|
assertEquals(0.02, noseCone.getForeRadius(), EPSILON);
|
||||||
assertEquals(tube1.getForeRadius(), noseCone.getBaseRadius(), EPSILON);
|
assertEquals(tube1.getForeRadius(), noseCone.getBaseRadius(), EPSILON);
|
||||||
assertEquals(0.01, noseCone.getBaseRadiusNoAutomatic(), EPSILON);
|
assertEquals(0.02, noseCone.getBaseRadius(), EPSILON);
|
||||||
assertEquals(noseCone.getAftRadius(), noseCone.getAftRadiusNoAutomatic(), EPSILON);
|
assertEquals(noseCone.getAftRadius(), noseCone.getAftRadius(), EPSILON);
|
||||||
assertEquals(0, noseCone.getAftRadius(), EPSILON);
|
assertEquals(0, noseCone.getAftRadius(), EPSILON);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -136,10 +136,8 @@ public class ScaleDialog extends JDialog {
|
|||||||
SCALERS_NO_OFFSET.put(FreeformFinSet.class, list);
|
SCALERS_NO_OFFSET.put(FreeformFinSet.class, list);
|
||||||
|
|
||||||
// MassObject
|
// MassObject
|
||||||
list = new ArrayList<>(1);
|
|
||||||
list.add(new MassObjectScaler());
|
|
||||||
SCALERS_NO_OFFSET.put(MassObject.class, list);
|
|
||||||
addScaler(MassObject.class, "Radius", "isRadiusAutomatic", SCALERS_NO_OFFSET);
|
addScaler(MassObject.class, "Radius", "isRadiusAutomatic", SCALERS_NO_OFFSET);
|
||||||
|
addScaler(MassObject.class, "Length", SCALERS_NO_OFFSET);
|
||||||
addScaler(MassObject.class, "RadialPosition", SCALERS_OFFSET);
|
addScaler(MassObject.class, "RadialPosition", SCALERS_OFFSET);
|
||||||
|
|
||||||
// MassComponent
|
// MassComponent
|
||||||
@ -721,25 +719,6 @@ public class ScaleDialog extends JDialog {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class MassObjectScaler implements Scaler {
|
|
||||||
@Override
|
|
||||||
public void scale(RocketComponent component, double multiplier, boolean scaleMass) {
|
|
||||||
if (scaleMass) {
|
|
||||||
MassObject c = (MassObject) component;
|
|
||||||
if (c.isRadiusAutomatic()) {
|
|
||||||
double volume = Math.PI * Math.pow(c.getRadiusNoAuto(), 2) * c.getLengthNoAuto();
|
|
||||||
double scaledVolume = volume * MathUtil.pow3(multiplier);
|
|
||||||
c.setRadius(c.getRadiusNoAuto() * multiplier);
|
|
||||||
c.setLengthNoAuto(scaledVolume / (Math.PI * Math.pow(c.getRadiusNoAuto(), 2)));
|
|
||||||
c.setRadiusAutomatic(true);
|
|
||||||
} else {
|
|
||||||
c.setLength(c.getLength() * multiplier);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class FreeformFinSetScaler implements Scaler {
|
private static class FreeformFinSetScaler implements Scaler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user