Esempio n. 1
0
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);
}
Esempio n. 2
0
    /**
     * 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;
    }
Esempio n. 3
0
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("--"));
}
Esempio n. 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("--"));
}
Esempio n. 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();
    }
  }
}
Esempio n. 6
0
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);
    }
  }
}
Esempio n. 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("«»"));
}
Esempio n. 8
0
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);
    }
  }
}
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();
    }
  }
}
Esempio n. 10
0
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("«»"));
}
Esempio n. 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();
        }
    }
}
Esempio n. 12
0
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();
}
Esempio n. 13
0
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();
    }
  }
}
Esempio n. 14
0
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();
}
Esempio n. 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;
}
Esempio n. 16
0
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 };
}
Esempio n. 17
0
 /**
  * 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;
 }