brilliant-msg
    Preparing search index...

    Class CompassHeading

    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 (or MagCalibration.heading) for a true-North heading.

    Index

    Constructors

    Methods

    • Add magnetic declination (deg, +east) to a magnetic heading -> true heading.

      Parameters

      • heading: number
      • declination: number

      Returns number

    • Heading (deg, 0-360) from horizontal magnetometer X/Y, no tilt compensation. Assumes the device is held level. +Y (forward) toward North gives 0deg.

      Parameters

      • x: number
      • y: number

      Returns number

    • Tilt-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.

      Parameters

      • magX: number
      • magY: number
      • magZ: number
      • gravityX: number
      • gravityY: number
      • gravityZ: number

      Returns number

    • Convert a heading (deg) to a 16-point compass label (N, NNE, NE, ...).

      Parameters

      • degrees: number

      Returns string