Motion Sensors

Motion Sensors

运动传感器

In this document

在本文档中,你会了解到

  1. Using the Accelerometer
  2. 如何使用加速度传感器
  3. Using the Gravity Sensor
  4. 如何使用重力传感器
  5. Using the Gyroscope
  6. 如何使用陀螺仪
  7. Using the Linear Accelerometer
  8. 如何使用线性加速度传感器
  9. Using the Rotation Vector Sensor
  10. 如何使用旋转矢量传感器

Key classes and interfaces

关键类以及接口

  1. Sensor
  2. SensorEvent
  3. SensorManager
  4. SensorEventListener

Related samples

相关样例

  1. Accelerometer Play
  2. API Demos (OS - RotationVectorDemo)
  3. API Demos (OS - Sensors)

See also

  1. Sensors
  2. Sensors Overview
  3. Position Sensors
  4. Environment Sensors

The Android platform providesseveral sensors that let you monitor the motion of a device. Two of thesesensors are always hardware-based (the accelerometer and gyroscope), and threeof these sensors can be either hardware-based or software-based (the gravity,linear acceleration, and rotation vector sensors). For example, on some devicesthe software-based sensors derive their data from the accelerometer andmagnetometer, but on other devices they may also use the gyroscope to derivetheir data. Most Android-powered devices have an accelerometer, and many nowinclude a gyroscope. The availability of the software-based sensors is morevariable because they often rely on one or more hardware sensors to derivetheir data.

Android平台提供了多种传感器让你可以监测设备的运动状态。其中有两种传感器是基于硬件平台的(加速度传感器和陀螺仪),另外三种传感器同时基于软硬件平台(重力传感器,线性加速度传感器以及旋转矢量传感器)。举例来说,在某些设备上,基于软件平台的传感器的数据来源也许是加速度传感器和磁场强度感应计,但是在另外一些设备中,他们的数据来源也可以是陀螺仪。大多数Android平台设备都内置加速传感器,而且如今也多带有一个陀螺仪。基于软件的传感器的使用方式可以调整,这是因为他们通常会从两个及两个以上的硬件传感器中获取数据来源。

Motion sensors are useful formonitoring device movement, such as tilt, shake, rotation, or swing. Themovement is usually a reflection of direct user input (for example, a usersteering a car in a game or a user controlling a ball in a game), but it canalso be a reflection of the physical environment in which the device is sitting(for example, moving with you while you drive your car). In the first case, youare monitoring motion relative to the device's frame of reference or yourapplication's frame of reference; in the second case you are monitoring motionrelative to the world's frame of reference. Motion sensors by themselves arenot typically used to monitor device position, but they can be used with othersensors, such as the geomagnetic field sensor, to determine a device's positionrelative to the world's frame of reference (seePosition Sensors for more information).

运动传感器可以用来监测设备的运动状态,比如倾斜、晃动、旋转或是摇动。这些运动状态通常直接反映了用户们的输入方式(比如,一名用户在游戏中操作一辆汽车,或是在游戏中控制一颗皮球),但是,它也可以反映某种设备所处的物理环境(比如说当你驾车时,设备显示为正在运动的状态)。通过前者,你可以监测到它相对于所参考的设备或者应用框架的相对位移,而通过后者,你可以监测到它相对与整个地表的相对位移。运动传感器原本并不是为了定位设备的位置而设计的,但是通过与其他传感器的协同工作,比如说磁场强度感应计,来定位设备在地表的位置(参考位置传感器一章来获取更多信息)也不是做不到。

All of the motion sensors returnmulti-dimensional arrays of sensor values for eachSensorEvent. For example, duringa single sensor event the accelerometer returns acceleration force data for thethree coordinate axes, and the gyroscope returns rate of rotation data for thethree coordinate axes. These data values are returned in a float array (values) along with other SensorEvent parameters. Table 1summarizes the motion sensors that are available on the Android platform.

所有的运动传感器都会为每个传感器事件SensorEvent返回以多维数组形式表示的传感器数据。例如,在某次独立的传感器事件中,加速度传感器会返回含有三个坐标系信息的加速度力场信息,而陀螺仪则会返回含有三个坐标系信息的旋转力场信息。这些参数会跟其它的传感器事件SensorEvent参数一道,以浮点数组的方式返回。表1总结了在android平台上若干可用的运动传感器数据。

