iphone compass tilt compensation

Posted by m01d on Stack Overflow See other posts from Stack Overflow or by m01d
Published on 2010-03-27T15:46:53Z Indexed on 2010/03/27 15:53 UTC
Read the original article Hit count: 685

hi,

has anybody already programmed a iphone compass heading tilt compensation?

i have got some approaches, but some help or a better solution would be cool!

FIRST i define a vector Ev, calculated out of the cross product of Gv and Hv. Gv is a gravity vector i build out of the accelerometer values and Hv is an heading vector built out the magnetometer values. Ev stands perpendicular on Gv and Hv, so it is heading to horizonatl East.

SECOND i define a vector Rv, calculated out of the cross product Bv and Gv. Bv is my looking vector and it is defined as [0,0,-1]. Rv is perpendicular to Gv and Bv and shows always to the right.

THIRD the angle between these two vectors, Ev and Rv, should be my corrected heading. to calculate the angle i build the dot product and thereof the arcos.

phi = arcos ( Ev * Rv / |Ev| * |Rv| )

Theoretically it should work, but maybe i have to normalize the vectors?!

Has anybody got a solution for this?

Thanks, m01d

© Stack Overflow or respective owner

Related posts about iphone

Related posts about compass