[#2171] Compute position based on active components
This commit is contained in:
parent
1832778ba8
commit
b30803250b
@ -1338,8 +1338,19 @@ public abstract class RocketComponent implements ChangeSource, Cloneable, Iterab
|
||||
if( 0 == thisIndex ) {
|
||||
this.position = this.position.setX(0.);
|
||||
}else if( 0 < thisIndex ) {
|
||||
RocketComponent referenceComponent = parent.getChild( thisIndex - 1 );
|
||||
|
||||
int idx = thisIndex - 1;
|
||||
RocketComponent referenceComponent = parent.getChild(idx);
|
||||
while (!getRocket().getSelectedConfiguration().isComponentActive(referenceComponent) && idx > 0) {
|
||||
idx--;
|
||||
referenceComponent = parent.getChild(idx);
|
||||
}
|
||||
|
||||
// If previous components are inactive, set this as the new reference point
|
||||
if (!getRocket().getSelectedConfiguration().isComponentActive(referenceComponent)) {
|
||||
this.position = this.position.setX(0.);
|
||||
return;
|
||||
}
|
||||
|
||||
double refLength = referenceComponent.getLength();
|
||||
double refRelX = referenceComponent.getPosition().x;
|
||||
|
||||
|
@ -998,7 +998,7 @@ public class MassCalculatorTest extends BaseTestCase {
|
||||
double expTotalMass = overrideMass;
|
||||
assertEquals(" Booster Launch Mass is incorrect: ", expTotalMass, calcTotalMass, EPSILON);
|
||||
|
||||
double expCMx = 6.484;
|
||||
double expCMx = 5.92;
|
||||
Coordinate expCM = new Coordinate(expCMx, 0, 0, expTotalMass);
|
||||
assertEquals(" Booster Launch CM.x is incorrect: ", expCM.x, boosterSetCM.x, EPSILON);
|
||||
assertEquals(" Booster Launch CM.y is incorrect: ", expCM.y, boosterSetCM.y, EPSILON);
|
||||
@ -1052,7 +1052,7 @@ public class MassCalculatorTest extends BaseTestCase {
|
||||
double expTotalMass = 3.3565872;
|
||||
assertEquals(" Booster Launch Mass is incorrect: ", expTotalMass, boosterData.getMass(), EPSILON);
|
||||
|
||||
double expCMx = 0.847508988;
|
||||
double expCMx = 0.2835089882645608;
|
||||
Coordinate expCM = new Coordinate(expCMx, 0, 0, expTotalMass);
|
||||
assertEquals(" Booster Launch CM.x is incorrect: ", expCM.x, boosterCM.x, EPSILON);
|
||||
assertEquals(" Booster Launch CM.y is incorrect: ", expCM.y, boosterCM.y, EPSILON);
|
||||
@ -1099,7 +1099,7 @@ public class MassCalculatorTest extends BaseTestCase {
|
||||
double calcTotalMass = structure.getMass();
|
||||
assertEquals(" Booster Launch Mass is incorrect: ", expMass, calcTotalMass, EPSILON);
|
||||
|
||||
final double expCMx = 1.1191303646438673;
|
||||
final double expCMx = 0.5551303646438673;
|
||||
Coordinate expCM = new Coordinate(expCMx, 0, 0, expMass);
|
||||
assertEquals(" Booster Launch CM.x is incorrect: ", expCM.x, structure.getCM().x, EPSILON);
|
||||
assertEquals(" Booster Launch CM.y is incorrect: ", expCM.y, structure.getCM().y, EPSILON);
|
||||
|
Loading…
x
Reference in New Issue
Block a user