update iteration through rocket components to account for inactive components and instances
This commit is contained in:
parent
d673163d74
commit
98b60d1f7a
@ -1,9 +1,13 @@
|
|||||||
package net.sf.openrocket.simulation;
|
package net.sf.openrocket.simulation;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import net.sf.openrocket.rocketcomponent.FinSet;
|
import net.sf.openrocket.rocketcomponent.FinSet;
|
||||||
import net.sf.openrocket.rocketcomponent.FlightConfiguration;
|
import net.sf.openrocket.rocketcomponent.FlightConfiguration;
|
||||||
|
import net.sf.openrocket.rocketcomponent.InstanceContext;
|
||||||
|
import net.sf.openrocket.rocketcomponent.InstanceMap;
|
||||||
import net.sf.openrocket.rocketcomponent.Rocket;
|
import net.sf.openrocket.rocketcomponent.Rocket;
|
||||||
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
||||||
import net.sf.openrocket.rocketcomponent.SymmetricComponent;
|
import net.sf.openrocket.rocketcomponent.SymmetricComponent;
|
||||||
@ -46,13 +50,18 @@ public class BasicTumbleStatus extends SimulationStatus {
|
|||||||
// compute the fin and body tube projected areas
|
// compute the fin and body tube projected areas
|
||||||
double aFins = 0.0;
|
double aFins = 0.0;
|
||||||
double aBt = 0.0;
|
double aBt = 0.0;
|
||||||
Rocket r = this.getConfiguration().getRocket();
|
final InstanceMap imap = this.getConfiguration().getActiveInstances();
|
||||||
Iterator<RocketComponent> componentIterator = r.iterator();
|
for(Map.Entry<RocketComponent, ArrayList<InstanceContext>> entry: imap.entrySet() ) {
|
||||||
while (componentIterator.hasNext()) {
|
final RocketComponent component = entry.getKey();
|
||||||
RocketComponent component = componentIterator.next();
|
|
||||||
if (!component.isAerodynamic()) {
|
if (!component.isAerodynamic()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// iterate across component instances
|
||||||
|
final ArrayList<InstanceContext> contextList = entry.getValue();
|
||||||
|
for(InstanceContext context: contextList ) {
|
||||||
|
|
||||||
if (component instanceof FinSet) {
|
if (component instanceof FinSet) {
|
||||||
final FinSet finComponent = ((FinSet) component);
|
final FinSet finComponent = ((FinSet) component);
|
||||||
final double finArea = finComponent.getPlanformArea();
|
final double finArea = finComponent.getPlanformArea();
|
||||||
@ -63,12 +72,13 @@ public class BasicTumbleStatus extends SimulationStatus {
|
|||||||
finCount = finEff.length - 1;
|
finCount = finEff.length - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
aFins += finArea * finEff[finCount];
|
aFins += finArea * finEff[finCount] / finComponent.getFinCount();
|
||||||
|
|
||||||
} else if (component instanceof SymmetricComponent) {
|
} else if (component instanceof SymmetricComponent) {
|
||||||
aBt += ((SymmetricComponent) component).getComponentPlanformArea();
|
aBt += ((SymmetricComponent) component).getComponentPlanformArea();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (cDFin * aFins + cDBt * aBt);
|
return (cDFin * aFins + cDBt * aBt);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user