问题
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