Compute rotation matrix using the magnetic field

浪子不回头ぞ 提交于 2019-12-03 00:50:46

Orientation is not a rotation matrix as it only provides you angles related to magnetic North. You can obtain the rotation matrix (Direction Cosine Matrix) that will help you to transform coordinates from your device frame to the Earth's frame this way :

with

= azimuth (radians)

= pitch (radians)

= roll (radians)

I know that this is an old thread but in case it helps, for Android I think the 3x3 rotation matrix is actually given by a variation of the approved answer. To be specific, in Android the rotation matrix is

     (cosφ cosψ - sinφ sinψ sinθ)     sinφ cosθ     ( cosφ sinψ + sinφ cosψ sinθ)
    -(sinφ cosψ + cosφ sinψ sinθ)     cosφ cosθ     (-sinφ sinψ + cosφ cosψ sinθ)
              -sinψ cosθ                 -sinθ                  cosφ cosθ

where

    φ = azimuth
    θ = pitch
    ψ = roll

which corresponds to the 3x3 Android rotation matrix R[0] to R[8] (matrixR in the question) via

    R[0] R[1] R[2]
    R[3] R[4] R[5]
    R[6] R[7] R[8]
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!