Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you have access to the accelerometer, you can use the <a href="http://bit.ly/fjJ0dk" rel="nofollow" title="getOrientation()">getOrientation()</a> method, which returns azimuth, pitch, and roll as determined from the two sensors, and calculated via the <a href="http://bit.ly/hU1jxV" rel="nofollow" title="getRotationMatrix()">getRotationMatrix()</a> method.</p> <p><strong>EDITS</strong></p> <p>Response to comments... I see your question now. Sorry. With just the 3-axis magnetometer, you can't accurately get azimuth, pitch, and roll except when the device is parallel to the surface of the earth. Remember using a needle compass and having it either a) on a spindle so you can see and manually compensate for tilt, or b) sealed in liquid so you can get the bubble level to the center? To get azimuth: </p> <pre><code>azimuth = arctan(y/x) </code></pre> <p>Now, if you tilt the phone, the errors in the x/y plane sensing can get big. Now you need to figure out the tilt (with the accelerometer), then measure the Z-axis magnetic strength, and then use the three to compensate. This is essentially what you know as getRotationMatrix() and getOrientation().</p> <p>Part of the reason I think Sensor.TYPE_ORIENTATION was deprecated in API 8 was because there isn't a separate orientation sensor <strong>per se</strong>. It is a combination of magnetic field and acceleration sensing.</p> <p>A good paper that I dug up that covers it all:</p> <p><a href="http://www.ssec.honeywell.com/position-sensors/datasheets/sae.pdf" rel="nofollow">http://www.ssec.honeywell.com/position-sensors/datasheets/sae.pdf</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload