StaticapplyAdd magnetic declination (deg, +east) to a magnetic heading -> true heading.
StaticcalculateHeading (deg, 0-360) from horizontal magnetometer X/Y, no tilt compensation. Assumes the device is held level. +Y (forward) toward North gives 0deg.
StaticcalculateTilt-compensated heading (deg, 0-360) using gravity to remove tilt.
Projects the magnetic vector onto the plane perpendicular to gravity, then
takes the horizontal bearing. gravity is the raw accelerometer vector; it
is normalised here (the projection requires a UNIT vector -- feeding the raw
accel, magnitude ~960, blows up the projection), and its sign does not matter.
NOTE: this is the simplified projection used by the examples. It is exact when level and degrades gracefully with modest tilt; a full rotation into the world horizontal frame would be more accurate at large tilt.
StaticdegreesConvert a heading (deg) to a 16-point compass label (N, NNE, NE, ...).
Compass heading math. Static methods only; mirrors the Python and Dart implementations so all three SDKs produce identical headings.
Magnetic declination is location-specific and left to the caller: look up your own at https://www.ngdc.noaa.gov/geomag/calculators/magcalc.shtml and pass it to
applyDeclination(orMagCalibration.heading) for a true-North heading.