Use correct zero point for CoG calculation
When center of gravity position is overrided, the zero point is the front of component, not the old center of gravity or the front of the parent.
This commit is contained in:
parent
17ba70987a
commit
e914b78052
@ -343,6 +343,10 @@ public class MassCalculation {
|
||||
|
||||
// mass data for *this component only* in the rocket-frame
|
||||
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.isMassive() ){
|
||||
// if this component mass, merge it in before overriding:
|
||||
@ -352,14 +356,13 @@ public class MassCalculation {
|
||||
this.setCM( this.getCM().setWeight(component.getOverrideMass()) );
|
||||
}
|
||||
if (component.isCGOverridden()) {
|
||||
this.setCM( this.getCM().setX( compCM.x + component.getOverrideCGX()));
|
||||
this.setCM( this.getCM().setX( compZero.x + component.getOverrideCGX()));
|
||||
}
|
||||
}else {
|
||||
if (component.isMassOverridden()) {
|
||||
compCM = compCM.setWeight( component.getOverrideMass() );
|
||||
}
|
||||
if (component.isCGOverridden()) {
|
||||
final Coordinate compZero = parentTransform.transform( Coordinate.ZERO );
|
||||
compCM = compCM.setX( compZero.x + component.getOverrideCGX() );
|
||||
}
|
||||
this.addMass( compCM );
|
||||
|
Loading…
x
Reference in New Issue
Block a user