V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
332781100
V2EX  ›  问与答

android 的传感器,究竟有多少个坐标系啊?而下面这个函数,传入一个 values 作为返回参数,又返回同一个 values,用意何在呢?这是 android 的源代码

  •  
  •   332781100 · Nov 18, 2014 · 2169 views
    This topic created in 4184 days ago, the information mentioned may be changed or developed.
    public static float[] getOrientation(float[] R, float values[]) {
    /*
    * 4x4 (length=16) case:
    * / R[ 0] R[ 1] R[ 2] 0 \
    * | R[ 4] R[ 5] R[ 6] 0 |
    * | R[ 8] R[ 9] R[10] 0 |
    * \ 0 0 0 1 /
    *
    * 3x3 (length=9) case:
    * / R[ 0] R[ 1] R[ 2] \
    * | R[ 3] R[ 4] R[ 5] |
    * \ R[ 6] R[ 7] R[ 8] /
    *
    */
    if (R.length == 9) {
    values[0] = (float)Math.atan2(R[1], R[4]);
    values[1] = (float)Math.asin(-R[7]);
    values[2] = (float)Math.atan2(-R[6], R[8]);
    } else {
    values[0] = (float)Math.atan2(R[1], R[5]);
    values[1] = (float)Math.asin(-R[9]);
    values[2] = (float)Math.atan2(-R[8], R[10]);
    }
    return values;
    }
    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   974 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 23:40 · PVG 07:40 · LAX 16:40 · JFK 19:40
    ♥ Do have faith in what you're doing.