diff --git a/core/src/net/sf/openrocket/file/openrocket/importt/DocumentConfig.java b/core/src/net/sf/openrocket/file/openrocket/importt/DocumentConfig.java
index 73b1f0b16..82428f119 100644
--- a/core/src/net/sf/openrocket/file/openrocket/importt/DocumentConfig.java
+++ b/core/src/net/sf/openrocket/file/openrocket/importt/DocumentConfig.java
@@ -389,7 +389,7 @@ class DocumentConfig {
// MassObject
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(
Reflection.findMethod(MassObject.class, "setRadius", double.class),
"auto", " ",
diff --git a/core/src/net/sf/openrocket/file/openrocket/savers/BodyTubeSaver.java b/core/src/net/sf/openrocket/file/openrocket/savers/BodyTubeSaver.java
index d6aa0c85c..e4d7fb45d 100644
--- a/core/src/net/sf/openrocket/file/openrocket/savers/BodyTubeSaver.java
+++ b/core/src/net/sf/openrocket/file/openrocket/savers/BodyTubeSaver.java
@@ -23,7 +23,7 @@ public class BodyTubeSaver extends SymmetricComponentSaver {
net.sf.openrocket.rocketcomponent.BodyTube tube = (net.sf.openrocket.rocketcomponent.BodyTube) c;
if (tube.isOuterRadiusAutomatic()) {
- elements.add("auto " + tube.getOuterRadiusNoAutomatic() + "");
+ elements.add("auto " + tube.getOuterRadius() + "");
}
else
elements.add("" + tube.getOuterRadius() + "");
diff --git a/core/src/net/sf/openrocket/file/openrocket/savers/MassObjectSaver.java b/core/src/net/sf/openrocket/file/openrocket/savers/MassObjectSaver.java
index 9842dc26e..3cbf57605 100644
--- a/core/src/net/sf/openrocket/file/openrocket/savers/MassObjectSaver.java
+++ b/core/src/net/sf/openrocket/file/openrocket/savers/MassObjectSaver.java
@@ -13,11 +13,11 @@ public class MassObjectSaver extends InternalComponentSaver {
MassObject mass = (MassObject) c;
- elements.add("" + mass.getLengthNoAuto() + "");
+ elements.add("" + mass.getLength() + "");
if (mass.isRadiusAutomatic()) {
- elements.add("auto " + mass.getRadiusNoAuto() + "");
+ elements.add("auto " + mass.getRadius() + "");
} else {
- elements.add("" + mass.getRadiusNoAuto() + "");
+ elements.add("" + mass.getRadius() + "");
}
elements.add("" + mass.getRadialPosition() + "");
elements.add("" + (mass.getRadialDirection() * 180.0 / Math.PI)
diff --git a/core/src/net/sf/openrocket/file/openrocket/savers/NoseConeSaver.java b/core/src/net/sf/openrocket/file/openrocket/savers/NoseConeSaver.java
index e5c24e571..9c39cca72 100644
--- a/core/src/net/sf/openrocket/file/openrocket/savers/NoseConeSaver.java
+++ b/core/src/net/sf/openrocket/file/openrocket/savers/NoseConeSaver.java
@@ -27,7 +27,7 @@ public class NoseConeSaver extends TransitionSaver {
super.addParams(c, elements);
if (noseCone.isBaseRadiusAutomatic())
- elements.add("auto " + noseCone.getBaseRadiusNoAutomatic() + "");
+ elements.add("auto " + noseCone.getBaseRadius() + "");
else
elements.add("" + noseCone.getBaseRadius() + "");
diff --git a/core/src/net/sf/openrocket/file/openrocket/savers/TransitionSaver.java b/core/src/net/sf/openrocket/file/openrocket/savers/TransitionSaver.java
index b3b2ae8d6..331a95303 100644
--- a/core/src/net/sf/openrocket/file/openrocket/savers/TransitionSaver.java
+++ b/core/src/net/sf/openrocket/file/openrocket/savers/TransitionSaver.java
@@ -46,12 +46,12 @@ public class TransitionSaver extends SymmetricComponentSaver {
}
if (trans.isForeRadiusAutomatic())
- elements.add("auto " + trans.getForeRadiusNoAutomatic() + "");
+ elements.add("auto " + trans.getForeRadius() + "");
else
elements.add("" + trans.getForeRadius() + "");
if (trans.isAftRadiusAutomatic())
- elements.add("auto " + trans.getAftRadiusNoAutomatic() + "");
+ elements.add("auto " + trans.getAftRadius() + "");
else
elements.add("" + trans.getAftRadius() + "");
diff --git a/core/src/net/sf/openrocket/rocketcomponent/BodyTube.java b/core/src/net/sf/openrocket/rocketcomponent/BodyTube.java
index 40b292044..938f7a8a1 100644
--- a/core/src/net/sf/openrocket/rocketcomponent/BodyTube.java
+++ b/core/src/net/sf/openrocket/rocketcomponent/BodyTube.java
@@ -75,35 +75,35 @@ public class BodyTube extends SymmetricComponent implements BoxBounded, MotorMou
@Override
public double getOuterRadius() {
if (autoRadius) {
- // Return auto radius from front or rear
- double r = -1;
- SymmetricComponent c = this.getPreviousSymmetricComponent();
- // Don't use the radius of a component who already has its auto diameter enabled
- if (c != null && !c.usesNextCompAutomatic()) {
- r = c.getFrontAutoRadius();
- refComp = c;
- }
- if (r < 0) {
- c = this.getNextSymmetricComponent();
- // Don't use the radius of a component who already has its auto diameter enabled
- if (c != null && !c.usesPreviousCompAutomatic()) {
- r = c.getRearAutoRadius();
- refComp = c;
- }
- }
- if (r < 0)
- r = DEFAULT_RADIUS;
- return r;
+ outerRadius = getAutoOuterRadius();
}
return outerRadius;
}
/**
- * Return the outer radius that was manually entered, so not the value that the component received from automatic
- * outer radius.
+ * Returns the automatic outer radius, taken from the previous/next component. Returns the default radius if there
+ * is no previous/next component.
*/
- public double getOuterRadiusNoAutomatic() {
- return outerRadius;
+ private double getAutoOuterRadius() {
+ // Return auto radius from front or rear
+ double r = -1;
+ SymmetricComponent c = this.getPreviousSymmetricComponent();
+ // Don't use the radius of a component who already has its auto diameter enabled
+ if (c != null && !c.usesNextCompAutomatic()) {
+ r = c.getFrontAutoRadius();
+ refComp = c;
+ }
+ if (r < 0) {
+ c = this.getNextSymmetricComponent();
+ // Don't use the radius of a component who already has its auto diameter enabled
+ if (c != null && !c.usesPreviousCompAutomatic()) {
+ r = c.getRearAutoRadius();
+ refComp = c;
+ }
+ }
+ if (r < 0)
+ r = DEFAULT_RADIUS;
+ return r;
}
/**
diff --git a/core/src/net/sf/openrocket/rocketcomponent/MassObject.java b/core/src/net/sf/openrocket/rocketcomponent/MassObject.java
index 3d9fa5e6f..d370e3b8e 100644
--- a/core/src/net/sf/openrocket/rocketcomponent/MassObject.java
+++ b/core/src/net/sf/openrocket/rocketcomponent/MassObject.java
@@ -23,6 +23,7 @@ public abstract class MassObject extends InternalComponent {
protected double radius;
private boolean autoRadius = false;
+ private double volume; // (Packed) volume of the object
private double radialPosition;
private double radialDirection;
@@ -40,6 +41,7 @@ public abstract class MassObject extends InternalComponent {
this.length = length;
this.radius = radius;
+ updateVolume(radius);
this.setAxialMethod( AxialMethod.TOP);
this.setAxialOffset(0.0);
@@ -50,40 +52,18 @@ public abstract class MassObject extends InternalComponent {
return false;
}
+ private void updateVolume(double radius) {
+ volume = Math.pow(radius, 2) * length; // Math.PI left out, not needed
+ }
+
@Override
public double getLength() {
- if (this.autoRadius) {
- // Calculate the volume using the non auto radius and the non auto length, and transform that back
- // 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);
+ if (autoRadius) {
+ length = getAutoLength();
}
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) {
for (RocketComponent listener : configListeners) {
if (listener instanceof MassObject) {
@@ -92,45 +72,54 @@ public abstract class MassObject extends InternalComponent {
}
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)) {
- return;
- }
- this.length = length;
+
+ if (MathUtil.equals(this.length, length)) {
+ return;
}
+ this.length = length;
+ updateVolume(autoRadius ? getAutoRadius() : radius);
+
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() {
if (autoRadius) {
- if (parent == null) {
- return radius;
- }
- if (parent instanceof NoseCone) {
- return ((NoseCone) parent).getAftRadius();
- } else if (parent instanceof Transition) {
- double foreRadius = ((Transition) parent).getForeRadius();
- double aftRadius = ((Transition) parent).getAftRadius();
- return (Math.max(foreRadius, aftRadius));
- } else if (parent instanceof BodyComponent) {
- return ((BodyComponent) parent).getInnerRadius();
- } else if (parent instanceof RingComponent) {
- return ((RingComponent) parent).getInnerRadius();
- }
+ radius = getAutoRadius();
+ length = getAutoLength();
}
return radius;
}
- public double getRadiusNoAuto() {
+ /**
+ * Return the radius determined by its parent component.
+ * @return the radius determined by its parent component
+ */
+ public double getAutoRadius() {
+ if (parent == null) {
+ return radius;
+ }
+ if (parent instanceof NoseCone) {
+ return ((NoseCone) parent).getAftRadius();
+ } else if (parent instanceof Transition) {
+ double foreRadius = ((Transition) parent).getForeRadius();
+ double aftRadius = ((Transition) parent).getAftRadius();
+ return (Math.max(foreRadius, aftRadius));
+ } else if (parent instanceof BodyComponent) {
+ return ((BodyComponent) parent).getInnerRadius();
+ } else if (parent instanceof RingComponent) {
+ return ((RingComponent) parent).getInnerRadius();
+ }
+
return radius;
}
@@ -148,6 +137,7 @@ public abstract class MassObject extends InternalComponent {
this.autoRadius = false;
this.radius = radius;
+ updateVolume(radius);
fireComponentChangeEvent(ComponentChangeEvent.MASS_CHANGE);
}
@@ -167,10 +157,6 @@ public abstract class MassObject extends InternalComponent {
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);
}
diff --git a/core/src/net/sf/openrocket/rocketcomponent/NoseCone.java b/core/src/net/sf/openrocket/rocketcomponent/NoseCone.java
index 5e174bc24..ea76f4be1 100644
--- a/core/src/net/sf/openrocket/rocketcomponent/NoseCone.java
+++ b/core/src/net/sf/openrocket/rocketcomponent/NoseCone.java
@@ -52,14 +52,6 @@ public class NoseCone extends Transition implements InsideColorComponent {
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).
* 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();
setBypassChangeEvent(true);
if (flipped) {
- setForeRadius(getAftRadiusNoAutomatic());
+ setForeRadius(getAftRadius());
setForeRadiusAutomatic(isAftRadiusAutomatic(), sanityCheck);
setForeShoulderLength(getAftShoulderLength());
setForeShoulderRadius(getAftShoulderRadius());
@@ -212,7 +204,7 @@ public class NoseCone extends Transition implements InsideColorComponent {
resetAftRadius();
} else {
- setAftRadius(getForeRadiusNoAutomatic());
+ setAftRadius(getForeRadius());
setAftRadiusAutomatic(isForeRadiusAutomatic(), sanityCheck);
setAftShoulderLength(getForeShoulderLength());
setAftShoulderRadius(getForeShoulderRadius());
diff --git a/core/src/net/sf/openrocket/rocketcomponent/Transition.java b/core/src/net/sf/openrocket/rocketcomponent/Transition.java
index 5fb9822eb..a518844bf 100644
--- a/core/src/net/sf/openrocket/rocketcomponent/Transition.java
+++ b/core/src/net/sf/openrocket/rocketcomponent/Transition.java
@@ -77,7 +77,7 @@ public class Transition extends SymmetricComponent implements InsideColorCompone
@Override
public double getForeRadius() {
if (isForeRadiusAutomatic()) {
- return getAutoForeRadius();
+ foreRadius = getAutoForeRadius();
}
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.
* @param radius new radius
@@ -174,7 +166,7 @@ public class Transition extends SymmetricComponent implements InsideColorCompone
@Override
public double getAftRadius() {
if (isAftRadiusAutomatic()) {
- return getAutoAftRadius();
+ aftRadius = getAutoAftRadius();
}
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.
* @param radius new radius
diff --git a/core/test/net/sf/openrocket/rocketcomponent/MassObjectTest.java b/core/test/net/sf/openrocket/rocketcomponent/MassObjectTest.java
index 72458ce78..a4df5b6eb 100644
--- a/core/test/net/sf/openrocket/rocketcomponent/MassObjectTest.java
+++ b/core/test/net/sf/openrocket/rocketcomponent/MassObjectTest.java
@@ -21,20 +21,14 @@ public class MassObjectTest extends BaseTestCase {
mo.setLength(0.1);
Assert.assertEquals(String.format(" No auto %s incorrect radius", mo.getClass().getName()),
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()),
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()),
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()),
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()),
0.05, mo.getComponentCG().x, MathUtil.EPSILON);
@@ -46,12 +40,8 @@ public class MassObjectTest extends BaseTestCase {
mo.setRadiusAutomatic(true);
Assert.assertEquals(String.format(" Auto 1 %s incorrect radius", mo.getClass().getName()),
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()),
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()),
0.2, mo.getComponentCG().x, MathUtil.EPSILON);
@@ -59,12 +49,8 @@ public class MassObjectTest extends BaseTestCase {
parent.setInnerRadius(0.1);
Assert.assertEquals(String.format(" Auto 2 %s incorrect radius", mo.getClass().getName()),
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()),
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()),
0.05, mo.getComponentCG().x, MathUtil.EPSILON);
@@ -73,26 +59,18 @@ public class MassObjectTest extends BaseTestCase {
mo.setLength(0.075);
Assert.assertEquals(String.format(" Auto 3 %s incorrect radius", mo.getClass().getName()),
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()),
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()),
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()),
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()),
- 0.0889, mo.getLength(), 0.001);
- Assert.assertEquals(String.format(" Auto 4 %s incorrect no auto length", mo.getClass().getName()),
- 0.05, mo.getLengthNoAuto(), MathUtil.EPSILON);
+ 0.05, mo.getLength(), 0.001);
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);
}
}
}
diff --git a/core/test/net/sf/openrocket/rocketcomponent/NoseConeTest.java b/core/test/net/sf/openrocket/rocketcomponent/NoseConeTest.java
index f8076445b..4757e52b9 100644
--- a/core/test/net/sf/openrocket/rocketcomponent/NoseConeTest.java
+++ b/core/test/net/sf/openrocket/rocketcomponent/NoseConeTest.java
@@ -31,8 +31,8 @@ public class NoseConeTest extends BaseTestCase {
assertEquals(0.06, noseCone.getLength(), EPSILON);
assertEquals(0.1, noseCone.getAftRadius(), EPSILON);
assertEquals(0.1, noseCone.getBaseRadius(), EPSILON);
- assertEquals(0.1, noseCone.getAftRadiusNoAutomatic(), EPSILON);
- assertEquals(0.1, noseCone.getBaseRadiusNoAutomatic(), EPSILON);
+ assertEquals(0.1, noseCone.getAftRadius(), EPSILON);
+ assertEquals(0.1, noseCone.getBaseRadius(), EPSILON);
assertEquals(0.01, noseCone.getAftShoulderLength(), EPSILON);
assertEquals(0.01, noseCone.getShoulderLength(), EPSILON);
assertEquals(0.05, noseCone.getAftShoulderRadius(), EPSILON);
@@ -44,7 +44,7 @@ public class NoseConeTest extends BaseTestCase {
assertFalse(noseCone.isAftRadiusAutomatic());
assertEquals(0, noseCone.getForeRadius(), EPSILON);
- assertEquals(0, noseCone.getForeRadiusNoAutomatic(), EPSILON);
+ assertEquals(0, noseCone.getForeRadius(), EPSILON);
assertEquals(0, noseCone.getForeShoulderLength(), EPSILON);
assertEquals(0, noseCone.getForeShoulderRadius(), 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.getBaseRadius(), EPSILON);
- assertEquals(0.2, noseCone.getAftRadiusNoAutomatic(), EPSILON);
- assertEquals(0.2, noseCone.getBaseRadiusNoAutomatic(), EPSILON);
+ assertEquals(0.2, noseCone.getAftRadius(), EPSILON);
+ assertEquals(0.2, noseCone.getBaseRadius(), EPSILON);
assertEquals(0.03, noseCone.getAftShoulderLength(), EPSILON);
assertEquals(0.03, noseCone.getShoulderLength(), EPSILON);
assertEquals(0.04, noseCone.getAftShoulderRadius(), EPSILON);
@@ -73,7 +73,7 @@ public class NoseConeTest extends BaseTestCase {
assertFalse(noseCone.isAftRadiusAutomatic());
assertEquals(0, noseCone.getForeRadius(), EPSILON);
- assertEquals(0, noseCone.getForeRadiusNoAutomatic(), EPSILON);
+ assertEquals(0, noseCone.getForeRadius(), EPSILON);
assertEquals(0, noseCone.getForeShoulderLength(), EPSILON);
assertEquals(0, noseCone.getForeShoulderRadius(), EPSILON);
assertEquals(0, noseCone.getForeShoulderThickness(), EPSILON);
@@ -99,8 +99,8 @@ public class NoseConeTest extends BaseTestCase {
assertEquals(0.06, noseCone.getLength(), EPSILON);
assertEquals(0.1, noseCone.getForeRadius(), EPSILON);
assertEquals(0.1, noseCone.getBaseRadius(), EPSILON);
- assertEquals(0.1, noseCone.getForeRadiusNoAutomatic(), EPSILON);
- assertEquals(0.1, noseCone.getBaseRadiusNoAutomatic(), EPSILON);
+ assertEquals(0.1, noseCone.getForeRadius(), EPSILON);
+ assertEquals(0.1, noseCone.getBaseRadius(), EPSILON);
assertEquals(0.01, noseCone.getForeShoulderLength(), EPSILON);
assertEquals(0.01, noseCone.getShoulderLength(), EPSILON);
assertEquals(0.05, noseCone.getForeShoulderRadius(), EPSILON);
@@ -112,7 +112,7 @@ public class NoseConeTest extends BaseTestCase {
assertFalse(noseCone.isForeRadiusAutomatic());
assertEquals(0, noseCone.getAftRadius(), EPSILON);
- assertEquals(0, noseCone.getAftRadiusNoAutomatic(), EPSILON);
+ assertEquals(0, noseCone.getAftRadius(), EPSILON);
assertEquals(0, noseCone.getAftShoulderLength(), EPSILON);
assertEquals(0, noseCone.getAftShoulderRadius(), 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.getBaseRadius(), EPSILON);
- assertEquals(0.2, noseCone.getForeRadiusNoAutomatic(), EPSILON);
- assertEquals(0.2, noseCone.getBaseRadiusNoAutomatic(), EPSILON);
+ assertEquals(0.2, noseCone.getForeRadius(), EPSILON);
+ assertEquals(0.2, noseCone.getBaseRadius(), EPSILON);
assertEquals(0.03, noseCone.getForeShoulderLength(), EPSILON);
assertEquals(0.03, noseCone.getShoulderLength(), EPSILON);
assertEquals(0.04, noseCone.getForeShoulderRadius(), EPSILON);
@@ -141,7 +141,7 @@ public class NoseConeTest extends BaseTestCase {
assertFalse(noseCone.isForeRadiusAutomatic());
assertEquals(0, noseCone.getAftRadius(), EPSILON);
- assertEquals(0, noseCone.getAftRadiusNoAutomatic(), EPSILON);
+ assertEquals(0, noseCone.getAftRadius(), EPSILON);
assertEquals(0, noseCone.getAftShoulderLength(), EPSILON);
assertEquals(0, noseCone.getAftShoulderRadius(), 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.getBaseRadius(), EPSILON);
- assertEquals(0.2, noseCone.getAftRadiusNoAutomatic(), EPSILON);
- assertEquals(0.2, noseCone.getBaseRadiusNoAutomatic(), EPSILON);
+ assertEquals(0.2, noseCone.getAftRadius(), EPSILON);
+ assertEquals(0.2, noseCone.getBaseRadius(), EPSILON);
assertEquals(0.03, noseCone.getAftShoulderLength(), EPSILON);
assertEquals(0.03, noseCone.getShoulderLength(), EPSILON);
assertEquals(0.04, noseCone.getAftShoulderRadius(), EPSILON);
@@ -166,7 +166,7 @@ public class NoseConeTest extends BaseTestCase {
assertFalse(noseCone.isAftRadiusAutomatic());
assertEquals(0, noseCone.getForeRadius(), EPSILON);
- assertEquals(0, noseCone.getForeRadiusNoAutomatic(), EPSILON);
+ assertEquals(0, noseCone.getForeRadius(), EPSILON);
assertEquals(0, noseCone.getForeShoulderLength(), EPSILON);
assertEquals(0, noseCone.getForeShoulderRadius(), EPSILON);
assertEquals(0, noseCone.getForeShoulderThickness(), EPSILON);
@@ -180,7 +180,7 @@ public class NoseConeTest extends BaseTestCase {
AxialStage stage = rocket.getStage(0);
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);
BodyTube tube2 = new BodyTube(0.06, 0.03);
tube2.setOuterRadiusAutomatic(false);
@@ -197,11 +197,11 @@ public class NoseConeTest extends BaseTestCase {
assertFalse(noseCone.isAftRadiusAutomatic());
assertFalse(noseCone.isBaseRadiusAutomatic());
assertFalse(noseCone.isForeRadiusAutomatic());
- assertEquals(noseCone.getAftRadius(), noseCone.getAftRadiusNoAutomatic(), EPSILON);
- assertEquals(noseCone.getBaseRadius(), noseCone.getBaseRadiusNoAutomatic(), EPSILON);
- assertEquals(noseCone.getForeRadius(), noseCone.getForeRadiusNoAutomatic(), EPSILON);
- assertEquals(0.01, noseCone.getAftRadiusNoAutomatic(), EPSILON);
- assertEquals(0, noseCone.getForeRadiusNoAutomatic(), EPSILON);
+ assertEquals(noseCone.getAftRadius(), noseCone.getAftRadius(), EPSILON);
+ assertEquals(noseCone.getBaseRadius(), noseCone.getBaseRadius(), EPSILON);
+ assertEquals(noseCone.getForeRadius(), noseCone.getForeRadius(), EPSILON);
+ assertEquals(0.01, noseCone.getAftRadius(), EPSILON);
+ assertEquals(0, noseCone.getForeRadius(), EPSILON);
noseCone.setAftRadiusAutomatic(true, true);
assertFalse(noseCone.isAftRadiusAutomatic());
@@ -222,10 +222,10 @@ public class NoseConeTest extends BaseTestCase {
assertFalse(noseCone.isAftRadiusAutomatic());
assertFalse(noseCone.isBaseRadiusAutomatic());
assertFalse(noseCone.isForeRadiusAutomatic());
- assertEquals(noseCone.getAftRadius(), noseCone.getAftRadiusNoAutomatic(), EPSILON);
- assertEquals(noseCone.getBaseRadius(), noseCone.getBaseRadiusNoAutomatic(), EPSILON);
- assertEquals(noseCone.getForeRadius(), noseCone.getForeRadiusNoAutomatic(), EPSILON);
- assertEquals(0, noseCone.getForeRadiusNoAutomatic(), EPSILON);
+ assertEquals(noseCone.getAftRadius(), noseCone.getAftRadius(), EPSILON);
+ assertEquals(noseCone.getBaseRadius(), noseCone.getBaseRadius(), EPSILON);
+ assertEquals(noseCone.getForeRadius(), noseCone.getForeRadius(), EPSILON);
+ assertEquals(0, noseCone.getForeRadius(), EPSILON);
noseCone.setAftRadiusAutomatic(true, true);
assertFalse(noseCone.usesPreviousCompAutomatic());
@@ -238,24 +238,24 @@ public class NoseConeTest extends BaseTestCase {
assertTrue(noseCone.isBaseRadiusAutomatic());
assertFalse(noseCone.isForeRadiusAutomatic());
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(0.01, noseCone.getBaseRadiusNoAutomatic(), EPSILON);
- assertEquals(noseCone.getForeRadius(), noseCone.getForeRadiusNoAutomatic(), EPSILON);
- assertEquals(0, noseCone.getForeRadiusNoAutomatic(), EPSILON);
+ assertEquals(0.023, noseCone.getBaseRadius(), EPSILON);
+ assertEquals(noseCone.getForeRadius(), noseCone.getForeRadius(), EPSILON);
+ assertEquals(0, noseCone.getForeRadius(), EPSILON);
noseCone.setAftRadiusAutomatic(false, true);
- assertEquals(noseCone.getAftRadius(), noseCone.getAftRadiusNoAutomatic(), EPSILON);
- assertEquals(noseCone.getBaseRadius(), noseCone.getBaseRadiusNoAutomatic(), EPSILON);
- assertEquals(noseCone.getForeRadius(), noseCone.getForeRadiusNoAutomatic(), EPSILON);
- assertEquals(0, noseCone.getForeRadiusNoAutomatic(), EPSILON);
+ assertEquals(noseCone.getAftRadius(), noseCone.getAftRadius(), EPSILON);
+ assertEquals(noseCone.getBaseRadius(), noseCone.getBaseRadius(), EPSILON);
+ assertEquals(noseCone.getForeRadius(), noseCone.getForeRadius(), EPSILON);
+ assertEquals(0, noseCone.getForeRadius(), EPSILON);
noseCone.setBaseRadiusAutomatic(true);
- assertEquals(0.01, noseCone.getAftRadiusNoAutomatic(), EPSILON);
+ assertEquals(0.023, noseCone.getAftRadius(), EPSILON);
assertEquals(tube1.getForeRadius(), noseCone.getBaseRadius(), EPSILON);
- assertEquals(0.01, noseCone.getBaseRadiusNoAutomatic(), EPSILON);
- assertEquals(noseCone.getForeRadius(), noseCone.getForeRadiusNoAutomatic(), EPSILON);
- assertEquals(0, noseCone.getForeRadiusNoAutomatic(), EPSILON);
+ assertEquals(0.023, noseCone.getBaseRadius(), EPSILON);
+ assertEquals(noseCone.getForeRadius(), noseCone.getForeRadius(), EPSILON);
+ assertEquals(0, noseCone.getForeRadius(), EPSILON);
noseCone.setForeRadiusAutomatic(true, true);
assertFalse(noseCone.isForeRadiusAutomatic());
@@ -274,11 +274,11 @@ public class NoseConeTest extends BaseTestCase {
assertTrue(noseCone.isBaseRadiusAutomatic());
assertFalse(noseCone.isForeRadiusAutomatic());
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(0.01, noseCone.getBaseRadiusNoAutomatic(), EPSILON);
- assertEquals(noseCone.getForeRadius(), noseCone.getForeRadiusNoAutomatic(), EPSILON);
- assertEquals(0, noseCone.getForeRadiusNoAutomatic(), EPSILON);
+ assertEquals(0.023, noseCone.getBaseRadius(), EPSILON);
+ assertEquals(noseCone.getForeRadius(), noseCone.getForeRadius(), EPSILON);
+ assertEquals(0, noseCone.getForeRadius(), EPSILON);
// Do a flip
noseCone.setFlipped(true);
@@ -311,11 +311,11 @@ public class NoseConeTest extends BaseTestCase {
assertFalse(noseCone.isAftRadiusAutomatic());
assertFalse(noseCone.isBaseRadiusAutomatic());
assertFalse(noseCone.isForeRadiusAutomatic());
- assertEquals(noseCone.getAftRadius(), noseCone.getAftRadiusNoAutomatic(), EPSILON);
- assertEquals(noseCone.getBaseRadius(), noseCone.getBaseRadiusNoAutomatic(), EPSILON);
- assertEquals(noseCone.getForeRadius(), noseCone.getForeRadiusNoAutomatic(), EPSILON);
- assertEquals(0, noseCone.getAftRadiusNoAutomatic(), EPSILON);
- assertEquals(0.01, noseCone.getForeRadiusNoAutomatic(), EPSILON);
+ assertEquals(noseCone.getAftRadius(), noseCone.getAftRadius(), EPSILON);
+ assertEquals(noseCone.getBaseRadius(), noseCone.getBaseRadius(), EPSILON);
+ assertEquals(noseCone.getForeRadius(), noseCone.getForeRadius(), EPSILON);
+ assertEquals(0, noseCone.getAftRadius(), EPSILON);
+ assertEquals(0.01, noseCone.getForeRadius(), EPSILON);
noseCone.setAftRadiusAutomatic(true, true);
assertFalse(noseCone.isAftRadiusAutomatic());
@@ -336,10 +336,10 @@ public class NoseConeTest extends BaseTestCase {
assertFalse(noseCone.isAftRadiusAutomatic());
assertFalse(noseCone.isBaseRadiusAutomatic());
assertFalse(noseCone.isForeRadiusAutomatic());
- assertEquals(noseCone.getAftRadius(), noseCone.getAftRadiusNoAutomatic(), EPSILON);
- assertEquals(noseCone.getBaseRadius(), noseCone.getBaseRadiusNoAutomatic(), EPSILON);
- assertEquals(noseCone.getForeRadius(), noseCone.getForeRadiusNoAutomatic(), EPSILON);
- assertEquals(0, noseCone.getAftRadiusNoAutomatic(), EPSILON);
+ assertEquals(noseCone.getAftRadius(), noseCone.getAftRadius(), EPSILON);
+ assertEquals(noseCone.getBaseRadius(), noseCone.getBaseRadius(), EPSILON);
+ assertEquals(noseCone.getForeRadius(), noseCone.getForeRadius(), EPSILON);
+ assertEquals(0, noseCone.getAftRadius(), EPSILON);
noseCone.setBaseRadiusAutomatic(true);
assertTrue(noseCone.usesPreviousCompAutomatic());
@@ -352,25 +352,25 @@ public class NoseConeTest extends BaseTestCase {
assertTrue(noseCone.isBaseRadiusAutomatic());
assertTrue(noseCone.isForeRadiusAutomatic());
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(0.01, noseCone.getBaseRadiusNoAutomatic(), EPSILON);
- assertEquals(noseCone.getAftRadius(), noseCone.getAftRadiusNoAutomatic(), EPSILON);
- assertEquals(0, noseCone.getAftRadiusNoAutomatic(), EPSILON);
+ assertEquals(0.02, noseCone.getBaseRadius(), EPSILON);
+ assertEquals(noseCone.getAftRadius(), noseCone.getAftRadius(), EPSILON);
+ assertEquals(0, noseCone.getAftRadius(), EPSILON);
noseCone.setForeRadiusAutomatic(false, true);
- assertEquals(noseCone.getAftRadius(), noseCone.getAftRadiusNoAutomatic(), EPSILON);
- assertEquals(noseCone.getBaseRadius(), noseCone.getBaseRadiusNoAutomatic(), EPSILON);
- assertEquals(noseCone.getForeRadius(), noseCone.getForeRadiusNoAutomatic(), EPSILON);
- assertEquals(0.01, noseCone.getForeRadiusNoAutomatic(), EPSILON);
+ assertEquals(noseCone.getAftRadius(), noseCone.getAftRadius(), EPSILON);
+ assertEquals(noseCone.getBaseRadius(), noseCone.getBaseRadius(), EPSILON);
+ assertEquals(noseCone.getForeRadius(), noseCone.getForeRadius(), EPSILON);
+ assertEquals(0.02, noseCone.getForeRadius(), EPSILON);
noseCone.setBaseRadiusAutomatic(true);
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(0.01, noseCone.getBaseRadiusNoAutomatic(), EPSILON);
- assertEquals(noseCone.getAftRadius(), noseCone.getAftRadiusNoAutomatic(), EPSILON);
- assertEquals(0, noseCone.getAftRadiusNoAutomatic(), EPSILON);
+ assertEquals(0.02, noseCone.getBaseRadius(), EPSILON);
+ assertEquals(noseCone.getAftRadius(), noseCone.getAftRadius(), EPSILON);
+ assertEquals(0, noseCone.getAftRadius(), EPSILON);
assertTrue(noseCone.isForeRadiusAutomatic());
assertTrue(noseCone.isBaseRadiusAutomatic());
@@ -389,10 +389,10 @@ public class NoseConeTest extends BaseTestCase {
assertTrue(noseCone.isBaseRadiusAutomatic());
assertTrue(noseCone.isForeRadiusAutomatic());
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(0.01, noseCone.getBaseRadiusNoAutomatic(), EPSILON);
- assertEquals(noseCone.getAftRadius(), noseCone.getAftRadiusNoAutomatic(), EPSILON);
+ assertEquals(0.02, noseCone.getBaseRadius(), EPSILON);
+ assertEquals(noseCone.getAftRadius(), noseCone.getAftRadius(), EPSILON);
assertEquals(0, noseCone.getAftRadius(), EPSILON);
}
}
diff --git a/swing/src/net/sf/openrocket/gui/dialogs/ScaleDialog.java b/swing/src/net/sf/openrocket/gui/dialogs/ScaleDialog.java
index 111f16378..d1a95308d 100644
--- a/swing/src/net/sf/openrocket/gui/dialogs/ScaleDialog.java
+++ b/swing/src/net/sf/openrocket/gui/dialogs/ScaleDialog.java
@@ -136,10 +136,8 @@ public class ScaleDialog extends JDialog {
SCALERS_NO_OFFSET.put(FreeformFinSet.class, list);
// 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, "Length", SCALERS_NO_OFFSET);
addScaler(MassObject.class, "RadialPosition", SCALERS_OFFSET);
// MassComponent
@@ -720,25 +718,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 {