Table 1. Motion sensors that are supportedon the Android platform.

表1. Android平台上支持的运动传感器列表

Sensor

传感器

Sensor event data

Description

描述

Units of measure

单位

 

 

 

 

TYPE_ACCELEROMETER

SensorEvent.values[0]

Acceleration force along the x axis (including gravity).

沿着x轴方向的加速度力(包括重力)

m/s2

SensorEvent.values[1]

Acceleration force along the y axis (including gravity).

沿着y轴方向的加速度力(包括重力)

SensorEvent.values[2]

Acceleration force along the z axis (including gravity).

沿着z轴方向的加速度力(包括重力)

TYPE_GRAVITY

SensorEvent.values[0]

Force of gravity along the x axis.

沿x轴方向的重力。

m/s2

SensorEvent.values[1]

Force of gravity along the y axis.

沿y轴方向的重力

SensorEvent.values[2]

Force of gravity along the z axis.

沿z轴方向的重力

TYPE_GYROSCOPE

SensorEvent.values[0]

Rate of rotation around the x axis

沿x轴方向的角速度.

rad/s

SensorEvent.values[1]

Rate of rotation around the y axis.

沿y轴方向的角速度

SensorEvent.values[2]

Rate of rotation around the z axis.

沿z轴方向的角速度

TYPE_LINEAR_ACCELERATION

SensorEvent.values[0]

Acceleration force along the x axis (excluding gravity).

沿x轴方向的加速度力(不包括重力)

m/s2

SensorEvent.values[1]

Acceleration force along the y axis (excluding gravity).

沿y轴方向的加速度力(不包括重力)

SensorEvent.values[2]

Acceleration force along the z axis (excluding gravity).

沿z轴方向的加速度力(不包括重力)

TYPE_ROTATION_VECTOR

SensorEvent.values[0]

Rotation vector component along the x axis (x * sin(θ/2)).

沿x轴方向的旋转矢量正弦分量(x * sin(θ/2))

Unitless

SensorEvent.values[1]

Rotation vector component along the y axis (y * sin(θ/2)).

沿y轴方向的旋转矢量正弦分量(y * sin(θ/2))

SensorEvent.values[2]

Rotation vector component along the z axis (z * sin(θ/2)).

沿z轴方向的旋转矢量正弦分量(z * sin(θ/2))

SensorEvent.values[3]

