Scalars: b = bearing (device) i = inclination (device) r = rotation (device) dip = dip of magnetic field of vertical. negative if north pointing into ground Vectors: Mr = Magnetic field vector in real world, usually (0,cos(dip),sin(dip)) Gr = Gravitatinal field vector in real world (0,0,-1) Dr = Device Laser vector in real world (cos(b)*cos(i),sin(b)*cos(i),sin(i)) (cos(b)^2*cos(i)^2) + (sin(b)^2 * cos(i)^2) + sin(i)^2 = (cos(b)^2 + sin(b)^2)(cos(i)^2) + sin(i)^2 = cos(i)^2 + sin(i)^2 Tick - adds up... Offshoot1 = O1 = Dr dot Gr - gives us a horizontal field Offshoot 2 = O2 = Gr dot O1 - gives us our third orthogonal field Rotational conversion matrix R(D)= ( Dr O1 O2)^-1 . ( sin(-r) cos(-r)) (-cos(-r) sin(-r)) Next we need a calibration matrix Mx,My,Mz = Vectors of Magnetometers in Device coords eg (0.9,0.1,0.1), multiplied by scaling error Mt = translation error (typically +512 or whatever) Gx etc for accels Mc = (Mx My Mz Mt)^-1 ( 0 0 0 1) Gc = (Gx Gy Gz Gt)^-1 ( 0 0 0 1) Final data = Md = Mr x R x Mc = Gd = Gr x R x Gc Convert Realworld co-ords of device vector into a matrix Device operation Gc' = Mc' = devices calibration thingy - should be inverses of Mc and Gc G = Gd.Gc' M = Md.Mc' D(own) = G E(ast) = G.M N(orth)= E.G Translation matrix T = (E N D)^-1 Dr = (1 0 0) T b = tan(Dr.x/Dr.y) i = tan(Dr.z/sqrt(Dr.x^2 + Dr.y^2)) Sweet