fix(cockpit): read a rounded-north destination heading as 000

359.6 degrees was shown as 360 degrees on the destination bearing while the compass tape uses 000.
This commit is contained in:
Rudy Celekli committed 2026-10-24 00:24:43 -04:00
1 parent 9d3548c27c
commit 05316bb34b
3 files changed
+20 -1

No files matched your search

+9
View File
@@ -6,6 +6,15 @@ export function normalizeHeading(value) {
return ((value % 360) + 360) % 360;
}
/**
* Three-digit heading readout, 000–359.
* Rounding 359.5° and above lands on north (000), not 360.
*/
export function formatHeadingReadout(degrees) {
if (!Number.isFinite(degrees)) return '---';
return String(Math.round(normalizeHeading(degrees)) % 360).padStart(3, '0');
}
/** Advance a displayed heading along the shortest arc without exceeding a slew rate. */
export function slewHeading(current, target, maxStepDeg) {
const from = normalizeHeading(current);