From 098223eb31b958b353350953e2d088d6525880d5 Mon Sep 17 00:00:00 2001 From: JoePfeiffer Date: Wed, 18 Jan 2023 10:14:08 -0700 Subject: [PATCH] Check for gaps and overlaps in airframe --- core/resources/l10n/messages.properties | 2 ++ .../aerodynamics/BarrowmanCalculator.java | 33 ++++++++++--------- .../sf/openrocket/aerodynamics/Warning.java | 6 ++++ 3 files changed, 26 insertions(+), 15 deletions(-) diff --git a/core/resources/l10n/messages.properties b/core/resources/l10n/messages.properties index b5b965b22..b87bfd771 100644 --- a/core/resources/l10n/messages.properties +++ b/core/resources/l10n/messages.properties @@ -1864,6 +1864,8 @@ Warning.LargeAOA.str1 = Large angle of attack encountered. Warning.LargeAOA.str2 = Large angle of attack encountered ( Warning.DISCONTINUITY = Discontinuity in rocket body diameter Warning.OPEN_AIRFRAME_FORWARD = Forward end of airframe is open (radius is > 0) +Warning.AIRFRAME_GAP = Gap in rocket airframe +Warning.AIRFRAME_OVERLAP = Two airframe sections overlap Warning.THICK_FIN = Thick fins may not simulate accurately. Warning.JAGGED_EDGED_FIN = Jagged-edged fin predictions may be inaccurate. Warning.LISTENERS_AFFECTED = Listeners modified the flight simulation diff --git a/core/src/net/sf/openrocket/aerodynamics/BarrowmanCalculator.java b/core/src/net/sf/openrocket/aerodynamics/BarrowmanCalculator.java index ce2d5ce61..686119fac 100644 --- a/core/src/net/sf/openrocket/aerodynamics/BarrowmanCalculator.java +++ b/core/src/net/sf/openrocket/aerodynamics/BarrowmanCalculator.java @@ -309,25 +309,28 @@ public class BarrowmanCalculator extends AbstractAerodynamicCalculator { // We're going to say it's discontinuous if it is presented to the user as having two different // string representations. Hopefully there are enough digits in the string that it will // present as different if the discontinuity is big enough to matter. - if (!UnitGroup.UNITS_LENGTH.getDefaultUnit().toStringUnit(2.0*sym.getForeRadius()).equals(UnitGroup.UNITS_LENGTH.getDefaultUnit().toStringUnit(2.0*prevComp.getAftRadius()))) { - // if ( !MathUtil.equals(sym.getForeRadius(), prevComp.getAftRadius())) { - warnings.add( Warning.DIAMETER_DISCONTINUITY, sym + ", " + prevComp); + if (!UnitGroup.UNITS_LENGTH.getDefaultUnit().toStringUnit(2.0*sym.getForeRadius()) + .equals(UnitGroup.UNITS_LENGTH.getDefaultUnit().toStringUnit(2.0*prevComp.getAftRadius()))) { + warnings.add( Warning.DIAMETER_DISCONTINUITY, prevComp + ", " + sym); + } + + // check for gap in airframe. We'll use a textual comparison as above to see if there is a + // gap or overlap, then use arithmetic comparison to see which it is. This won't be quite as reliable + // as the case for radius, since we never actually display the absolute X position + double compX = comp.toAbsolute(Coordinate.NUL)[0].x; + double prevX = prevComp.toAbsolute(new Coordinate(prevComp.getLength(), 0, 0, 0))[0].x; + if (!UnitGroup.UNITS_LENGTH.getDefaultUnit().toStringUnit(compX) + .equals(UnitGroup.UNITS_LENGTH.getDefaultUnit().toStringUnit(prevX))) { + if (compX > prevX) { + warnings.add(Warning.AIRFRAME_GAP, prevComp + ", " + sym); + } else { + warnings.add(Warning.AIRFRAME_OVERLAP, prevComp + ", " + sym); + } } } - - // double x = component.toAbsolute(Coordinate.NUL)[0].x; - // // Check for lengthwise discontinuity - // if (x > componentX + 0.0001) { - // if (!MathUtil.equals(radius, 0)) { - // warnings.add(Warning.DISCONTINUITY); - // radius = 0; - //} - //componentX = component.toAbsolute(new Coordinate(component.getLengthAerodynamic()))[0].x; - - }else if( comp instanceof ComponentAssembly ){ + } else if (comp instanceof ComponentAssembly) { checkGeometry(configuration, comp, warnings); } - } } diff --git a/core/src/net/sf/openrocket/aerodynamics/Warning.java b/core/src/net/sf/openrocket/aerodynamics/Warning.java index b3c31fecc..6274a71c1 100644 --- a/core/src/net/sf/openrocket/aerodynamics/Warning.java +++ b/core/src/net/sf/openrocket/aerodynamics/Warning.java @@ -361,6 +361,12 @@ public abstract class Warning { /** A Warning that a ComponentAssembly has an open forward end */ public static final Warning OPEN_AIRFRAME_FORWARD = new Other(trans.get("Warning.OPEN_AIRFRAME_FORWARD")); + + /** A Warning that there is a gap in the airframe */ + public static final Warning AIRFRAME_GAP = new Other(trans.get("Warning.AIRFRAME_GAP")); + + /** A Warning that two airframe components overlap*/ + public static final Warning AIRFRAME_OVERLAP = new Other(trans.get("Warning.AIRFRAME_OVERLAP")); /** A Warning that the fins are thick compared to the rocket body. */ ////Thick fins may not be modeled accurately.