Scalar component of the rotation vector ((cos(θ/2)).

旋转矢量余弦分量((cos(θ/2)).1

1 The scalarcomponent is an optional value.

标量是一个可变值。

The rotation vector sensor and thegravity sensor are the most frequently used sensors for motion detection andmonitoring. The rotational vector sensor is particularly versatile and can beused for a wide range of motion-related tasks, such as detecting gestures,monitoring angular change, and monitoring relative orientation changes. Forexample, the rotational vector sensor is ideal if you are developing a game, anaugmented reality application, a 2-dimensional or 3-dimensional compass, or acamera stabilization app. In most cases, using these sensors is a better choicethan using the accelerometer and geomagnetic field sensor or the orientationsensor.

旋转矢量传感器和重力传感器是在运动检测和监测过程中最常用到的两种传感器。其中旋转矢量传感器的使用方法非常灵活,可广泛应用于与运动相关的检测当中,例如手势的检测,角度变化的检测,以及相对方位的检测等。打个比方,如果你正在开发一款游戏,包括增强现实的应用,一个2维或者3维德罗盘应用,或者相机防抖的应用等,此时旋转矢量传感器就是最好的选择了。大多数情况下,运用旋转矢量传感器和重力传感器要比使用加速度传感器、磁场感应传感器以及方位传感器更加合理。

Android Open SourceProject Sensors

Android开源项目传感器

The Android Open Source Project(AOSP) provides three software-based motion sensors: a gravity sensor, a linearacceleration sensor, and a rotation vector sensor. These sensors were updatedin Android 4.0 and now use a device's gyroscope (in addition to other sensors)to improve stability and performance. If you want to try these sensors, you canidentify them by using thegetVendor() method and thegetVersion() method (the vendoris Google Inc.; the version number is 3). Identifying these sensors by vendor andversion number is necessary because the Android system considers these threesensors to be secondary sensors. For example, if a device manufacturer providestheir own gravity sensor, then the AOSP gravity sensor shows up as a secondarygravity sensor. All three of these sensors rely on a gyroscope: if a devicedoes not have a gyroscope, these sensors do not show up and are not availablefor use.

Android开源项目(AOSP)提供了三种基于软件平台的运动传感器:重力感应传感器,线性加速度传感器以及旋转矢量传感器。这些传感器在android 4.0版本中又进行了升级——使用陀螺仪设备(其它传感器未使用)以提高其稳定性和实用性。如果你想使用这些传感器,你可以使用getVendor()方法以及getVersion()方法来识别它们(参数供应商是谷歌公司,版本号为3)。通过供应商名称以及版本号来进行识别是很有必要的,这是因为这三种传感器被Android系统识别为次要传感器。例如说,如果一个设备制造商已经提供了他们所属的重力传感器,那么AOPS的重力传感器则被显示为次要的传感器设备。注意上述提到的传感器都有赖于陀螺仪:如果设备内没有陀螺仪传感器,这些传感器都不会被枚举,也不能正常使用。

Using the Accelerometer

如何使用加速度传感器


An acceleration sensor measuresthe acceleration applied to the device, including the force of gravity. Thefollowing code shows you how to get an instance of the default accelerationsensor:

加速度传感器用来测量设备包括重力加速度在内的加速度。下面的代码说明了如何获取一个默认加速度传感器的对象。

private SensorManagermSensorManager;

private Sensor mSensor;

  ...

mSensorManager =(SensorManager) getSystemService(Context.SENSOR_SERVICE);

mSensor =mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);

Conceptually, an accelerationsensor determines the acceleration that is applied to a device (Ad)by measuring the forces that are applied to the sensor itself (Fs)using the following relationship:

从理论上来说,加速度传感器的工作原理是通过测量施加在传感器上的应力(F)来计算设备所产生的的加速度(A),参见下面的表达式:

Ad = - ∑Fs / mass

However, the force of gravity isalways influencing the measured acceleration according to the followingrelationship:

然而,重力加速度是一个常量,影响加速度的计算。因此,表达式修正为:

Ad = -g - ∑F / mass

For this reason, when the deviceis sitting on a table (and not accelerating), the accelerometer reads amagnitude of g = 9.81 m/s2. Similarly, when the device is in freefall and therefore rapidly accelerating toward the ground at 9.81 m/s2,its accelerometer reads a magnitude of g = 0 m/s2. Therefore, tomeasure the real acceleration of the device, the contribution of the force ofgravity must be removed from the accelerometer data. This can be achieved byapplying a high-pass filter. Conversely, a low-pass filter can be used toisolate the force of gravity. The following example shows how you can do this:

由于这个原因,当设备静止在桌面上时(没有被加速移动),加速度传感器的读数为g = 9.81 m/s2。而如果设备是自由下落,那么它的加速度为9.81m/s2,加速度传感器的读数为g = 0 m/s2。因此,为了计算设备实际的加速度,通常会将重力加速度移除。这一过程可以通过施加一个高通滤波器来完成,反而言之,施加一个低通滤波器也可以将其他力从重力中隔离出去。下面的样例演示了如何做到这一点:

public voidonSensorChanged(SensorEvent event){

  // In this example, alpha is calculated as t/ (t + dT),

  // where t is the low-pass filter'stime-constant and

  // dT is the event delivery rate.

 

  final float alpha = 0.8;

 

  // Isolate the force of gravity with thelow-pass filter.

  gravity[0] = alpha * gravity[0] + (1 - alpha)* event.values[0];

  gravity[1] = alpha * gravity[1] + (1 - alpha)* event.values[1];

  gravity[2] = alpha * gravity[2] + (1 - alpha)* event.values[2];

 

  // Remove the gravity contribution with thehigh-pass filter.

  linear_acceleration[0] = event.values[0] -gravity[0];

  linear_acceleration[1] = event.values[1] -gravity[1];

  linear_acceleration[2] = event.values[2] -gravity[2];

}

Note: You can use many differenttechniques to filter sensor data. The code sample above uses a simple filterconstant (alpha) to create a low-pass filter. This filter constant is derivedfrom a time constant (t), which is a rough representation of the latency that thefilter adds to the sensor events, and the sensor's event delivery rate (dt).The code sample uses an alpha value of 0.8 for demonstration purposes. If youuse this filtering method you may need to choose a different alpha value.

注意:你可以用多个不同的方式来过滤传感器数据。上述的代码样例用到的是一个简单的滤波器参数(alpha)来创建低通滤波器。滤波器常数是由时间常数(t)和传感器传递率(dt)共同决定,其中时间常数通常指的是添加到传感器事件上的滤波器的一个粗略的延时率。为了更清楚的说明,上面的代码样例中使用的alpha参数值为0.8。如果你也用到了这种滤波器方法,你仍需要选择一个不同的alpha值。

Accelerometers use the standardsensorcoordinate system. In practice, thismeans that the following conditions apply when a device is laying flat on atable in its natural orientation:

加速度传感器使用的是标准的传感器坐标系。这就是说,在实际使用中当设备以自然方式放置在桌面上时,它将适用于以下几种情况:

  • If you push the device on the left side (so it moves to the right), the x acceleration value is positive.
  • 如果你从左边推设备(当然它会往右移动),那么x轴上的加速度值为正。
  • If you push the device on the bottom (so it moves away from you), the y acceleration value is positive.
  • 如果你从设备的下方位置推动它(当然它就往你的反方向移动),此时y轴上的加速度值为正。
  • If you push the device toward the sky with an acceleration of A m/s2, the z acceleration value is equal to A + 9.81, which corresponds to the acceleration of the device (+A m/s2) minus the force of gravity (-9.81 m/s2).
  • 如果你将设备以A m/s2的速度向上空移动,那么z轴方向的加速度值为A + 9.81,这是由设备本身的加速度(+A m/s2)减去重力加速度(-9.81 m/s2)得出的。
  • The stationary device will have an acceleration value of +9.81, which corresponds to the acceleration of the device (0 m/s2 minus the force of gravity, which is -9.81 m/s2).
  • 静止的设备始终具有+9.81的加速度值,这是由施加在设备上的重力决定的(此时的设备运动速度为0 m/s2 ,减去-9.81 m/s2的重力加速度值而得出)。

In general, the accelerometer is agood sensor to use if you are monitoring device motion. Almost everyAndroid-powered handset and tablet has an accelerometer, and it uses about 10times less power than the other motion sensors. One drawback is that you mighthave to implement low-pass and high-pass filters to eliminate gravitationalforces and reduce noise.

大多数情况下,当你检测设备运动状况时加速度传感器都是个不赖的设备。目前几乎所有的Android设备——手机跟平板电脑都有一个加速度传感器。与其它传感器相比,加速度传感器的能耗只有1/10。唯一的缺点是,使用加速度传感器你需要设计高通和低通滤波器来消除重力和噪声所带来的影响。

The Android SDK provides a sampleapplication that shows how to use the acceleration sensor (Accelerometer Play).

Android SDK提供了一个样例用来说明如何使用加速度传感器(Accelerometer Play).。

Using the Gravity Sensor

如何使用重力传感器


The gravity sensor provides athree dimensional vector indicating the direction and magnitude of gravity. Thefollowing code shows you how to get an instance of the default gravity sensor:

重力传感器提供了用于指示和衡量重力的三个维度的矢量值。下面的代码表明了如何为重力传感器创建一个默认的实例:

private SensorManager mSensorManager;

private Sensor mSensor;

...

mSensorManager =(SensorManager) getSystemService(Context.SENSOR_SERVICE);

mSensor =mSensorManager.getDefaultSensor(Sensor.TYPE_GRAVITY);

The units are the same as thoseused by the acceleration sensor (m/s2), and the coordinate system isthe same as the one used by the acceleration sensor.

以上参与计算的数值单位与加速度传感器一致,都是(m/s2),坐标系也与加速度传感器所用的一致。

Note: When a device is at rest, theoutput of the gravity sensor should be identical to that of the accelerometer.

注意:当设备处于静止状态时,重力传感器的输出值应与加速度传感器的输出值一致。

Using the Gyroscope

如何使用陀螺仪


The gyroscope measures the rate orrotation in rad/s around a device's x, y, and z axis. The following code showsyou how to get an instance of the default gyroscope:

陀螺仪用来测量设备围绕x\y\z三轴方向上的旋转角速度,单位是rad/s。下面的代码表明如何获取一个陀螺仪设备的默认实例。

private SensorManagermSensorManager;

private Sensor mSensor;

...

mSensorManager =(SensorManager) getSystemService(Context.SENSOR_SERVICE);

mSensor =mSensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE);

