import java.util.List;
import net.sf.openrocket.aerodynamics.WarningSet;
+import net.sf.openrocket.logging.LogHelper;
+import net.sf.openrocket.startup.Application;
import net.sf.openrocket.util.MathUtil;
import net.sf.openrocket.util.Mutable;
* @author Sampo Niskanen <sampo.niskanen@iki.fi>
*/
public class FlightData {
+ private static final LogHelper log = Application.getLogger();
/**
* An immutable FlightData object with NaN data.
private double timeToApogee = Double.NaN;
private double flightTime = Double.NaN;
private double groundHitVelocity = Double.NaN;
+ private double launchRodVelocity = Double.NaN;
/**
* @param timeToApogee time to apogee.
* @param flightTime total flight time.
* @param groundHitVelocity ground hit velocity.
+ * @param launchRodVelocity TODO
*/
public FlightData(double maxAltitude, double maxVelocity, double maxAcceleration,
double maxMachNumber, double timeToApogee, double flightTime,
- double groundHitVelocity) {
+ double groundHitVelocity, double launchRodVelocity) {
this.maxAltitude = maxAltitude;
this.maxVelocity = maxVelocity;
this.maxAcceleration = maxAcceleration;
this.timeToApogee = timeToApogee;
this.flightTime = flightTime;
this.groundHitVelocity = groundHitVelocity;
+ this.launchRodVelocity = launchRodVelocity;
}
return groundHitVelocity;
}
+ public double getLaunchRodVelocity() {
+ return launchRodVelocity;
+ }
+
/**
groundHitVelocity = Double.NaN;
}
+
// Time to apogee
List<Double> time = branch.get(FlightDataType.TYPE_TIME);
List<Double> altitude = branch.get(FlightDataType.TYPE_ALTITUDE);
else
timeToApogee = Double.NaN;
+
+ // Launch rod velocity
+ eventloop: for (FlightEvent event : branch.getEvents()) {
+ if (event.getType() == FlightEvent.Type.LAUNCHROD) {
+ double t = event.getTime();
+ List<Double> velocity = branch.get(FlightDataType.TYPE_VELOCITY_TOTAL);
+ if (velocity == null) {
+ break;
+ }
+ for (int i = 0; i < velocity.size(); i++) {
+ if (time.get(i) >= t) {
+ launchRodVelocity = velocity.get(i);
+ break eventloop;
+ }
+ }
+ }
+ }
+
// Max. acceleration (must be after apogee time)
if (branch.get(FlightDataType.TYPE_ACCELERATION_TOTAL) != null) {
maxAcceleration = calculateMaxAcceleration();
} else {
maxAcceleration = Double.NaN;
}
+
+ log.info("Computed flight values:" +
+ " maxAltitude=" + maxAltitude +
+ " maxVelocity=" + maxVelocity +
+ " maxAcceleration=" + maxAcceleration +
+ " maxMachNumber=" + maxMachNumber +
+ " timeToApogee=" + timeToApogee +
+ " flightTime=" + flightTime +
+ " groundHitVelocity=" + groundHitVelocity +
+ " launchRodVelocity=" + launchRodVelocity);
}