Merge pull request #1614 from SiboVG/issue-1613

[#1613] Fix bugs in fin tabs auto calc
This commit is contained in:
SiboVG 2022-08-26 16:17:23 +02:00 committed by GitHub
commit a13ab56808
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 17 deletions

View File

@ -42,7 +42,6 @@ public class TrapezoidFinSet extends FinSet {
this(3, 0.05, 0.05, 0.025, 0.03); this(3, 0.05, 0.05, 0.025, 0.03);
} }
// TODO: HIGH: height=0 -> CP = NaN
public TrapezoidFinSet(int fins, double rootChord, double tipChord, double sweep, public TrapezoidFinSet(int fins, double rootChord, double tipChord, double sweep,
double height) { double height) {
super(); super();

View File

@ -39,6 +39,7 @@ import net.sf.openrocket.rocketcomponent.SymmetricComponent;
import net.sf.openrocket.rocketcomponent.position.AxialMethod; import net.sf.openrocket.rocketcomponent.position.AxialMethod;
import net.sf.openrocket.startup.Application; import net.sf.openrocket.startup.Application;
import net.sf.openrocket.unit.UnitGroup; import net.sf.openrocket.unit.UnitGroup;
import net.sf.openrocket.util.Coordinate;
import net.sf.openrocket.util.MathUtil; import net.sf.openrocket.util.MathUtil;
import net.sf.openrocket.gui.widgets.SelectColorButton; import net.sf.openrocket.gui.widgets.SelectColorButton;
@ -257,26 +258,28 @@ public abstract class FinSetConfig extends RocketComponentConfig {
List<CenteringRing> rings = new ArrayList<>(); List<CenteringRing> rings = new ArrayList<>();
// Do deep recursive iteration to find centering rings and determine radius of inner tube // Do deep recursive iteration to find centering rings and determine radius of inner tube
Iterator<RocketComponent> iter = parent.iterator(false); for (RocketComponent child : parent.getChildren()) {
while (iter.hasNext()) { if (child instanceof InnerTube) {
RocketComponent rocketComponent = iter.next(); if (!isComponentInsideFinSpan(child)) {
if (rocketComponent instanceof InnerTube) {
if (!isComponentInsideFinSpan(rocketComponent)) {
continue; continue;
} }
InnerTube tube = (InnerTube) rocketComponent; InnerTube tube = (InnerTube) child;
if (tube.getOuterRadius() > maxTubeRad) { if (tube.getOuterRadius() > maxTubeRad) {
maxTubeRad = tube.getOuterRadius(); maxTubeRad = tube.getOuterRadius();
} }
} else if (rocketComponent instanceof CenteringRing) { } else if (child instanceof CenteringRing) {
CenteringRing ring = (CenteringRing) rocketComponent; CenteringRing ring = (CenteringRing) child;
if (ring.getOuterRadius() > maxRingRad) { if (ring.getOuterRadius() > maxRingRad) {
maxRingRad = ring.getOuterRadius(); maxRingRad = ring.getOuterRadius();
rings.clear();
rings.add(ring);
} else if (ring.getOuterRadius() == maxRingRad) {
rings.add(ring);
} }
rings.add(ring);
}
}
// Remove rings that are smaller than the maximum inner tube radius
for (CenteringRing ring : new ArrayList<>(rings)) {
if (ring.getOuterRadius() <= maxTubeRad) {
rings.remove(ring);
} }
} }
@ -290,14 +293,17 @@ public abstract class FinSetConfig extends RocketComponentConfig {
//Be nice to the user and set the tab relative position enum back the way they had it. //Be nice to the user and set the tab relative position enum back the way they had it.
tabOffsetMethod.setSelectedItem(temp); tabOffsetMethod.setSelectedItem(temp);
} else { } else {
tabLength.setValue(component.getLength());
tabOffsetMethod.setSelectedItem(AxialMethod.TOP); tabOffsetMethod.setSelectedItem(AxialMethod.TOP);
tabOffset.setValue(0); tabOffset.setValue(0);
tabLength.setValue(component.getLength());
} }
// Compute tab height // Compute tab height
double parentMinRadius = MathUtil.min(((SymmetricComponent)parent).getRadius(((FinSet) component).getTabFrontEdge()), final Coordinate finFront = ((FinSet) component).getFinFront();
((SymmetricComponent)parent).getRadius(((FinSet) component).getTabTrailingEdge())); double finStart = finFront.x + ((FinSet) component).getTabFrontEdge();
double finEnd = finFront.x + ((FinSet) component).getTabTrailingEdge();
double parentMinRadius = MathUtil.min(((SymmetricComponent)parent).getRadius(finStart),
((SymmetricComponent)parent).getRadius(finEnd));
double height = parentMinRadius - maxTubeRad; double height = parentMinRadius - maxTubeRad;
// Set tab height // Set tab height