The compass sensor returns X,Y,Z angles.
My embedded sensor board won't be lying horizontal inside my project, so I'd want basically to factor that out. I will move on a horizontal plane. I'd like to report the bearing from 0 to 360 degrees.
Some ideas come to mind:
Assume the chip's orientation is more or less fixed, somehow detect which (x,y,y) does the closest to a 360 when I turn the rig around, and use that as my rotation axis?
Build a coordinate system where I can get the angle between the before and after position vector. In math it would be defining a plane parallel to the 2 vectors, and computing the angle, based on the dX,dY,dZ angles. Caveat, I still want the angle of rotation oriented so a left turn and a right turn have different signs.
Fudge the 3 values by summing them or their squares, and using that as the rotation angle, if so what's the best math?
Of course I want to do this in a few cycles so fixed math or no math
Thanks for any insight you may have.