34 lines
1.2 KiB
Java
34 lines
1.2 KiB
Java
package dev.lumareth.improvedAerodynamics.flight;
|
|
|
|
/**
|
|
* Rise of zero-lift drag around the speed of sound: shock waves build up from Mach 0.8, drag peaks at Mach 1.05 and
|
|
* settles to a lower, still high, level once the flow is fully supersonic from Mach 1.3.
|
|
*/
|
|
final class TransonicDrag {
|
|
private static final double DRAG_RISE_START = 0.80;
|
|
private static final double PEAK = 1.05;
|
|
private static final double SUPERSONIC_START = 1.30;
|
|
|
|
private TransonicDrag() {
|
|
}
|
|
|
|
/**
|
|
* @param mach airspeed divided by the speed of sound
|
|
* @param peakDrag multiplier at the peak
|
|
* @param supersonicDrag multiplier once fully supersonic
|
|
* @return factor for parasitic drag, 1 in subsonic flight
|
|
*/
|
|
static double multiplier(double mach, double peakDrag, double supersonicDrag) {
|
|
if (mach <= DRAG_RISE_START) {
|
|
return 1.0;
|
|
}
|
|
if (mach < PEAK) {
|
|
return 1.0 + (peakDrag - 1.0) * ImprovedAero.smoothstep(DRAG_RISE_START, PEAK, mach);
|
|
}
|
|
if (mach < SUPERSONIC_START) {
|
|
return peakDrag + (supersonicDrag - peakDrag) * ImprovedAero.smoothstep(PEAK, SUPERSONIC_START, mach);
|
|
}
|
|
return supersonicDrag;
|
|
}
|
|
}
|