Pong

August 5th 2015 Magnetic Declination

July 27th 2015 Compass Widget | | November 3th 2015 Debugging Native Android Code

The smartphone’s built-in compass measures the direction to magnetic north but not to true geographic north. In order to correct the deviation of the compass, we need to compute the so called magnetic declination, which is modeled by the WMM, the World Magnetic Model.

Let’s excercise an example:

For Central Europe, e.g. the Lat-Lon coordinates 49/11, the magnetic declination according to the WMM is about 2.15 degrees east. The model employs clock-wise angles, so that 2.15 degrees east corresponds to +2.15 degrees clock-wise.

So if your compass is pointing exactly to the magnetic north pole in Central Europe, the clock-wise angle w.r.t. to true north is about +2.15 degrees.

Here is a C++ example, which corrects the magnetic compass readings to be true northings. It uses the magnetic declination code developed on the WMM project page:

#include <iostream>
#include <mini/wmm.h>

// function to convert magnetic declinations into true northings
double mag2true_decl(double mag_decl, double lat, double lon)
{
   double decl = sample_mag(lat, lon);
   double true_decl = mag_decl + decl;

   return(true_decl);
}

// example of calculating the true northing at Lat/Lon 49/11
double lat = 49.0, lon = 11.0;
double mag_decl = 90.0; // magnetic compass pointing east
double true_decl = mag2true_decl(mag_decl, lat, lon);

std::cout << "magnetic reading: " << mag_decl << std::endl;
std::cout << "true northing: " << true_decl << std::endl;

The above example outputs about 92.15 degrees as true northing for a magnetic reading of 90 degrees east.

July 27th 2015 Compass Widget | | November 3th 2015 Debugging Native Android Code

Options: