From 6698dbfc67cea74aada91c2b12e39fdbfa5e99ce Mon Sep 17 00:00:00 2001 From: Daniel_M_Williams Date: Sun, 25 Sep 2016 11:29:34 -0400 Subject: [PATCH] [Minor] added exception throws upon detected invalid inertia values during simulation. --- .../src/net/sf/openrocket/masscalc/MassCalculator.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/core/src/net/sf/openrocket/masscalc/MassCalculator.java b/core/src/net/sf/openrocket/masscalc/MassCalculator.java index f39bab384..fd47a79f9 100644 --- a/core/src/net/sf/openrocket/masscalc/MassCalculator.java +++ b/core/src/net/sf/openrocket/masscalc/MassCalculator.java @@ -14,6 +14,7 @@ import net.sf.openrocket.rocketcomponent.ParallelStage; import net.sf.openrocket.rocketcomponent.RocketComponent; import net.sf.openrocket.simulation.MotorClusterState; import net.sf.openrocket.simulation.SimulationStatus; +import net.sf.openrocket.util.BugException; import net.sf.openrocket.util.Coordinate; import net.sf.openrocket.util.MathUtil; import net.sf.openrocket.util.Monitorable; @@ -368,6 +369,15 @@ public class MassCalculator implements Monitorable { Coordinate compCM = component.getComponentCG(); double compIx = component.getRotationalUnitInertia() * compCM.weight; double compIt = component.getLongitudinalUnitInertia() * compCM.weight; + if( 0 > compCM.weight ){ + throw new BugException(" computed a negative rotational inertia value."); + } + if( 0 > compIx ){ + throw new BugException(" computed a negative rotational inertia value."); + } + if( 0 > compIt ){ + throw new BugException(" computed a negative longitudinal inertia value."); + } if (!component.getOverrideSubcomponents()) { if (component.isMassOverridden())