The sensor's coordinate system is the same as theone used for the acceleration sensor. Rotation is positive in thecounter-clockwise direction; that is, an observer looking from some positivelocation on the x, y or z axis at a device positioned on the origin wouldreport positive rotation if the device appeared to be rotating counterclockwise. This is the standard mathematical definition of positive rotationand is not the same as the definition for roll that is used by the orientationsensor.

陀螺仪传感器的坐标系与加速度传感器用到的某个坐标系一致。逆时针方向被定义为旋转的正向;这也就是说,如果设备以逆时针方向旋转,那么当处于设备的自然方向为基准点进行观察的时候,陀螺仪的显示就应该为正值。这是标准的数学定义上正向旋转,与以轴承旋转的方位传感器的工作原理是不一样的。

Usually, the output of the gyroscope is integrated over time to calculatea rotation describing the change of angles over the time step. For example:

一般来说,陀螺仪传感器的输出是旋转角度对时间的积分。参见如下代码:

// Create a constant toconvert nanoseconds to seconds.

private static final floatNS2S = 1.0f / 1000000000.0f;

private final float[]deltaRotationVector = new float[4]();

private float timestamp;

 

public void onSensorChanged(SensorEventevent) {

  // This timestep's delta rotation to bemultiplied by the current rotation

  // after computing it from the gyro sampledata.

  if (timestamp != 0) {

    final float dT = (event.timestamp -timestamp) * NS2S;

    // Axis of the rotation sample, notnormalized yet.

    float axisX = event.values[0];

    float axisY = event.values[1];

    float axisZ = event.values[2];

 

    // Calculate the angular speed of thesample

    float omegaMagnitude = sqrt(axisX*axisX +axisY*axisY + axisZ*axisZ);

 

    // Normalize the rotation vector if it'sbig enough to get the axis

    // (that is, EPSILON should represent yourmaximum allowable margin of error)

    if (omegaMagnitude > EPSILON) {

      axisX /= omegaMagnitude;

      axisY /= omegaMagnitude;

      axisZ /= omegaMagnitude;

    }

 

    // Integrate around this axis with theangular speed by the timestep

    // in order to get a delta rotation fromthis sample over the timestep

    // We will convert this axis-anglerepresentation of the delta rotation

    // into a quaternion before turning it intothe rotation matrix.

    float thetaOverTwo = omegaMagnitude * dT /2.0f;

    float sinThetaOverTwo = sin(thetaOverTwo);

    float cosThetaOverTwo = cos(thetaOverTwo);

    deltaRotationVector[0] = sinThetaOverTwo *axisX;

    deltaRotationVector[1] = sinThetaOverTwo *axisY;

    deltaRotationVector[2] = sinThetaOverTwo *axisZ;

    deltaRotationVector[3] = cosThetaOverTwo;

  }

  timestamp = event.timestamp;

  float[] deltaRotationMatrix = new float[9];

 SensorManager.getRotationMatrixFromVector(deltaRotationMatrix,deltaRotationVector);

    // User code should concatenate the deltarotation we computed with the current rotation

    // in order to get the updated rotation.

    // rotationCurrent = rotationCurrent *deltaRotationMatrix;

   }

}

