コード例 #1
0
ファイル: Canvas.cpp プロジェクト: Adrien81/XCSoar
gcc_const
static std::pair<unsigned,unsigned>
AngleToDonutVertices(Angle start, Angle end)
{
  static constexpr Angle epsilon = Angle::FullCircle()
    / int(GLDonutVertices::CIRCLE_SIZE * 4u);

  const Angle delta = end - start;

  if (fabs(delta.AsDelta().Native()) <= epsilon.Native())
    /* full circle */
    return std::make_pair(0u, unsigned(GLDonutVertices::MAX_ANGLE));

  const unsigned istart = AngleToDonutVertex(start);
  unsigned iend = AngleToDonutVertex(end);

  if (istart == iend && delta > epsilon) {
    if (end - start >= Angle::HalfCircle())
      /* nearly full circle, round down the end */
      iend = GLDonutVertices::PreviousAngle(iend);
    else
      /* slightly larger than epsilon: draw at least two indices */
      iend = GLDonutVertices::NextAngle(iend);
  }

  return std::make_pair(istart, iend);
}
コード例 #2
0
ファイル: GeoPoint.hpp プロジェクト: CnZoom/XcSoarPull
    /**
     * Normalize the values, so this object can be used properly in
     * calculations, without unintended side effects (such as -1 degrees
     * vs 359 degrees).  This modification is in-place.
     */
    GeoPoint &Normalize() {
        longitude = longitude.AsDelta();

        if (latitude < -Angle::QuarterCircle())
            latitude = -Angle::QuarterCircle();
        else if (latitude > Angle::QuarterCircle())
            latitude = Angle::QuarterCircle();

        return *this;
    }
