Fix RockSim fin tab import issue

This commit is contained in:
SiboVG 2022-10-29 01:42:33 +02:00
parent 59fb50aeb1
commit 903a13cc91
2 changed files with 71 additions and 19 deletions

View File

@ -281,8 +281,9 @@ class FinSetHandler extends AbstractElementHandler {
//Create the fin set and correct for overrides and actual material densities
FinSet finSet = asOpenRocket(warnings);
if (component instanceof Transition && shapeCode == 0)
if (component instanceof Transition && shapeCode == 0) {
finSet = FreeformFinSet.convertFinSet(finSet);
}
finSet.setAppearance(appearanceBuilder.getAppearance());
@ -316,18 +317,18 @@ class FinSetHandler extends AbstractElementHandler {
FinSet result;
if (shapeCode == 0) {
//Trapezoidal
// Trapezoidal
result = new TrapezoidFinSet();
((TrapezoidFinSet) result).setFinShape(rootChord, tipChord, sweepDistance, semiSpan, thickness);
}
else if (shapeCode == 1) {
//Elliptical
// Elliptical
result = new EllipticalFinSet();
((EllipticalFinSet) result).setHeight(semiSpan);
((EllipticalFinSet) result).setLength(rootChord);
}
else if (shapeCode == 2) {
// Freeform
result = new FreeformFinSet();
((FreeformFinSet) result).setPoints(toCoordinates(pointList, warnings));
@ -338,16 +339,25 @@ class FinSetHandler extends AbstractElementHandler {
result.setThickness(thickness);
result.setName(name);
result.setFinCount(finCount);
result.setFinish(finish);
//All TTW tabs in Rocksim are relative to the front of the fin.
result.setTabOffsetMethod( AxialMethod.TOP);
result.setTabHeight(tabDepth);
result.setTabLength(tabLength);
result.setTabOffset(taboffset);
result.setBaseRotation(radialAngle);
result.setCrossSection(convertTipShapeCode(tipShapeCode));
result.setAxialMethod(axialMethod);
result.setAxialOffset(location);
result.setBaseRotation(radialAngle);
result.setCrossSection(convertTipShapeCode(tipShapeCode));
result.setFinish(finish);
result.setTabOffsetMethod(AxialMethod.TOP);
result.setTabOffset(taboffset);
result.setTabLength(tabLength);
//All TTW tabs in Rocksim are relative to the front of the fin, so set an offset if the parent's fore radius is larger than the aft radius.
Double radiusFront = result.getParentFrontRadius(component);
Double radiusTrailing = result.getParentTrailingRadius(component);
if (radiusFront == null) {
radiusFront = 0d;
}
if (radiusTrailing == null) {
radiusTrailing = 0d;
}
double tabDepthOffset = Math.max(radiusFront - radiusTrailing, 0);
result.setTabHeight(tabDepth - tabDepthOffset);
return result;

View File

@ -437,18 +437,60 @@ public abstract class FinSet extends ExternalComponent implements AxialPositiona
* @return maximum tab height value
*/
public double getMaxTabHeight() {
// check tab height
if (null != getParent() ){
Double radiusFront = getParentFrontRadius();
Double radiusTrailing = getParentTrailingRadius();
if (radiusFront != null && radiusTrailing != null) {
return MathUtil.min(radiusFront, radiusTrailing);
}
return Double.MAX_VALUE;
}
/**
* Returns the radius of the parent at the front of the fin, or null if no parent is present.
* @param parent the fin's parent component
*/
public Double getParentFrontRadius(RocketComponent parent) {
if (parent instanceof SymmetricComponent) {
final Coordinate finFront = this.getFinFront();
// pulls the parent-body radius at the fin-tab reference point.
final double xLead = this.getTabFrontEdge();
final double xTrail = this.getTabTrailingEdge();
final SymmetricComponent sym = (SymmetricComponent)this.parent;
return MathUtil.min(sym.getRadius(finFront.x + xLead), sym.getRadius(finFront.x + xTrail));
final SymmetricComponent sym = (SymmetricComponent) parent;
return sym.getRadius(finFront.x + xLead);
}
return Double.MAX_VALUE;
return null;
}
/**
* Returns the radius of the parent at the front of the fin, or null if no parent is present.
*/
public Double getParentFrontRadius() {
return getParentFrontRadius(getParent());
}
/**
* Returns the radius of the parent at the trailing edge of the fin, or null if no parent is present.
* @param parent the fin's parent component
*/
public Double getParentTrailingRadius(RocketComponent parent) {
if (parent instanceof SymmetricComponent) {
final Coordinate finFront = this.getFinFront();
// pulls the parent-body radius at the fin-tab reference point.
final double xTrail = this.getTabTrailingEdge();
final SymmetricComponent sym = (SymmetricComponent) parent;
return sym.getRadius(finFront.x + xTrail);
}
return null;
}
/**
* Returns the radius of the parent at the trailing edge of the fin, or null if no parent is present.
*/
public Double getParentTrailingRadius() {
return getParentTrailingRadius(getParent());
}
/////////// Calculation methods //////////