Monday, 15 September 2014

How should I calculate azimuth, pitch, orientation when my Android device isn't flat? -


I am using Android gravity and magnetic field sensors to calculate orientation through SensorManager.getRotationMatrix and SensorManager.getOrientation I am It gives me brain, pitch and orientation number. I feel sensible when the results are lying flat on the basis of the table.

However, I have disabled the switch between portrait and landscape in the manifest, so that getWindowManager () be. GetDefaultDisplay () GetRotation () is always zero when I rotate the device 90 degrees, then standing up, I get into trouble. Sometimes the number seems quite wrong, and I have realized that it relates to it. However, other apps do not have this problem. For example, I've compared my app to two free sensor testing apps (and). My app agrees with these apps when the device is flat, but there can be significant differences as I rotate the device in vertical position. Both apps start agreeing with each other, how do they cope with this problem?

I think the best way to define angles of your orientation is when the device is not flat. Another proper angular coordination system is to use the standard Euler that you get from SensorManager.getOrientation (...). . I suggest that as I describe, I have put some code that applies it. In addition to the good definition of azimuth, there is also the definition of pitch angle in it, which is the angle given by Math.acos (rotationmatrix [8]) , which is mentioned in another answer.

You can get complete details from the two links given in the first paragraph. However, in short, your rotation matrix from SensorManager.getRotationMatrix (...) is R < / P>

Where (E x , e y , e / sub>), (n x , n y , N z ) and (g x , g y , g j ) are vectors that are east, north and In the direction of gravity The Ngit. Then, the Ajithm angle you want is given by

defined by the equation of the azimuth angle

No comments:

Post a Comment