From a25cb8355e1c7faa61192dbee5095fd496163290 Mon Sep 17 00:00:00 2001 From: JoePfeiffer Date: Wed, 6 Apr 2022 10:49:49 -0600 Subject: [PATCH 1/2] generalize getOuterRadius() to set radius so tubes touch for number of tubes greater than 2 (ie whenever possible) create getTubesTouching() method to determine whether tubes are touching (will also return true if they overlap) fix several places where outerRadius was used instead of getOuterRadius() --- .../rocketcomponent/TubeFinSet.java | 61 ++++++++++--------- 1 file changed, 31 insertions(+), 30 deletions(-) diff --git a/core/src/net/sf/openrocket/rocketcomponent/TubeFinSet.java b/core/src/net/sf/openrocket/rocketcomponent/TubeFinSet.java index 2292429a7..63af7b3bd 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/TubeFinSet.java +++ b/core/src/net/sf/openrocket/rocketcomponent/TubeFinSet.java @@ -85,35 +85,37 @@ public class TubeFinSet extends ExternalComponent implements AxialPositionable, */ public double getOuterRadius() { if (autoRadius) { - // Return auto radius from front or rear - double r = -1; - RocketComponent c = this.getParent(); - if (c != null) { - if (c instanceof SymmetricComponent) { - r = ((SymmetricComponent) c).getAftRadius(); - } - } - if (r < 0) { - r = DEFAULT_RADIUS; + if (fins < 3) { + return getBodyRadius(); } else { - // for 5,6, and 8 fins, adjust the diameter to provide touching fins. - switch (fins) { - case 5: - r *= 1.43; // sin(36) / (1- sin(36), 36 = 360/5/2 - break; - case 7: - r *= 0.77; // sin(25.7) / (1- sin(25.7) - break; - case 8: - r *= 0.62; // sin(22.5) / (1- sin(22.5) - break; - } + return getTouchingRadius(); } - return r; } return outerRadius; } - + + /** + * Return whether the tubes are touching + * + * @return true if touching, false if not + */ + public boolean getTubesTouching() { + return getOuterRadius() > getTouchingRadius() - MathUtil.EPSILON; + } + + /** + * Return the required radius for the fins to be touching + * + * @return required radius + */ + private double getTouchingRadius() { + double r = getBodyRadius(); + final double finSep = Math.PI / fins; + + r *= Math.sin(finSep)/(1.0 - Math.sin(finSep)); + + return r; + } /** * Set the outer radius of the tube-fin. If the radius is less than the wall thickness, * the wall thickness is decreased accordingly of the value of the radius. @@ -355,8 +357,8 @@ public class TubeFinSet extends ExternalComponent implements AxialPositionable, List bounds = new ArrayList(); double r = getBodyRadius(); - addBound(bounds, 0, 2 * (r + outerRadius)); - addBound(bounds, length, 2 * (r + outerRadius)); + addBound(bounds, 0, 2 * getBoundingRadius()); + addBound(bounds, length, 2 * getBoundingRadius()); return bounds; } @@ -364,8 +366,8 @@ public class TubeFinSet extends ExternalComponent implements AxialPositionable, @Override public BoundingBox getInstanceBoundingBox() { BoundingBox box = new BoundingBox(); - box.update(new Coordinate(0, -outerRadius, -outerRadius)); - box.update(new Coordinate(length, outerRadius, outerRadius)); + box.update(new Coordinate(0, -getOuterRadius(), -getOuterRadius())); + box.update(new Coordinate(length, getOuterRadius(), getOuterRadius())); return box; } @@ -413,8 +415,7 @@ public class TubeFinSet extends ExternalComponent implements AxialPositionable, @Override public double getBoundingRadius() { - // TODO Auto-generated method stub - return 0; + return getBodyRadius() + getOuterRadius(); } @Override From e8ae279dd3c85d6924367cdaf783b2361a60303c Mon Sep 17 00:00:00 2001 From: JoePfeiffer Date: Wed, 13 Apr 2022 14:03:56 -0600 Subject: [PATCH 2/2] Instead of getTubesTouching() returning a boolean telling whether tubes are touching, use getTubeSeparation() returning the actual separation between tubes. This'll work just as well for the current effort, and will be more useful when we consider tubes with separation. --- .../src/net/sf/openrocket/rocketcomponent/TubeFinSet.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/src/net/sf/openrocket/rocketcomponent/TubeFinSet.java b/core/src/net/sf/openrocket/rocketcomponent/TubeFinSet.java index 63af7b3bd..685198726 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/TubeFinSet.java +++ b/core/src/net/sf/openrocket/rocketcomponent/TubeFinSet.java @@ -95,12 +95,12 @@ public class TubeFinSet extends ExternalComponent implements AxialPositionable, } /** - * Return whether the tubes are touching + * Return distance between tubes. * - * @return true if touching, false if not + * @return distance between tubes. 0 if touching, negative if overlap */ - public boolean getTubesTouching() { - return getOuterRadius() > getTouchingRadius() - MathUtil.EPSILON; + public double getTubeSeparation() { + return 2.0*(getTouchingRadius() - getOuterRadius()); } /**