diff --git a/core/src/net/sf/openrocket/aerodynamics/BarrowmanCalculator.java b/core/src/net/sf/openrocket/aerodynamics/BarrowmanCalculator.java index 65f5cc21b..526dacf32 100644 --- a/core/src/net/sf/openrocket/aerodynamics/BarrowmanCalculator.java +++ b/core/src/net/sf/openrocket/aerodynamics/BarrowmanCalculator.java @@ -634,14 +634,19 @@ public class BarrowmanCalculator extends AbstractAerodynamicCalculator { // base drag calculation if (c instanceof SymmetricComponent) { SymmetricComponent s = (SymmetricComponent) c; - + double foreRadius = s.getForeRadius(); + double aftRadius = s.getAftRadius(); + // If length is zero, the component is a disk, i.e. a zero-length tube, so match the fore and aft diameter + if (s.getLength() == 0) { + foreRadius = Math.max(foreRadius, aftRadius); + } double radius = 0; final SymmetricComponent prevComponent = s.getPreviousSymmetricComponent(); if (prevComponent != null && configuration.isComponentActive(prevComponent)) radius = prevComponent.getAftRadius(); - if (radius < s.getForeRadius()) { - double area = Math.PI * (pow2(s.getForeRadius()) - pow2(radius)); + if (radius < foreRadius) { + double area = Math.PI * (pow2(foreRadius) - pow2(radius)); cd = stagnation * area / conditions.getRefArea(); total += instanceCount * cd; @@ -685,6 +690,13 @@ public class BarrowmanCalculator extends AbstractAerodynamicCalculator { } SymmetricComponent s = (SymmetricComponent) c; + double foreRadius = s.getForeRadius(); + double aftRadius = s.getAftRadius(); + // If length is zero, the component is a disk, i.e. a zero-length tube, so match the fore and aft diameter + if (s.getLength() == 0) { + final double componentMaxR = Math.max(foreRadius, aftRadius); + foreRadius = aftRadius = componentMaxR; + } int instanceCount = entry.getValue().size(); @@ -701,8 +713,8 @@ public class BarrowmanCalculator extends AbstractAerodynamicCalculator { radius = prevComponent.getAftRadius(); } - if (radius > s.getForeRadius()) { - double area = Math.PI * (pow2(radius) - pow2(s.getForeRadius())); + if (radius > foreRadius) { + double area = Math.PI * (pow2(radius) - pow2(foreRadius)); double cd = base * area / conditions.getRefArea(); total += instanceCount * cd; if ((forceMap != null) && (prevComponent != null)) { @@ -712,10 +724,10 @@ public class BarrowmanCalculator extends AbstractAerodynamicCalculator { // if I'm the last component, set my base CD // note: the iterator *should* serve up the next component.... buuuut .... - // this code has is tested, and there's no compelling reason to change. + // this code is tested, and there's no compelling reason to change. final SymmetricComponent n = s.getNextSymmetricComponent(); if ((n == null) || !configuration.isStageActive(n.getStageNumber())) { - double area = Math.PI * pow2(s.getAftRadius()); + double area = Math.PI * pow2(aftRadius); double cd = base * area / conditions.getRefArea(); total += instanceCount * cd; if (forceMap != null) { diff --git a/core/src/net/sf/openrocket/aerodynamics/barrowman/SymmetricComponentCalc.java b/core/src/net/sf/openrocket/aerodynamics/barrowman/SymmetricComponentCalc.java index 6a7e8cafc..3399f262f 100644 --- a/core/src/net/sf/openrocket/aerodynamics/barrowman/SymmetricComponentCalc.java +++ b/core/src/net/sf/openrocket/aerodynamics/barrowman/SymmetricComponentCalc.java @@ -56,8 +56,13 @@ public class SymmetricComponentCalc extends RocketComponentCalc { SymmetricComponent component = (SymmetricComponent) c; length = component.getLength(); - foreRadius = component.getForeRadius(); - aftRadius = component.getAftRadius(); + if (length > 0) { + foreRadius = component.getForeRadius(); + aftRadius = component.getAftRadius(); + } else { // If length is zero, the component is a disk, i.e. a zero-length tube, so match the fore and aft diameter + final double componentMaxR = Math.max(component.getForeRadius(), component.getAftRadius()); + foreRadius = aftRadius = componentMaxR; + } fineness = length / (2 * Math.abs(aftRadius - foreRadius)); fullVolume = component.getFullVolume(); diff --git a/core/src/net/sf/openrocket/rocketcomponent/SymmetricComponent.java b/core/src/net/sf/openrocket/rocketcomponent/SymmetricComponent.java index 524f20973..0427ea927 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/SymmetricComponent.java +++ b/core/src/net/sf/openrocket/rocketcomponent/SymmetricComponent.java @@ -311,14 +311,16 @@ public abstract class SymmetricComponent extends BodyComponent implements BoxBou private void integrate() { double x, r1, r2; double cgx; - + + wetArea = 0; + planArea = 0; + planCenter = 0; + fullVolume = 0; + volume = 0; + cg = Coordinate.NUL; + // Check length > 0 if (length <= 0) { - wetArea = 0; - planArea = 0; - planCenter = 0; - volume = 0; - cg = Coordinate.NUL; return; } @@ -329,11 +331,6 @@ public abstract class SymmetricComponent extends BodyComponent implements BoxBou final double pi3 = Math.PI / 3.0; r1 = getRadius(0); x = 0; - wetArea = 0; - planArea = 0; - planCenter = 0; - fullVolume = 0; - volume = 0; cgx = 0; for (int n = 1; n <= DIVISIONS; n++) { @@ -422,15 +419,18 @@ public abstract class SymmetricComponent extends BodyComponent implements BoxBou */ private void integrateInertiaVolume() { double x, r1, r2; - + + longitudinalInertia = 0; + rotationalInertia = 0; + + if (length <= 0) return; + final double l = length / DIVISIONS; final double pil = Math.PI * l; // PI * l final double pil3 = Math.PI * l / 3; // PI * l/3 r1 = getRadius(0); x = 0; - longitudinalInertia = 0; - rotationalInertia = 0; double vol = 0; @@ -489,16 +489,17 @@ public abstract class SymmetricComponent extends BodyComponent implements BoxBou */ private void integrateInertiaSurface() { double x, r1, r2; - + + longitudinalInertia = 0; + rotationalInertia = 0; + + if (length <= 0) return; + final double l = length / DIVISIONS; r1 = getRadius(0); - //System.out.println(r1); x = 0; - longitudinalInertia = 0; - rotationalInertia = 0; - double surface = 0; for (int n = 1; n <= DIVISIONS; n++) { diff --git a/core/src/net/sf/openrocket/rocketcomponent/Transition.java b/core/src/net/sf/openrocket/rocketcomponent/Transition.java index c9f0f9b16..8c819e276 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/Transition.java +++ b/core/src/net/sf/openrocket/rocketcomponent/Transition.java @@ -479,7 +479,7 @@ public class Transition extends SymmetricComponent implements InsideColorCompone public double getRadius(double x) { if ( x < 0 ) return getForeRadius(); - if ( x > length) + if ( x >= length) return getAftRadius(); double r1 = getForeRadius();