[#1204] Add CG override effect to motors
The problem was that the overrideCG had no effect in calculateMotors().
This commit is contained in:
parent
d661cf12aa
commit
ec4e6eed37
@ -72,6 +72,10 @@ public class MassCalculation {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addMass(double mass) {
|
||||||
|
this.centerOfMass = this.centerOfMass.setWeight(getMass() + mass);
|
||||||
|
}
|
||||||
|
|
||||||
public MassCalculation copy( final RocketComponent _root, final Transformation _transform){
|
public MassCalculation copy( final RocketComponent _root, final Transformation _transform){
|
||||||
return new MassCalculation( this.type, this.config, this.simulationTime, this.activeMotorList, _root, _transform, this.analysisMap);
|
return new MassCalculation( this.type, this.config, this.simulationTime, this.activeMotorList, _root, _transform, this.analysisMap);
|
||||||
}
|
}
|
||||||
@ -84,6 +88,10 @@ public class MassCalculation {
|
|||||||
return this.centerOfMass.weight;
|
return this.centerOfMass.weight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setMass(double mass) {
|
||||||
|
this.centerOfMass = this.centerOfMass.setWeight(mass);
|
||||||
|
}
|
||||||
|
|
||||||
public double getLongitudinalInertia() {
|
public double getLongitudinalInertia() {
|
||||||
return this.inertia.Iyy;
|
return this.inertia.Iyy;
|
||||||
}
|
}
|
||||||
@ -407,6 +415,13 @@ public class MassCalculation {
|
|||||||
final int instanceCount = component.getInstanceCount();
|
final int instanceCount = component.getInstanceCount();
|
||||||
Coordinate[] instanceLocations = component.getInstanceLocations();
|
Coordinate[] instanceLocations = component.getInstanceLocations();
|
||||||
|
|
||||||
|
if (analysisMap != null) {
|
||||||
|
if (this.config.isComponentActive(component) && (!analysisMap.containsKey(component.hashCode()))) {
|
||||||
|
CMAnalysisEntry entry = new CMAnalysisEntry(component);
|
||||||
|
analysisMap.put(component.hashCode(), entry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// // vvv DEBUG
|
// // vvv DEBUG
|
||||||
// if( this.config.isComponentActive(component) ){
|
// if( this.config.isComponentActive(component) ){
|
||||||
// System.err.println(String.format( "%s[%s]....", prefix, component.getName()));
|
// System.err.println(String.format( "%s[%s]....", prefix, component.getName()));
|
||||||
@ -449,6 +464,45 @@ public class MassCalculation {
|
|||||||
//System.err.println(String.format( "%s....assembly mass (incl/children): %s", prefix, this.toCMDebug()));
|
//System.err.println(String.format( "%s....assembly mass (incl/children): %s", prefix, this.toCMDebug()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.config.isComponentActive(component) ){
|
||||||
|
Coordinate compCM = component.getComponentCG();
|
||||||
|
|
||||||
|
// 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.isCGOverridden()) {
|
||||||
|
this.setCM(this.getCM().setX(compZero.x + component.getOverrideCGX()));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (component.isCGOverridden()) {
|
||||||
|
compCM = compCM.setX(compZero.x + component.getOverrideCGX());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (null != analysisMap) {
|
||||||
|
final CMAnalysisEntry entry = analysisMap.get(component.hashCode());
|
||||||
|
if (component.getChildCount() > 0) {
|
||||||
|
// For parent components, record the _assembly_ information
|
||||||
|
entry.updateEachMass(children.getMass() / component.getInstanceCount());
|
||||||
|
entry.updateAverageCM(this.centerOfMass);
|
||||||
|
} else {
|
||||||
|
// For actual components, record the mass of the component, and disregard children
|
||||||
|
entry.updateEachMass(compCM.weight);
|
||||||
|
entry.updateAverageCM(compCM);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final double compIx = component.getRotationalUnitInertia() * compCM.weight;
|
||||||
|
final double compIt = component.getLongitudinalUnitInertia() * compCM.weight;
|
||||||
|
final RigidBody componentInertia = new RigidBody(compCM, compIx, compIt, compIt);
|
||||||
|
this.addInertia(componentInertia);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// // vvv DEBUG
|
// // vvv DEBUG
|
||||||
// if( this.config.isComponentActive(component) && 0 < this.getMass() ) {
|
// if( this.config.isComponentActive(component) && 0 < this.getMass() ) {
|
||||||
// System.err.println(String.format( "%s....<< return assemblyData: %s (tree @%s)", prefix, this.toCMDebug(), component.getName() ));
|
// System.err.println(String.format( "%s....<< return assemblyData: %s (tree @%s)", prefix, this.toCMDebug(), component.getName() ));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user