带有传感器信息旋转后的android手机朝向方向

时间:2018-07-17 05:26:59

标签: android android-sensors android-screen

我有要分析的Android手机的日志文件,我正在尝试查找手机的朝向。日志有4列:log_entrytimekeyvalue。我删除了一些不相关的条目,将传感器数据保留在此处:

1046    2015-10-27T17:37:12.126 sensor|magneticField|raw    20.5307,27.912903,-19.042969
1059    2015-10-27T17:37:12.682 sensor|gravity|raw  -3.44763,4.310282,8.105906
1060    2015-10-27T17:37:12.702 sensor|rotationVector|raw   0.2927694,-0.031621482,-0.6736214
1061    2015-10-27T17:37:12.703 sensor|orientation|raw  84.45444,-28.001629,-20.582787
1243    2015-10-27T17:37:13.704 sensor|gyroscope|window 5,0.3242262085071154,0.002710102285323411,0.018316363364503215,0.12471347618924414,0.040062330625930336
1245    2015-10-27T17:37:13.767 sensor|accelerometer|window 4,36.81831910465795,3.154611784990185E-4,9.183022166921088,9.226166408993787,9.204565264371539
2413    2015-10-27T17:41:39.841 sensor|magneticField|raw    26.080322,-127.63672,-39.442444
2596    2015-10-27T17:41:40.410 sensor|gravity|raw  -1.1501468,-0.40935522,9.730364
2597    2015-10-27T17:41:40.419 sensor|rotationVector|raw   -0.04232129,0.045808677,0.39225417
2598    2015-10-27T17:41:40.420 sensor|orientation|raw  313.85678,2.4090059,-6.735284
2604    2015-10-27T17:41:41.171 sensor|accelerometer|window 4,38.62983172205982,1.1600939884971153E-5,9.654755016756964,9.662419888064361,9.656328408619245
3097    2015-10-27T17:46:39.931 sensor|magneticField|raw    26.080322,-127.63672,-39.442444
3110    2015-10-27T17:46:40.537 sensor|gravity|raw  -0.8883529,-0.4162266,9.757458
3111    2015-10-27T17:46:40.544 sensor|rotationVector|raw   -0.048620816,0.012006509,0.77643335
3112    2015-10-27T17:46:40.548 sensor|orientation|raw  258.063,2.442601,-5.197365
3117    2015-10-27T17:46:41.250 sensor|accelerometer|window 4,38.623687629591316,1.0130627960113626E-5,9.65307327903755,9.660463074509671,9.655075638022051
3287    2015-10-27T17:46:41.471 sensor|gyroscope|window 5,0.006274198991127779,8.64517812319579E-8,0.0010331000292853245,0.00176118421374848,0.001177697815335539

我做了一些搜索,据说rotationVector可能就足够了。我在https://math.stackexchange.com/questions/2253071/convert-quaternion-to-vector/2253214中读了答案,但四元数有4个值(wxyz),而rotationVector这里有3个(xyz)。

在旋转之前,还需要一个初始位置来确定最终位置。我在android API文档中找不到任何提及的内容。我不确定初始位置是否会重复。第二rotationVector是否以上次旋转后的位置为参考?还是有固定的初始位置?

感谢您的帮助!

0 个答案:

没有答案