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); }
/** * 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; }
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("--")); }
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("--")); }
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(); } } }
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); } } }
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("«»")); }
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(); } } }
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("«»")); }
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(); } } }
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(); }
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(); } } }
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(); }
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; }
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 }; }
/** * 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; }