[fix][masscalc] Validation Rockets correctly calculate mass
- Adjusted masscalculater code to not double-count instances (when mass > 0, and instance > 1 ) - RingComponents now correctly calculate their mass again
This commit is contained in:
parent
9176e9fa61
commit
279bb59f30
@ -318,10 +318,13 @@ public class MassCalculator implements Monitorable {
|
||||
|
||||
childrenData = childrenData.add( childData );
|
||||
}
|
||||
assemblyData = assemblyData.add( childrenData);
|
||||
|
||||
|
||||
|
||||
// if instanced, adjust children's data too.
|
||||
if ( 1 < component.getInstanceCount() ){
|
||||
if( 1 == component.getInstanceCount() ){
|
||||
assemblyData = assemblyData.add( childrenData );
|
||||
}else if( 0 < component.getChildCount()){
|
||||
final double curIxx = childrenData.getIxx(); // MOI about x-axis
|
||||
final double curIyy = childrenData.getIyy(); // MOI about y axis
|
||||
final double curIzz = childrenData.getIzz(); // MOI about z axis
|
||||
@ -337,8 +340,8 @@ public class MassCalculator implements Monitorable {
|
||||
// and add to the total
|
||||
instAccumData = instAccumData.add( instanceData);
|
||||
}
|
||||
|
||||
assemblyData = instAccumData;
|
||||
|
||||
assemblyData = assemblyData.add( instAccumData );
|
||||
}
|
||||
|
||||
|
||||
|
@ -4,6 +4,10 @@ import net.sf.openrocket.util.ChangeSource;
|
||||
|
||||
public interface Clusterable extends ChangeSource, Instanceable {
|
||||
|
||||
@Deprecated
|
||||
// redundant with Instanceable#getInstanceCount()
|
||||
public int getClusterCount();
|
||||
|
||||
public ClusterConfiguration getClusterConfiguration();
|
||||
|
||||
public void setClusterConfiguration(ClusterConfiguration cluster);
|
||||
|
@ -162,16 +162,6 @@ public abstract class RingComponent extends StructuralComponent implements Coaxi
|
||||
fireComponentChangeEvent(ComponentChangeEvent.MASS_CHANGE);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the number of times the component is multiplied.
|
||||
*/
|
||||
public int getClusterCount() {
|
||||
if (this instanceof Clusterable)
|
||||
return ((Clusterable) this).getClusterConfiguration().getClusterCount();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Coordinate> getComponentBounds() {
|
||||
List<Coordinate> bounds = new ArrayList<Coordinate>();
|
||||
@ -180,17 +170,29 @@ public abstract class RingComponent extends StructuralComponent implements Coaxi
|
||||
return bounds;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Coordinate getComponentCG() {
|
||||
return new Coordinate(length / 2, 0, 0, getComponentMass());
|
||||
Coordinate cg = Coordinate.ZERO;
|
||||
int instanceCount = getInstanceCount();
|
||||
double instanceMass = ringMass(getOuterRadius(), getInnerRadius(), getLength(),
|
||||
getMaterial().getDensity());
|
||||
|
||||
if (1 == instanceCount ) {
|
||||
cg = new Coordinate( length/2, 0, 0, instanceMass );
|
||||
}else{
|
||||
Coordinate offsets[] = getInstanceOffsets();
|
||||
for( Coordinate c : offsets) {
|
||||
cg = cg.average(c);
|
||||
}
|
||||
cg.add( length/2, 0, 0);
|
||||
}
|
||||
return cg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getComponentMass() {
|
||||
return ringMass(getOuterRadius(), getInnerRadius(), getLength(),
|
||||
getMaterial().getDensity()) * getClusterCount();
|
||||
getMaterial().getDensity()) * getInstanceCount();
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user