当前位置: 首页>>代码示例>>C++>>正文


C++ GlidePolar::GetMC方法代码示例

本文整理汇总了C++中GlidePolar::GetMC方法的典型用法代码示例。如果您正苦于以下问题:C++ GlidePolar::GetMC方法的具体用法?C++ GlidePolar::GetMC怎么用?C++ GlidePolar::GetMC使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GlidePolar的用法示例。


在下文中一共展示了GlidePolar::GetMC方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: UpdateStatsGlide

bool 
AbstractTask::UpdateIdle(const AircraftState &state,
                         const GlidePolar &glide_polar)
{
  if (TaskStarted() && task_behaviour.calc_cruise_efficiency) {
    fixed val = fixed_one;
    if (CalcCruiseEfficiency(state, glide_polar, val))
      stats.cruise_efficiency = std::max(ce_lpf.update(val), fixed_zero);
  } else {
    stats.cruise_efficiency = ce_lpf.reset(fixed_one);
  }

  if (TaskStarted() && task_behaviour.calc_effective_mc) {
    fixed val = glide_polar.GetMC();
    if (CalcEffectiveMC(state, glide_polar, val))
      stats.effective_mc = std::max(em_lpf.update(val), fixed_zero);
  } else {
    stats.effective_mc = em_lpf.reset(glide_polar.GetMC());
  }

  if (task_behaviour.calc_glide_required)
    UpdateStatsGlide(state, glide_polar);
  else
    stats.glide_required = fixed_zero; // error

  return false;
}
开发者ID:davidswelt,项目名称:XCSoar,代码行数:27,代码来源:AbstractTask.cpp

示例2: fixed

bool 
AbstractTask::UpdateIdle(const AircraftState &state,
                         const GlidePolar &glide_polar)
{
  if (stats.start.task_started && task_behaviour.calc_cruise_efficiency &&
      glide_polar.IsValid()) {
    fixed val = fixed(1);
    if (CalcCruiseEfficiency(state, glide_polar, val))
      stats.cruise_efficiency = std::max(ce_lpf.Update(val), fixed(0));
  } else {
    stats.cruise_efficiency = ce_lpf.Reset(fixed(1));
  }

  if (stats.start.task_started && task_behaviour.calc_effective_mc &&
      glide_polar.IsValid()) {
    fixed val = glide_polar.GetMC();
    if (CalcEffectiveMC(state, glide_polar, val))
      stats.effective_mc = std::max(em_lpf.Update(val), fixed(0));
  } else {
    stats.effective_mc = em_lpf.Reset(glide_polar.GetMC());
  }

  if (task_behaviour.calc_glide_required && glide_polar.IsValid())
    UpdateStatsGlide(state, glide_polar);
  else
    stats.glide_required = fixed(0); // error

  return false;
}
开发者ID:rjsikarwar,项目名称:XCSoar,代码行数:29,代码来源:AbstractTask.cpp

示例3: chart

