Exemplo n.º 1
0
fixed 
AirspaceAircraftPerformance::SolutionGeneral(fixed distance, fixed dh) const
{
  const fixed t_cruise =
      positive(distance) ? distance / GetCruiseSpeed() : fixed(0);
  const fixed h_descent = dh - t_cruise * GetCruiseDescent();

  if (fabs(h_descent) < fixed(1))
    return t_cruise;

  if (positive(h_descent)) {
    // descend steeper than best glide

    fixed mod_descent_rate = GetDescentRate() + vertical_tolerance;

    if (!positive(mod_descent_rate))
      return fixed_big;

    const fixed t_descent = h_descent / mod_descent_rate;
    return std::max(t_cruise, t_descent);

  }

  // require climb

  fixed mod_climb_rate = GetClimbRate() + vertical_tolerance;

  if (!positive(mod_climb_rate))
    return fixed_big;

  const fixed t_climb = -h_descent / mod_climb_rate;
  return t_cruise + t_climb;
}
Exemplo n.º 2
0
double
AirspaceAircraftPerformance::SolutionGeneral(double distance, double dh) const
{
  const auto t_cruise = distance > 0
    ? distance / GetCruiseSpeed()
    : double(0);
  const auto h_descent = dh - t_cruise * GetCruiseDescent();

  if (fabs(h_descent) < 1)
    return t_cruise;

  if (h_descent > 0) {
    // descend steeper than best glide

    auto mod_descent_rate = GetDescentRate() + vertical_tolerance;

    if (mod_descent_rate <= 0)
      return BIG;

    const auto t_descent = h_descent / mod_descent_rate;
    return std::max(t_cruise, t_descent);

  }

  // require climb

  auto mod_climb_rate = GetClimbRate() + vertical_tolerance;

  if (mod_climb_rate <= 0)
    return BIG;

  const auto t_climb = -h_descent / mod_climb_rate;
  return t_cruise + t_climb;
}
Exemplo n.º 3
0
bool 
AirspaceAircraftPerformance::SolutionExists(double distance_max,
                                            double altitude,
                                            double h_min, double h_max) const
{
  if (altitude - h_max > 0 &&
      std::max(GetCruiseDescent(), GetDescentRate()) + vertical_tolerance <= 0)
    return false;

  if (h_min-altitude > 0 &&
      std::max(GetClimbRate(), -GetCruiseDescent()) + vertical_tolerance <= 0)
    return false;

  if (distance_max > 0 && GetCruiseSpeed() <= 0)
    return false;

  return true;
}
Exemplo n.º 4
0
// This calculates the maximum speed we can travel as a whole unit
int BrigadeClass::GetUnitSpeed (void)
	{
	int			speed = 9999;
	Battalion   e;

	e = (Battalion)GetFirstUnitElement();
	if (!e)
		return GetCruiseSpeed();
	while (e)
		{
		if (speed > e->GetCruiseSpeed())
			speed = e->GetCruiseSpeed();
		e = (Battalion)GetNextUnitElement();
		}
	if (speed > 9000)
		MonoPrint("Warning: Unit %d exceeding maximum warp!\n",GetCampID());
	return speed;
	}
Exemplo n.º 5
0
bool 
AirspaceAircraftPerformance::SolutionExists(fixed distance_max,
                                            fixed altitude,
                                            fixed h_min, fixed h_max) const
{
  if (positive(altitude - h_max) &&
      !positive(std::max(GetCruiseDescent(), GetDescentRate())
                + vertical_tolerance))
    return false;

  if (positive(h_min-altitude) &&
      !positive(std::max(GetClimbRate(), -GetCruiseDescent())
                + vertical_tolerance))
    return false;

  if (positive(distance_max) && !positive(GetCruiseSpeed()))
    return false;

  return true;
}