Merge pull request #1035 from rsammelson/fix-cg-positioning
Use correct zero point for center of gravity calculation
This commit is contained in:
commit
83908a9f20
@ -343,6 +343,10 @@ public class MassCalculation {
|
|||||||
|
|
||||||
// mass data for *this component only* in the rocket-frame
|
// mass data for *this component only* in the rocket-frame
|
||||||
compCM = parentTransform.transform( compCM.add(component.getPosition()) );
|
compCM = parentTransform.transform( compCM.add(component.getPosition()) );
|
||||||
|
|
||||||
|
// setting zero as the CG position means the top of the component, which is component.getPosition()
|
||||||
|
final Coordinate compZero = parentTransform.transform( component.getPosition() );
|
||||||
|
|
||||||
if (component.getOverrideSubcomponents()) {
|
if (component.getOverrideSubcomponents()) {
|
||||||
if( component.isMassive() ){
|
if( component.isMassive() ){
|
||||||
// if this component mass, merge it in before overriding:
|
// if this component mass, merge it in before overriding:
|
||||||
@ -352,14 +356,13 @@ public class MassCalculation {
|
|||||||
this.setCM( this.getCM().setWeight(component.getOverrideMass()) );
|
this.setCM( this.getCM().setWeight(component.getOverrideMass()) );
|
||||||
}
|
}
|
||||||
if (component.isCGOverridden()) {
|
if (component.isCGOverridden()) {
|
||||||
this.setCM( this.getCM().setX( compCM.x + component.getOverrideCGX()));
|
this.setCM( this.getCM().setX( compZero.x + component.getOverrideCGX()));
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
if (component.isMassOverridden()) {
|
if (component.isMassOverridden()) {
|
||||||
compCM = compCM.setWeight( component.getOverrideMass() );
|
compCM = compCM.setWeight( component.getOverrideMass() );
|
||||||
}
|
}
|
||||||
if (component.isCGOverridden()) {
|
if (component.isCGOverridden()) {
|
||||||
final Coordinate compZero = parentTransform.transform( Coordinate.ZERO );
|
|
||||||
compCM = compCM.setX( compZero.x + component.getOverrideCGX() );
|
compCM = compCM.setX( compZero.x + component.getOverrideCGX() );
|
||||||
}
|
}
|
||||||
this.addMass( compCM );
|
this.addMass( compCM );
|
||||||
|
@ -1064,7 +1064,7 @@ public class MassCalculatorTest extends BaseTestCase {
|
|||||||
double calcTotalMass = structure.getMass();
|
double calcTotalMass = structure.getMass();
|
||||||
assertEquals(" Booster Launch Mass is incorrect: ", expMass, calcTotalMass, EPSILON);
|
assertEquals(" Booster Launch Mass is incorrect: ", expMass, calcTotalMass, EPSILON);
|
||||||
|
|
||||||
final double expCMx = 1.0446069131149498;
|
final double expCMx = 1.1191303646438673;
|
||||||
Coordinate expCM = new Coordinate(expCMx, 0, 0, expMass);
|
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.x is incorrect: ", expCM.x, structure.getCM().x, EPSILON);
|
||||||
assertEquals(" Booster Launch CM.y is incorrect: ", expCM.y, structure.getCM().y, EPSILON);
|
assertEquals(" Booster Launch CM.y is incorrect: ", expCM.y, structure.getCM().y, EPSILON);
|
||||||
@ -1076,7 +1076,7 @@ public class MassCalculatorTest extends BaseTestCase {
|
|||||||
double boosterMOI_xx = structure.getRotationalInertia();
|
double boosterMOI_xx = structure.getRotationalInertia();
|
||||||
assertEquals(" Booster x-axis MOI is incorrect: ", expMOI_axial, boosterMOI_xx, EPSILON);
|
assertEquals(" Booster x-axis MOI is incorrect: ", expMOI_axial, boosterMOI_xx, EPSILON);
|
||||||
|
|
||||||
final double expMOI_tr = 0.036243133045;
|
final double expMOI_tr = 0.040989095911;
|
||||||
double boosterMOI_tr = structure.getLongitudinalInertia();
|
double boosterMOI_tr = structure.getLongitudinalInertia();
|
||||||
assertEquals(" Booster transverse MOI is incorrect: ", expMOI_tr, boosterMOI_tr, EPSILON);
|
assertEquals(" Booster transverse MOI is incorrect: ", expMOI_tr, boosterMOI_tr, EPSILON);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user