Share via


SensorManager.GetOrientation(Single[], Single[]) Method

Definition

Computes the device's orientation based on the rotation matrix.

[Android.Runtime.Register("getOrientation", "([F[F)[F", "")]
public static float[]? GetOrientation (float[]? R, float[]? values);
[<Android.Runtime.Register("getOrientation", "([F[F)[F", "")>]
static member GetOrientation : single[] * single[] -> single[]

Parameters

R
Single[]

rotation matrix see #getRotationMatrix.

values
Single[]

an array of 3 floats to hold the result.

Returns

Single[]

The array values passed as argument.

Attributes

Remarks

Computes the device's orientation based on the rotation matrix.

When it returns, the array values are as follows: <ul> <li>values[0]: Azimuth, angle of rotation about the -z axis. This value represents the angle between the device's y axis and the magnetic north pole. When facing north, this angle is 0, when facing south, this angle is &pi;. Likewise, when facing east, this angle is &pi;/2, and when facing west, this angle is -&pi;/2. The range of values is -&pi; to &pi;.</li> <li>values[1]: Pitch, angle of rotation about the x axis. This value represents the angle between a plane parallel to the device's screen and a plane parallel to the ground. Assuming that the bottom edge of the device faces the user and that the screen is face-up, tilting the top edge of the device toward the ground creates a positive pitch angle. The range of values is -&pi;/2 to &pi;/2.</li> <li>values[2]: Roll, angle of rotation about the y axis. This value represents the angle between a plane perpendicular to the device's screen and a plane perpendicular to the ground. Assuming that the bottom edge of the device faces the user and that the screen is face-up, tilting the left edge of the device toward the ground creates a positive roll angle. The range of values is -&pi; to &pi;.</li> </ul>

Applying these three rotations in the azimuth, pitch, roll order transforms an identity matrix to the rotation matrix passed into this method. Also, note that all three orientation angles are expressed in <b>radians</b>.

Java documentation for android.hardware.SensorManager.getOrientation(float[], float[]).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

See also

  • <xref:Android.Hardware.SensorManager.GetRotationMatrix(System.Single%5b%5d%2c+System.Single%5b%5d%2c+System.Single%5b%5d%2c+System.Single%5b%5d)>
  • GeomagneticField