Standard gyroscopes provide rawrotational data without any filtering or correction for noise and drift (bias).In practice, gyroscope noise and drift will introduce errors that need to becompensated for. You usually determine the drift (bias) and noise by monitoringother sensors, such as the gravity sensor or accelerometer.

标准的陀螺仪传感器仅仅提供大致的旋转数据,但并不包括对噪声以及数据漂移所做的滤波和矫正处理。实际应用当中,陀螺仪传感器噪声和漂移会产生致命错误,必须被补偿矫正。使用者通常通过其它的传感器,比如说重力传感器和加速度传感器来检测这些漂移和噪声。

Using the Linear Accelerometer

如何使用线性加速度传感器


The linear acceleration sensorprovides you with a three-dimensional vector representing acceleration alongeach device axis, excluding gravity. The following code shows you how to get aninstance of the default linear acceleration sensor:

线性加速度传感器提供了一个表示设备三个维度方向力大小的矢量值,但是不包括重力。下面的代码说明了如何获取一个线性加速度传感器的对象。

private SensorManagermSensorManager;

private Sensor mSensor;

...

mSensorManager =(SensorManager) getSystemService(Context.SENSOR_SERVICE);

mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_LINEAR_ACCELERATION);

Conceptually, this sensor providesyou with acceleration data according to the following relationship:

