Compute rotation matrix using the magnetic field

前端 未结 2 609
隐瞒了意图╮
隐瞒了意图╮ 2021-02-04 22:17

In get rotation matrix value it contains public static boolean getRotationMatrix (float[] R, float[] I, float[] gravity, float[] geomagnetic) Here how can i calcula

相关标签:
2条回答
  • 2021-02-04 23:03

    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 :

    DCM from Wikipedia

    with

    azimuth = azimuth (radians)

    pitch = pitch (radians)

    roll = roll (radians)

    0 讨论(0)
  • 2021-02-04 23:05

    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]
    
    0 讨论(0)
提交回复
热议问题