void
RenderMacCready(Canvas &canvas, const PixelRect rc,
                 const ChartLook &chart_look,
                 const GlidePolar &glide_polar)
{
  ChartRenderer chart(chart_look, canvas, rc);

  if (!glide_polar.IsValid()) {
    chart.DrawNoData();
    return;
  }

  chart.ScaleXFromValue(0);
  chart.ScaleXFromValue(MAX_MACCREADY);
  chart.ScaleYFromValue(0);
  chart.ScaleYFromValue(glide_polar.GetVMax());

  chart.DrawXGrid(Units::ToSysVSpeed(1), 1, ChartRenderer::UnitFormat::NUMERIC);
  chart.DrawYGrid(Units::ToSysSpeed(10), 10, ChartRenderer::UnitFormat::NUMERIC);

  GlidePolar gp = glide_polar;
  double m = 0;
  double m_last;
  gp.SetMC(m);
  double v_last = gp.GetVBestLD();
  double vav_last = 0;
  do {
    m_last = m;
    m+= MAX_MACCREADY/STEPS_MACCREADY;
    gp.SetMC(m);
    const double v = gp.GetVBestLD();
    const double vav = gp.GetAverageSpeed();
    chart.DrawLine(m_last, v_last, m, v, ChartLook::STYLE_BLACK);
    chart.DrawLine(m_last, vav_last, m, vav, ChartLook::STYLE_BLUETHINDASH);
    v_last = v;
    vav_last = vav;
  } while (m<MAX_MACCREADY);

  // draw current MC setting
  chart.DrawLine(glide_polar.GetMC(), 0, glide_polar.GetMC(), glide_polar.GetVMax(),
                 ChartLook::STYLE_REDTHICKDASH);

  // draw labels and other overlays

  gp.SetMC(0.9*MAX_MACCREADY);
  chart.DrawLabel(_T("Vopt"), 0.9*MAX_MACCREADY, gp.GetVBestLD());
  gp.SetMC(0.9*MAX_MACCREADY);
  chart.DrawLabel(_T("Vave"), 0.9*MAX_MACCREADY, gp.GetAverageSpeed());

  chart.DrawYLabel(_T("V"), Units::GetSpeedName());
  chart.DrawXLabel(_T("MC"), Units::GetVerticalSpeedName());

  RenderGlidePolarInfo(canvas, rc, chart_look, glide_polar);
}
开发者ID:Advi42,项目名称:XCSoar,代码行数:54,代码来源:MacCreadyRenderer.cpp

示例4: bmc

bool 
UnorderedTask::CalcBestMC(const AircraftState &aircraft,
                          const GlidePolar &glide_polar,
                          fixed& best) const
{
  TaskPoint *tp = GetActiveTaskPoint();
  if (!tp) {
    best = glide_polar.GetMC();
    return false;
  }
  TaskBestMc bmc(tp, aircraft, task_behaviour.glide, glide_polar);
  return bmc.search(glide_polar.GetMC(), best);
}
开发者ID:davidswelt,项目名称:XCSoar,代码行数:13,代码来源:UnorderedTask.cpp

示例5: bce

bool 
OrderedTask::CalcEffectiveMC(const AircraftState &aircraft,
                             const GlidePolar &glide_polar,
                             fixed &val) const
{
  if (AllowIncrementalBoundaryStats(aircraft)) {
    TaskEffectiveMacCready bce(task_points, active_task_point, aircraft,
                               task_behaviour.glide, glide_polar);
    val = bce.search(glide_polar.GetMC());
    return true;
  } else {
    val = glide_polar.GetMC();
    return false;
  }
}
开发者ID:damianob,项目名称:xcsoar,代码行数:15,代码来源:OrderedTask.cpp

示例6: AirspaceAircraftPerformance

 /**
  * Specialisation based on simplified theoretical MC cross-country
  * speeds.  Assumes cruise at best LD (ignoring wind) for current MC
  * setting, climb rate at MC setting, with direct descent possible
  * at sink rate of cruise.
  */
 explicit AirspaceAircraftPerformance(const GlidePolar &polar)
   :vertical_tolerance(0),
    cruise_speed(polar.GetVBestLD()), cruise_descent(polar.GetSBestLD()),
    descent_rate(polar.GetSMax()),
    climb_rate(polar.GetMC()),
    max_speed(polar.GetVMax()) {
   assert(polar.IsValid());
 }
开发者ID:DRIZO,项目名称:xcsoar,代码行数:14,代码来源:AirspaceAircraftPerformance.hpp

示例7:

bool 
AbstractTask::CalcEffectiveMC(const AircraftState &state_now,
                              const GlidePolar &glide_polar,
                              fixed &val) const
{
  val = glide_polar.GetMC();
  return true;
}
开发者ID:davidswelt,项目名称:XCSoar,代码行数:8,代码来源:AbstractTask.cpp

示例8: bmc

