この前書いた日経ソフトウエア2010年1月の記事の中でiPhoneとAndroidの電子コンパスについて書いたのですが、紙面の都合上Androidで真北をとる方法を載せることができませんでした。せっかくなので補足の意味も込めてAndroidで真北をとる方法を紹介しiPhoneの実装と比較してみます。 そもそも磁北と真北の違いは? 磁北は文字通り方位磁石が指す北のことで、真北とは地球の地軸の北のことです。この磁北と真北には場所によってズレがあります。たとえば沖縄だと約4度とか、東京だと約7度とか。このズレのことを磁気偏角といいます。日本では真北は磁北から西にずれる(アメリカなど地域によっては東にずれる)ので磁北から磁気偏角を引いてやれば真北を求めることが出来ます。 真北 = 磁北 - 磁気偏角AndroidやiPhoneで真北をとるために位置情報が必要なのはこの磁気偏角を計算するためです。