From bcdf32ecba574607febf01ba84b8d3761d158630 Mon Sep 17 00:00:00 2001 From: JoePfeiffer Date: Sun, 15 Oct 2023 06:20:10 -0600 Subject: [PATCH] Don't include shoulders in CG calculation for applying parallel axis theorem to longitudinal inertia, as they aren't included in calculation of longitudinal inertia itself. --- .../rocketcomponent/SymmetricComponent.java | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/core/src/net/sf/openrocket/rocketcomponent/SymmetricComponent.java b/core/src/net/sf/openrocket/rocketcomponent/SymmetricComponent.java index 9cd011ead..78d4f8260 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/SymmetricComponent.java +++ b/core/src/net/sf/openrocket/rocketcomponent/SymmetricComponent.java @@ -281,14 +281,25 @@ public abstract class SymmetricComponent extends BodyComponent implements BoxBou /** - * Calculate CG of the component by integrating over the length of the component. - * The method caches the result, so subsequent calls are instant. Subclasses may + * Return the CG and mass of the component. Subclasses may * override this method for simple shapes and use this method as necessary. * * @return The CG+mass of the component. */ @Override public Coordinate getComponentCG() { + return getSymmetricComponentCG(); + } + + /** + * Calculate CG of the symmetric component by integrating over the length of the component. + * The method caches the result, so subsequent calls are instant. We need this method because subclasses + * override getComponentCG() and include mass of shoulders + * + * @return The CG+mass of the component. + */ + + private Coordinate getSymmetricComponentCG() { if (cg == null) integrate(); return cg; @@ -491,7 +502,7 @@ public abstract class SymmetricComponent extends BodyComponent implements BoxBou longitudinalInertia /= vol; // Shift longitudinal inertia to CG - longitudinalInertia = Math.max(longitudinalInertia - pow2(getComponentCG().x), 0); + longitudinalInertia = longitudinalInertia - pow2(getSymmetricComponentCG().x); } @@ -548,7 +559,7 @@ public abstract class SymmetricComponent extends BodyComponent implements BoxBou rotationalInertia /= surface; // Shift longitudinal inertia to CG - longitudinalInertia = Math.max(longitudinalInertia - pow2(getComponentCG().x), 0); + longitudinalInertia = longitudinalInertia - pow2(getSymmetricComponentCG().x); }