Android getOrientation() returns azimuth, positive or negative?

大城市里の小女人 提交于 2020-01-04 04:26:06

问题


Assumption: the phone is held flat (parallel with the ground).

I am using getRotationMatrix() and getOrientation (float[] R, float[] values) to get the azimuth. Under this assumption, the azimuth is simply values[0].

The documentation says:

All three angles above are in radians and positive in the counter-clockwise direction.

Then I checked, when my phone's y axis points to the North, the azimuth is indeed 0.

However, here comes the problem: when my phone's y axis points to West, i.e. I rotated my phone counter-clockwise to make it point from North to West, the azimuth is negative!

Shouldn't the angle be positive when it is rotated counter-clockwise from North?

Where goes wrong?


回答1:


No, if the positive direction of Z points to the sky then when y axis points to West then the angle is positive. But the coordinate used in getOrientation the positive direction of Z points down to the earth, thus now what seems counter-clockwise becomes clockwise, so West is negative.



来源:https://stackoverflow.com/questions/18182442/android-getorientation-returns-azimuth-positive-or-negative

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