コード例 #3
0
ファイル: AngleFormatter.cpp プロジェクト: Advi42/XCSoar
void
FormatVerticalAngleDelta(TCHAR *buffer, size_t size, Angle value)
{
  assert(buffer != NULL);
  assert(size >= 8);

  auto degrees = lround(value.AsDelta().Degrees());
  if (degrees < -1 || degrees > 1)
    StringFormat(buffer, size, _T("%+d°"), int(degrees));
  else
    _tcscpy(buffer, _T("--"));
}
コード例 #4
0
void
FormatVerticalAngleDelta(TCHAR *buffer, size_t size, Angle value)
{
    assert(buffer != NULL);
    assert(size >= 8);

    int degrees = iround(value.AsDelta().Degrees());
    if (degrees < -1 || degrees > 1)
        _sntprintf(buffer, size, _T("%+d°"), degrees);
    else
        _tcscpy(buffer, _T("--"));
}
コード例 #5
0
static void
OnTimerNotify(gcc_unused WndForm &sender)
{
  if (filter_data.direction_index == 1 && !XCSoarInterface::Calculated().circling) {
    Angle a = last_heading - CommonInterface::Calculated().heading;
    if (a.AsDelta().AbsoluteDegrees() >= fixed(60)) {
      last_heading = CommonInterface::Calculated().heading;
      UpdateList();
      InitializeDirection(true);
      direction_filter->RefreshDisplay();
    }
  }
}
コード例 #6
0
ファイル: WaypointList.cpp プロジェクト: osteocool/XCSoar-1
static void
OnTimerNotify(gcc_unused WndForm &sender)
{
  if (dialog_state.direction_index == 1 && !XCSoarInterface::Calculated().circling) {
    const Angle heading = CommonInterface::Basic().attitude.heading;
    Angle a = last_heading - heading;
    if (a.AsDelta().AbsoluteDegrees() >= fixed(60)) {
      last_heading = heading;
      UpdateList();
      InitializeDirection(true);
    }
  }
}
コード例 #7
0
void
FormatAngleDelta(TCHAR *buffer, size_t size, Angle value)
{
    assert(buffer != NULL);
    assert(size >= 8);

    int degrees = iround(value.AsDelta().Degrees());
    if (degrees > 1)
        _sntprintf(buffer, size, _T("%u°»"), degrees);
    else if (degrees < -1)
        _sntprintf(buffer, size, _T("«%u°"), -degrees);
    else
        _tcscpy(buffer, _T("«»"));
}
コード例 #8
0
ファイル: WaypointList.cpp プロジェクト: StefanL74/XCSoar
static void
OnGPSUpdate(const MoreData &basic)
{
  if (dialog_state.direction_index == 1 &&
      !CommonInterface::Calculated().circling) {
    const Angle heading = basic.attitude.heading;
    Angle a = last_heading - heading;
    if (a.AsDelta().AbsoluteDegrees() >= fixed(60)) {
      last_heading = heading;
      UpdateList();
      InitializeDirection(true);
    }
  }
}
コード例 #9
0
void
AirspaceListWidget::OnGPSUpdate(const MoreData &basic)
{
  if (dialog_state.direction == 0 && !CommonInterface::Calculated().circling) {
    const Angle heading = basic.attitude.heading;
    Angle a = last_heading - heading;
    if (a.AsDelta().AbsoluteDegrees() >= fixed(10)) {
      last_heading = heading;

      UpdateList();
      filter_widget.Update();
    }
  }
}
コード例 #10
0
ファイル: AngleFormatter.cpp プロジェクト: Advi42/XCSoar
void
FormatAngleDelta(TCHAR *buffer, size_t size, Angle value)
{
  assert(buffer != NULL);
  assert(size >= 8);

  auto degrees = lround(value.AsDelta().Degrees());
  if (degrees > 1)
    StringFormat(buffer, size, _T("%u°»"), unsigned(degrees));
  else if (degrees < -1)
    StringFormat(buffer, size, _T("«%u°"), unsigned(-degrees));
  else
    _tcscpy(buffer, _T("«»"));
}
コード例 #11
0
static void
OnTimerNotify(gcc_unused WndForm &Sender)
{
    if (direction_filter == 0 && !CommonInterface::Calculated().circling) {
        Angle a = last_heading - CommonInterface::Calculated().heading;
        if (a.AsDelta().AbsoluteDegrees() >= fixed(10)) {
            last_heading = CommonInterface::Calculated().heading;

            UpdateList();

            DataFieldEnum &df = *(DataFieldEnum *)wpDirection->GetDataField();
            TCHAR buffer[64];
            df.replaceEnumText(0, GetHeadingString(buffer));
            wpDirection->RefreshDisplay();
        }
    }
}
コード例 #12
0
ファイル: DigitEntry.cpp プロジェクト: CnZoom/XcSoarPull
void
DigitEntry::SetLatitude(Angle value, CoordinateFormat format)
{
  // Latitude in floating point degrees
  value = value.AsDelta();
  const fixed degrees = fabs(value.Degrees());

  // Check the first three columns
  assert(columns[0].type == Column::Type::NORTH_SOUTH);
  assert(columns[1].type == Column::Type::DIGIT);
  assert(columns[2].type == Column::Type::DIGIT);
  columns[0].value = negative(value.Native());

  // Set up and check the remaining digits
  SetDigits(degrees, format, true);

  Invalidate();
}
コード例 #13
0
ファイル: AirspaceList.cpp プロジェクト: henrik1g/XCSoar
static void
OnGPSUpdate(const MoreData &basic)
{
  if (dialog_state.direction == 0 && !CommonInterface::Calculated().circling) {
    const Angle heading = basic.attitude.heading;
    Angle a = last_heading - heading;
    if (a.AsDelta().AbsoluteDegrees() >= fixed(10)) {
      last_heading = heading;

      UpdateList();

      DataFieldEnum &df = *(DataFieldEnum *)direction_control->GetDataField();
      TCHAR buffer[64];
      df.replaceEnumText(0, GetHeadingString(buffer));
      direction_control->RefreshDisplay();
    }
  }
}
コード例 #14
0
ファイル: DigitEntry.cpp プロジェクト: rkohel/XCSoar
void
DigitEntry::SetLongitude(Angle value, CoordinateFormat format)
{
    // Longitude in floating point degrees
    value = value.AsDelta();
    const auto degrees = fabs(value.Degrees());

    // Check the first three columns here
    assert(columns[0].type == Column::Type::EAST_WEST);
    assert(columns[1].type == Column::Type::DIGIT19);
    assert(columns[2].type == Column::Type::DIGIT);
    columns[0].value = value.IsNegative();

    // Set up and check the remaining digits
    SetDigits(degrees, format, false);

    Invalidate();
}
コード例 #15
0
void
AATPoint::GetTargetRangeRadial(fixed &range, fixed &radial) const
{
  const fixed oldrange = range;

  const GeoPoint fprev = GetPrevious()->GetLocationRemaining();
  const GeoPoint floc = GetLocation();
  const Angle radialraw = (floc.Bearing(GetTargetLocation()) -
      fprev.Bearing(floc)).AsBearing();

  const fixed d = floc.Distance(GetTargetLocation());
  const fixed radius = floc.Distance(GetLocationMin());
  const fixed rangeraw = min(fixed_one, d / radius);

  radial = radialraw.AsDelta().Degrees();
  const fixed rangesign = (fabs(radial) > fixed(90)) ?
      fixed_minus_one : fixed_one;
  range = rangeraw * rangesign;

  if ((oldrange == fixed_zero) && (range == fixed_zero))
    radial = fixed_zero;
}
コード例 #16
0
ファイル: AATPoint.cpp プロジェクト: Adrien81/XCSoar
RangeAndRadial
AATPoint::GetTargetRangeRadial(fixed oldrange) const
{
  const GeoPoint fprev = GetPrevious()->GetLocationRemaining();
  const GeoPoint floc = GetLocation();
  const Angle radialraw = (floc.Bearing(GetTargetLocation()) -
      fprev.Bearing(floc)).AsBearing();
  Angle radial = radialraw.AsDelta();

  fixed d = floc.Distance(GetTargetLocation());
  if (radial < -Angle::QuarterCircle() || radial > Angle::QuarterCircle())
    d = -d;

  const fixed radius = negative(d)
    ? floc.Distance(GetLocationMin())
    : floc.Distance(GetLocationMax());
  const fixed range = Clamp(d / radius, fixed(-1), fixed(1));

  if (oldrange == fixed(0) && range == fixed(0))
    radial = Angle::Zero();

  return RangeAndRadial{ range, radial };
}
コード例 #17
0
ファイル: GeoPoint.hpp プロジェクト: davidswelt/XCSoar
 /**
  * Normalize the values, so this object can be used properly in
  * calculations, without unintended side effects (such as -1 degrees
  * vs 359 degrees).  This modification is in-place.
  */
 GeoPoint &Normalize() {
   longitude = longitude.AsDelta();
   return *this;
 }