理论上来说,这种传感器通过下面的表达式为使用者提供了加速度数据:

linear acceleration= acceleration - acceleration due to gravity

线性加速度=加速度-由重力引起的加速度

You typically use this sensor whenyou want to obtain acceleration data without the influence of gravity. Forexample, you could use this sensor to see how fast your car is going. Thelinear acceleration sensor always has an offset, which you need to remove. Thesimplest way to do this is to build a calibration step into your application.During calibration you can ask the user to set the device on a table, and thenread the offsets for all three axes. You can then subtract that offset from theacceleration sensor's direct readings to get the actual linear acceleration.

当你想获取不受重力影响的加速度数据的时候,你通常会选用这种传感器。比如说当你用传感器来测量你的汽车的速度的时候。线性加速度传感器通常有一个偏移量,你需要把它去掉。简单的说,就是在你的应用中需要做一个校准数据的步骤。校准就是需要你告知用户们将设备放置在桌面上,然后获取三个轴向上的偏移量。接下来你可以去除掉这些偏移量,最后就可以得到真正的线性加速度了。

The sensor coordinate system is the same as theone used by the acceleration sensor, as are the units of measure (m/s2).

这个传感器的坐标系与加速度传感器的坐标系一致,用的单位也是(m/s2)。

Using the Rotation Vector Sensor

如何使用旋转矢量传感器


The rotation vector represents theorientation of the device as a combination of an angle and an axis, in whichthe device has rotated through an angle θ around an axis (x, y, or z). The followingcode shows you how to get an instance of the default rotation vector sensor:

旋转矢量传感器表明了设备对某个轴向转角值,即设备绕着x\y\z轴旋转的角度大小。下面的代码表面如何获取一个旋转矢量传感器的对象:

private SensorManagermSensorManager;

private Sensor mSensor;

...

mSensorManager =(SensorManager) getSystemService(Context.SENSOR_SERVICE);

mSensor =mSensorManager.getDefaultSensor(Sensor.TYPE_ROTATION_VECTOR);

The three elements of the rotationvector are expressed as follows:

旋转矢量的三个输出数据可以由以下表达式表明: 

x*sin(θ/2)

y*sin(θ/2)

z*sin(θ/2)

Where the magnitude of the rotation vector is equal to sin(θ/2), and thedirection of the rotation vector is equal to the direction of the axis ofrotation.

此时旋转矢量大小为sin(θ/2),旋转矢量的方向与转轴的方向一致。


Figure 1. Coordinate system used by therotation vector sensor.

图1旋转矢量传感器所用的坐标系

The three elements of the rotationvector are equal to the last three components of a unit quaternion (cos(θ/2),x*sin(θ/2), y*sin(θ/2), z*sin(θ/2)). Elements of the rotation vector areunitless. The x, y, and z axes are defined in the same way as the accelerationsensor. The reference coordinate system is defined as a direct orthonormalbasis (see figure 1). This coordinate system has the following characteristics:

旋转矢量的三个输出结果实际上就是四元数的后三个表达式(cos(θ/2), x*sin(θ/2), y*sin(θ/2), z*sin(θ/2))。旋转矢量的输出值是无单位的。其中x/y/z三个轴向与加速度传感器的定义一致。所参考的坐标系被定义为一个标准正交基(如图1)。该坐标系具有以下特征:

  • X is defined as the vector product Y x Z. It is tangential to the ground at the device's current location and points approximately East.
  • X值被定义为Y与Z值的向量积。即设备当前所处位置的地面与东方向的正切值。
  • Y is tangential to the ground at the device's current location and points toward the geomagnetic North Pole.
  • Y值是设备当前所处位置与地磁北极的正切值。
  • Z points toward the sky and is perpendicular to the ground plane.
  • Z值朝向天空方向,与地面垂直相交。

The Android SDK provides a sample application that shows how to use therotation vector sensor. The sample application is located in the API Demos code( OS - RotationVectorDemo).

Android的SDK提供了如何使用旋转矢量传感器的样例。代码在此( OS - RotationVectorDemo)。

 


  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值