bool
OrderedTask::CalcBestMC(const AircraftState &aircraft,
                        const GlidePolar &glide_polar,
                        fixed &best) const
{
  // note setting of lower limit on mc
  TaskBestMc bmc(task_points, active_task_point, aircraft,
                 task_behaviour.glide, glide_polar);
  return bmc.search(glide_polar.GetMC(), best);
}
开发者ID:damianob,项目名称:xcsoar,代码行数:10,代码来源:OrderedTask.cpp

示例9: ResetAutoMC

bool 
AbstractTask::UpdateAutoMC(GlidePolar &glide_polar,
                           const AircraftState& state, fixed fallback_mc)
{
  if (!positive(fallback_mc))
    fallback_mc = glide_polar.GetMC();

  if (!TaskStarted(true) || !task_behaviour.auto_mc) {
    ResetAutoMC();
    return false;
  }

  if (task_behaviour.auto_mc_mode == TaskBehaviour::AutoMCMode::CLIMBAVERAGE) {
    stats.mc_best = mc_lpf.reset(fallback_mc);
    mc_lpf_valid = true;
    trigger_auto = false;
    return false;
  }

  fixed mc_found;
  if (CalcBestMC(state, glide_polar, mc_found)) {
    // improved solution found, activate auto fg mode
    if (mc_found > stats.mc_best)
      trigger_auto = true;
  } else {
    // no solution even at mc=0, deactivate auto fg mode
    trigger_auto = false;
  }

  if (!trigger_auto &&
      task_behaviour.auto_mc_mode == TaskBehaviour::AutoMCMode::FINALGLIDE &&
      stats.mc_best >= fixed(0.05)) {
    /* no solution, but forced final glide AutoMacCready - converge to
       zero */
    mc_found = fixed_zero;
    trigger_auto = true;
  }

  if (trigger_auto && mc_lpf_valid) {
    // smooth out updates
    stats.mc_best = std::max(mc_lpf.update(mc_found), fixed_zero);
    glide_polar.SetMC(stats.mc_best);
  } else {
    // reset lpf so will be smooth next time it becomes active
    stats.mc_best = mc_lpf.reset(fallback_mc);
    mc_lpf_valid = true;
  }

  return trigger_auto;
}
开发者ID:davidswelt,项目名称:XCSoar,代码行数:50,代码来源:AbstractTask.cpp

示例10: positive

static void
CheckTotal(const AircraftState &aircraft, const TaskStats &stats,
           const TaskWaypoint &start, const TaskWaypoint &tp1,
           const TaskWaypoint &finish)
{
  const fixed min_arrival_alt1 = tp1.GetWaypoint().elevation +
    task_behaviour.safety_height_arrival;
  const fixed min_arrival_alt2 = finish.GetWaypoint().elevation +
    task_behaviour.safety_height_arrival;
  const GeoVector vector0 =
    start.GetWaypoint().location.DistanceBearing(tp1.GetWaypoint().location);
  const GeoVector vector1 =
    aircraft.location.DistanceBearing(tp1.GetWaypoint().location);
  const GeoVector vector2 =
    tp1.GetWaypoint().location.DistanceBearing(finish.GetWaypoint().location);
  const fixed ld = glide_polar.GetBestLD();
  const fixed height_consumption1 = vector1.distance / ld;

  const fixed height_consumption2 = vector2.distance / ld;

  const ElementStat &total = stats.total;
  const GlideResult &solution_remaining = total.solution_remaining;
  const fixed distance_nominal = vector0.distance + vector2.distance;
  const fixed distance_ahead = vector1.distance + vector2.distance;

  ok1(equals(stats.distance_nominal, distance_nominal));
  ok1(equals(stats.distance_min, distance_nominal));
  ok1(equals(stats.distance_max, distance_nominal));

  ok1(!total.vector_remaining.IsValid());
  ok1(solution_remaining.IsOk());

  ok1(equals(solution_remaining.vector.distance, distance_ahead));
  ok1(equals(solution_remaining.height_glide, distance_ahead / ld));

  fixed alt_required_at_1 = std::max(min_arrival_alt1,
                                     min_arrival_alt2 + height_consumption2);
  fixed alt_required_at_aircraft = alt_required_at_1 + height_consumption1;
  ok1(equals(solution_remaining.GetRequiredAltitudeWithDrift(),
             alt_required_at_aircraft));
  ok1(equals(solution_remaining.altitude_difference,
             aircraft.altitude - alt_required_at_aircraft));
  ok1(equals(solution_remaining.height_climb,
             positive(glide_polar.GetMC())
             ? alt_required_at_aircraft - aircraft.altitude
             : fixed(0)));
}
开发者ID:Adrien81,项目名称:XCSoar,代码行数:47,代码来源:TestOrderedTask.cpp

