Condividi tramite


SensorManager.RemapCoordinateSystem(Single[], Axis, Axis, Single[]) Method

Definition

Rotates the supplied rotation matrix so it is expressed in a different coordinate system.

[Android.Runtime.Register("remapCoordinateSystem", "([FII[F)Z", "")]
public static bool RemapCoordinateSystem (float[]? inR, Android.Hardware.Axis X, Android.Hardware.Axis Y, float[]? outR);
[<Android.Runtime.Register("remapCoordinateSystem", "([FII[F)Z", "")>]
static member RemapCoordinateSystem : single[] * Android.Hardware.Axis * Android.Hardware.Axis * single[] -> bool

Parameters

inR
Single[]

the rotation matrix to be transformed. Usually it is the matrix returned by #getRotationMatrix.

X
Axis

defines the axis of the new cooridinate system that coincide with the X axis of the original coordinate system.

Y
Axis

defines the axis of the new cooridinate system that coincide with the Y axis of the original coordinate system.

outR
Single[]

the transformed rotation matrix. inR and outR should not be the same array.

Returns

true on success. false if the input parameters are incorrect, for instance if X and Y define the same axis. Or if inR and outR don't have the same length.

Attributes

Remarks

Rotates the supplied rotation matrix so it is expressed in a different coordinate system. This is typically used when an application needs to compute the three orientation angles of the device (see #getOrientation) in a different coordinate system.

When the rotation matrix is used for drawing (for instance with OpenGL ES), it usually <b>doesn't need</b> to be transformed by this function, unless the screen is physically rotated, in which case you can use android.view.Display#getRotation() Display.getRotation() to retrieve the current rotation of the screen. Note that because the user is generally free to rotate their screen, you often should consider the rotation in deciding the parameters to use here.

<u>Examples:</u>

<ul> <li>Using the camera (Y axis along the camera's axis) for an augmented reality application where the rotation angles are needed:</li>

<ul> remapCoordinateSystem(inR, AXIS_X, AXIS_Z, outR);</ul>

<li>Using the device as a mechanical compass when rotation is android.view.Surface#ROTATION_90 Surface.ROTATION_90:</li>

<ul> remapCoordinateSystem(inR, AXIS_Y, AXIS_MINUS_X, outR);</ul>

Beware of the above example. This call is needed only to account for a rotation from its natural orientation when calculating the rotation angles (see #getOrientation). If the rotation matrix is also used for rendering, it may not need to be transformed, for instance if your android.app.Activity Activity is running in landscape mode. </ul>

Since the resulting coordinate system is orthonormal, only two axes need to be specified.

Java documentation for android.hardware.SensorManager.remapCoordinateSystem(float[], int, int, 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)>