Function navtk::magnetic::mag_to_heading

Function Documentation

double navtk::magnetic::mag_to_heading(double mag_x, double mag_y, double magnetic_declination = 0.0)

Compute heading given a magnetometer measurement.

Assumes the measurements are already calibrated.

Parameters
  • mag_x – magnetic field value on x-axis (any units). Positive x direction is assumed to be to the front.

  • mag_y – magnetic field value on y-axis (any units). Positive y direction is assumed to be to the right.

  • magnetic_declination – magnetic declination (the angle on the horizontal plane between magnetic north and true north). This value varies depending on position on the Earth’s surface. Defaults to 0.0.

Returns

the heading in range (-PI, PI] in radians.