示例11: GlideSolutionRemaining

void
AbstractTask::UpdateGlideSolutions(const AircraftState &state,
                                   const GlidePolar &glide_polar)
{
  GlideSolutionRemaining(state, glide_polar, stats.total.solution_remaining,
                           stats.current_leg.solution_remaining);

  if (positive(glide_polar.GetMC())) {
    GlidePolar polar_mc0 = glide_polar;
    polar_mc0.SetMC(fixed_zero); 
    
    GlideSolutionRemaining(state, polar_mc0, stats.total.solution_mc0,
                             stats.current_leg.solution_mc0);
  } else {
    // no need to re-calculate, just copy
    stats.total.solution_mc0 = stats.total.solution_remaining;
    stats.current_leg.solution_mc0 = stats.current_leg.solution_remaining;
  }

  GlideSolutionTravelled(state, glide_polar,
                         stats.total.solution_travelled,
                           stats.current_leg.solution_travelled);

  GlideSolutionPlanned(state, glide_polar,
                       stats.total.solution_planned,
                         stats.current_leg.solution_planned,
                         stats.total.remaining_effective,
                         stats.current_leg.remaining_effective,
                         stats.total.solution_remaining,
                         stats.current_leg.solution_remaining);

  CalculatePirker(stats.total.pirker, stats.total.planned,
                  stats.total.remaining_effective);

  CalculatePirker(stats.current_leg.pirker, stats.current_leg.planned,
                  stats.current_leg.remaining_effective);

  Copy(stats.current_leg.remaining, stats.current_leg.solution_remaining);
  Copy(stats.current_leg.travelled, stats.current_leg.solution_travelled);
  Copy(stats.current_leg.planned, stats.current_leg.solution_planned);

  stats.total.gradient = ::AngleToGradient(CalcGradient(state));
  stats.current_leg.gradient = ::AngleToGradient(CalcLegGradient(state));
}
开发者ID:davidswelt,项目名称:XCSoar,代码行数:44,代码来源:AbstractTask.cpp

示例12: visible

void 
InputEvents::eventNearestAirspaceDetails(gcc_unused const TCHAR *misc)
{
  const MoreData &basic = CommonInterface::Basic();
  const DerivedInfo &calculated = CommonInterface::Calculated();
  const ComputerSettings &settings_computer =
    CommonInterface::GetComputerSettings();

  ProtectedAirspaceWarningManager *airspace_warnings = GetAirspaceWarnings();
  if (airspace_warnings != NULL && !airspace_warnings->warning_empty()) {
    // Prevent the dialog from closing itself without active warning
    // This is relevant if there are only acknowledged airspaces in the list
    // AutoClose will be reset when the dialog is closed again by hand
    dlgAirspaceWarningsShowModal(*XCSoarInterface::main_window,
                                 *airspace_warnings);
    return;
  }

  const AircraftState aircraft_state =
    ToAircraftState(basic, calculated);
  AirspaceVisiblePredicate visible(settings_computer.airspace,
                          CommonInterface::GetMapSettings().airspace,
                          aircraft_state);
  GlidePolar polar = settings_computer.polar.glide_polar_task;
  polar.SetMC(max(polar.GetMC(),fixed_one));
  AirspaceAircraftPerformanceGlide perf(polar);
  AirspaceSoonestSort ans(aircraft_state, perf, fixed(1800), visible);

  const AbstractAirspace* as = ans.find_nearest(airspace_database);
  if (!as) {
    return;
  } 

  dlgAirspaceDetails(*as, airspace_warnings);

  // clear previous warning if any
  XCSoarInterface::main_window->popup.Acknowledge(PopupMessage::MSG_AIRSPACE);

  // TODO code: No control via status data (ala DoStatusMEssage)
  // - can we change this?
//  Message::AddMessage(5000, Message::MSG_AIRSPACE, text);
}
开发者ID:,项目名称:,代码行数:42,代码来源:

