Fix wrong fin location referencing in aggregate tubes

This commit is contained in:
SiboVG 2023-04-11 22:08:44 +02:00
parent 884959a98e
commit 68904b597a

View File

@ -155,6 +155,7 @@ public class BoosterDTO implements BodyTubeDTOAdapter {
TrapezoidFinSet finSet = getFinSetFromBodyTube(firstTube);
double tubeLength = firstTube.getLength();
double finLocationOffset = 0;
// Aggregate same-sized body tubes
for (int i = stage.getChildPosition(firstTube) + 1; i < stage.getChildCount(); i++) {
RocketComponent comp = stage.getChild(i);
@ -167,6 +168,11 @@ public class BoosterDTO implements BodyTubeDTOAdapter {
if (finSet == null) {
finSet = getFinSetFromBodyTube((BodyTube) comp);
}
// We need an offset to the fin location, since the fin axial offset is referenced to its parent tube,
// which can be different from the bottom of the aggregate tubes
else {
finLocationOffset += comp.getLength();
}
} else {
// If this booster is the last stage, and the last component is a transition, it could be a boattail
boolean isBoattail = (comp instanceof Transition && !(comp instanceof NoseCone)) && i == stage.getChildCount() - 1;
@ -196,7 +202,10 @@ public class BoosterDTO implements BodyTubeDTOAdapter {
String.format(trans.get("RASAeroExport.error16"),
firstTube.getName(), stage.getName()));
}
setFin(new FinDTO(finSet, warnings, errors));
FinDTO finDTO = new FinDTO(finSet, warnings, errors);
double finLocation = finDTO.getLocation();
finDTO.setLocation(finLocation + finLocationOffset * RASAeroCommonConstants.OPENROCKET_TO_RASAERO_LENGTH);
setFin(finDTO);
setPartType(RASAeroCommonConstants.BOOSTER);
setLength(tubeLength * RASAeroCommonConstants.OPENROCKET_TO_RASAERO_LENGTH);