Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The rotation matrix in Android provides a rotation from the body (a.k.a device) frame to the world (a.k.a. inertial) frame. A normal back facing camera appears in landscape mode on the screen. This is native mode for a tablet, so has the following axes in the device frame:</p> <pre><code>camera_x_tablet_body = (1,0,0) camera_y_tablet_body = (0,1,0) camera_z_tablet_body = (0,0,1) </code></pre> <p>On a phone, where portrait is native mode, a rotation of the device into landscape with top turned to point left is:</p> <pre><code>camera_x_phone_body = (0,-1,0) camera_y_phone_body = (1,0,0) camera_z_phone_body = (0,0,1) </code></pre> <p>Now applying the rotation matrix will put this in the world frame, so (for rotation matrix R[] of size 9):</p> <pre><code>camera_x_tablet_world = (R[0],R[3],R[6]); camera_y_tablet_world = (R[1],R[4],R[7]); camera_z_tablet_world = (R[2],R[5],R[8]); </code></pre> <p>In general, you can use SensorManager.remapCoordinateSystem() which for the phone example above would be Display.getRotation()=Surface.ROTATION_90 and give the answer you provided. But if you rotate differently (ROTATION_270 for example) it will be different. </p> <p>Also, an aside: the best method to get orientation in Android is to listen for Sensor.TYPE_ROTATION_VECTOR events. These are filled with the best possible orientation on most (i.e. Gingerbread or newer) platforms. It is actually the vector part of the quaternion. You can get the full quaternion using this (and last two lines are a way to get the RotationMatrix):</p> <pre><code>float vec[] = event.values.clone(); float quat[] = new float[4]; SensorManager.getQuaternionFromVector(quat, vec); float [] RotMat = new float[9]; SensorManager.getRotationMatrixFromVector(RotMat, quat); </code></pre> <p>More information at: <a href="http://www.sensorplatforms.com/which-sensors-in-android-gets-direct-input-what-are-virtual-sensors" rel="nofollow">http://www.sensorplatforms.com/which-sensors-in-android-gets-direct-input-what-are-virtual-sensors</a> </p>
    singulars
    1. This table or related slice is empty.
    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. 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.
    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