示例13: GetSafetyHeight

static void
CheckLeg(const TaskWaypoint &tp, const AircraftState &aircraft,
         const TaskStats &stats)
{
  const GeoPoint destination = tp.GetWaypoint().location;
  const fixed safety_height = GetSafetyHeight(tp);
  const fixed min_arrival_alt = tp.GetWaypoint().elevation + safety_height;
  const GeoVector vector = aircraft.location.DistanceBearing(destination);
  const fixed ld = glide_polar.GetBestLD();
  const fixed height_above_min = aircraft.altitude - min_arrival_alt;
  const fixed height_consumption = vector.distance / ld;
  const ElementStat &leg = stats.current_leg;
  const GlideResult &solution_remaining = leg.solution_remaining;

  ok1(leg.vector_remaining.IsValid());
  ok1(equals(leg.vector_remaining.distance, vector.distance));
  ok1(equals(leg.vector_remaining.bearing, vector.bearing));

  ok1(solution_remaining.IsOk());
  ok1(solution_remaining.vector.IsValid());
  ok1(equals(solution_remaining.vector.distance, vector.distance));
  ok1(equals(solution_remaining.vector.bearing, vector.bearing));
  ok1(equals(solution_remaining.height_glide, height_consumption));
  ok1(equals(solution_remaining.altitude_difference,
             height_above_min - height_consumption));
  ok1(equals(solution_remaining.GetRequiredAltitudeWithDrift(),
             min_arrival_alt + height_consumption));

  if (height_above_min >= height_consumption) {
    /* straight glide */
    ok1(equals(solution_remaining.height_climb, 0));
  } else if (positive(glide_polar.GetMC())) {
    /* climb required */
    ok1(equals(solution_remaining.height_climb,
               height_consumption - height_above_min));
  } else {
    /* climb required, but not possible (MC=0) */
    ok1(equals(solution_remaining.height_climb, 0));
  }
}
开发者ID:Adrien81,项目名称:XCSoar,代码行数:40,代码来源:TestOrderedTask.cpp

示例14: chart

void
RenderClimbChart(Canvas &canvas, const PixelRect rc,
                 const ChartLook &chart_look,
                 const FlightStatistics &fs,
                 const GlidePolar &glide_polar)
{
  ChartRenderer chart(chart_look, canvas, rc);

  if (fs.thermal_average.IsEmpty()) {
    chart.DrawNoData();
    return;
  }

  fixed MACCREADY = glide_polar.GetMC();

  chart.ScaleYFromData(fs.thermal_average);
  chart.ScaleYFromValue(MACCREADY + fixed(0.5));
  chart.ScaleYFromValue(fixed(0));

  chart.ScaleXFromValue(fixed(-1));
  chart.ScaleXFromValue(fixed(fs.thermal_average.GetCount()));

  chart.DrawYGrid(Units::ToSysVSpeed(fixed(1)),
                  ChartLook::STYLE_THINDASHPAPER, fixed(1), true);
  chart.DrawBarChart(fs.thermal_average);

  chart.DrawLine(fixed(0), MACCREADY,
                 fixed(fs.thermal_average.GetCount()), MACCREADY,
                 ChartLook::STYLE_REDTHICK);

  chart.DrawLabel(_T("MC"),
                  std::max(fixed(0.5),
                           fs.thermal_average.GetGradient() - fixed(1)),
                  MACCREADY);

  chart.DrawTrendN(fs.thermal_average, ChartLook::STYLE_BLUETHIN);

  chart.DrawXLabel(_T("n"));
  chart.DrawYLabel(_T("w"), Units::GetVerticalSpeedName());
}
开发者ID:Adrien81,项目名称:XCSoar,代码行数:40,代码来源:ClimbChartRenderer.cpp

示例15: vector

static void
Test(const fixed distance, const fixed altitude, const SpeedVector wind)
{
    const GeoVector vector(distance, Angle::Zero());
    const GlideState state(vector,
                           fixed(2000), fixed(2000) + altitude,
                           wind);
    const GlideResult result =
        MacCready::Solve(glide_settings, glide_polar, state);

    const fixed ld_ground = glide_polar.GetLDOverGround(vector.bearing, wind);

    const fixed mc = glide_polar.GetMC();
    const fixed v_climb_progress = mc * ld_ground - state.head_wind;

    const fixed initial_glide_distance = state.altitude_difference * ld_ground;
    if (initial_glide_distance >= distance ||
            (!positive(mc) && !positive(v_climb_progress))) {
        /* reachable by pure glide */
        ok1(result.validity == GlideResult::Validity::OK);

        const fixed best_speed =
            glide_polar.GetBestGlideRatioSpeed(state.head_wind);
        const fixed best_sink = glide_polar.SinkRate(best_speed);
        const fixed ld_ground2 = positive(mc)
                                 ? ld_ground
                                 : (best_speed - state.head_wind) / best_sink;

        const fixed height_glide = distance / ld_ground2;
        const fixed height_climb = fixed(0);
        const fixed altitude_difference = altitude - height_glide;

        ok1(equals(result.head_wind, wind.norm));
        ok1(equals(result.vector.distance, distance));
        ok1(equals(result.height_climb, height_climb));
        ok1(equals(result.height_glide, height_glide));
        ok1(equals(result.altitude_difference, altitude_difference));
        return;
    }

    if (!positive(v_climb_progress)) {
        /* excessive wind */
        ok1(result.validity == GlideResult::Validity::WIND_EXCESSIVE);
        return;
    }

    /*
    const fixed drifted_distance = (distance - initial_glide_distance)
      * state.head_wind / v_climb_progress;
      */
    const fixed drifted_height_climb = (distance - initial_glide_distance)
                                       * mc / v_climb_progress;
    const fixed drifted_height_glide =
        drifted_height_climb + state.altitude_difference;

    const fixed height_glide = drifted_height_glide;
    const fixed altitude_difference = altitude - height_glide;
    const fixed height_climb = drifted_height_climb;

    const fixed time_climb = height_climb / mc;
    const fixed time_glide = height_glide / glide_polar.GetSBestLD();
    const fixed time_elapsed = time_climb + time_glide;

    /* more tolerance with strong wind because this unit test doesn't
       optimise pure glide */
    const int accuracy = positive(altitude) && positive(wind.norm)
                         ? (wind.norm > fixed(5) ? 5 : 10)
                         : ACCURACY;

    ok1(result.validity == GlideResult::Validity::OK);
    ok1(equals(result.head_wind, wind.norm));
    ok1(equals(result.vector.distance, distance));
    ok1(equals(result.height_climb, height_climb, accuracy));
    ok1(equals(result.height_glide, height_glide, accuracy));
    ok1(equals(result.altitude_difference, altitude_difference, accuracy));
    ok1(equals(result.time_elapsed, time_elapsed, accuracy));
}
开发者ID:,项目名称:,代码行数:77,代码来源:


注:本文中的GlidePolar::GetMC方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。