コード例 #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;
}
コード例 #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;
}
コード例 #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;
}
コード例 #4
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;
}