Tilt compensated compas
http://www.loveelectronics.co.uk/Tutorials/13/tilt-compensated-compass-arduino-tutorial
http://www.freescale.com/files/sensors/doc/app_note/AN4246.pdf
http://circuitcellar.com/editorsblog/implement-a-tilt-and-interference-compensated-electronic-compass/