From 19aed2a21618399b9fa53183ab1110a6a5feefcc Mon Sep 17 00:00:00 2001 From: JoePfeiffer Date: Sat, 24 Dec 2022 20:10:33 -0700 Subject: [PATCH 1/2] Unit.toString() now displays NaN as N/A. This brings it in agreement with Unit.toStringUnit() --- core/src/net/sf/openrocket/unit/Unit.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/src/net/sf/openrocket/unit/Unit.java b/core/src/net/sf/openrocket/unit/Unit.java index 4c4195b15..fd0f97ac6 100644 --- a/core/src/net/sf/openrocket/unit/Unit.java +++ b/core/src/net/sf/openrocket/unit/Unit.java @@ -90,8 +90,11 @@ public abstract class Unit { * @return A string representation of the number in these units. */ public String toString(double value) { - double val = toUnit(value); + if (Double.isNaN(value)) + return "N/A"; + double val = toUnit(value); + if (Math.abs(val) > 1E6) { return expFormat.format(val); } From b89a5aa35c67266f32294ca2ad2d86234fa41152 Mon Sep 17 00:00:00 2001 From: JoePfeiffer Date: Sat, 24 Dec 2022 20:11:34 -0700 Subject: [PATCH 2/2] If rocket CP weight is less than or equal to 0, display it as N/A in ComponentAnalysisDialog. This brings it in agreement with the CP display in the RocketPanel, and more clearly expresses a problem with the deisgn. --- .../sf/openrocket/gui/dialogs/ComponentAnalysisDialog.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/swing/src/net/sf/openrocket/gui/dialogs/ComponentAnalysisDialog.java b/swing/src/net/sf/openrocket/gui/dialogs/ComponentAnalysisDialog.java index b0b120c82..d05c0b039 100644 --- a/swing/src/net/sf/openrocket/gui/dialogs/ComponentAnalysisDialog.java +++ b/swing/src/net/sf/openrocket/gui/dialogs/ComponentAnalysisDialog.java @@ -571,7 +571,12 @@ public class ComponentAnalysisDialog extends JDialog implements StateChangeListe } if (forces.getCP() != null) { - row.cpx = forces.getCP().x; + if ((comp instanceof Rocket) && + (forces.getCP().weight < MathUtil.EPSILON)) { + row.cpx = Double.NaN; + } else { + row.cpx = forces.getCP().x; + } row.cna = forces.getCNa(); }