G-Sensor的一些概念,基于android

期天在家没有事情,一边翻译sdk中onSensorChanged 的解释,一遍摸索G1下onSensorChanged 第二个参数values的含义:
总结如下,发完赶紧吃饭!
  1. public abstract void onAccuracyChanged (int sensor, int accuracy)
复制代码
Called when the accuracy of a sensor has changed. See SensorManager for details.
Parameters:
sensor  The ID of the sensor being monitored
accuracy  The new accuracy of this sensor.  


当sensor的"精确度"发生改变的时候,该方法会被回调,详细信息请参看 SensorManager 类
参数:
sensor  被监视的sensor的ID
accuracy 关于此sensor的新精确度描述
  1. public abstract void onSensorChanged (int sensor, float[] values)
复制代码
Called when sensor values have changed. The length and contents of the values array vary depending on
which sensor is being monitored. See SensorManager for details on possible sensor types.

当sensor的值发生改变的时候被回调,values数组的元素个数和其中的内容取决于哪个sensor正在被监视,sensor的可
用类型请参看SensorManager类



Definition of the coordinate system used below.

The X axis refers to the screen's horizontal axis (the small edge in portrait mode, the long edge in
landscape mode) and points to the right.
The Y axis refers to the screen's vertical axis and points towards the top of the screen (the origin is
in the lower-left corner).
The Z axis points toward the sky when the device is lying on its back on a table.
X轴:和屏幕平行并且指向右边的轴(在portrait中使用"小边角",在landscape模式中使用"长边角")
Y轴:和屏幕垂直并且指向屏幕上方的轴(坐标原点在左下角)
Z轴:当设备(手机)背面着地放在桌子上的时候,指向天空的方向就是Z轴


IMPORTANT NOTE: The axis are swapped when the device's screen orientation changes. To access the
unswapped values, use indices 3, 4 and 5 in values[].

一定要大家注意的:坐标系是跟随手机屏幕的方向改变而改变的,values数组中下标为3、4、5的3个元素,使用的是恒
定的坐标系,(和尚注:你可以通过这三个元素得到一个不变的坐标,游戏开发中可能会用到)


(和尚注:此方法的第一个参数sensor可能是
SensorManager.SENSOR_ORIENTATION
SensorManager.SENSOR_ORIENTATION
中的一个)
解释如下:
SENSOR_ORIENTATION, SENSOR_ORIENTATION_RAW:
All values are angles in degrees.
values[0]: Azimuth, rotation around the Z axis (0<=azimuth<360). 0 = North, 90 = East, 180 = South, 270 =
West
values[1]: Pitch, rotation around X axis (-180<=pitch<=180), with positive values when the z-axis moves
toward the y-axis.
values[2]: Roll, rotation around Y axis (-90<=roll<=90), with positive values when the z-axis moves
toward the x-axis.


所有的值都是以角度为单位的
values[0]:经度,以Z轴为中心旋转(0-360之间),北方=0,东方=90,南方=180,西方=270
(和尚注:这个方向指的是google标志所对的方向,为了测试这个值,手都酸了(*^__^*) )
values[1]: 着地点(终于选了一个合适的词),以X为轴转动(-180到180),Z轴向Y轴方向运动的相对偏移量
(和尚注:当手机垂直放在面前的时候为-90,当你面对着手机屏幕看天花板的时候为180/-180,当手机屏幕朝上放在水平
的桌子上的时候为0,当手机的USB口朝向天花板垂直放置的时候为90)
values[2]: 转动,以Y为中心转动(-90到90),Z轴向X轴方向运动的相对偏移量
(和尚注:这个运动其实就是我们所说的"垂直屏幕和水平屏幕的切换")




Note that this definition of yaw, pitch and roll is different from the traditional definition used in
aviation where the X axis is along the long side of the plane (tail to nose).
需要注意的是在传统意义上的航空定位中,X轴指的是飞机的机身,而这里的yaw、pitch、roll和它是不一样的,这里的
X轴指的是飞机的水平翼
(和尚注:SDK中的这个解释对于西方人可能有帮助,对于我们可能会更加迷茫,我相信我上边已经说的够清楚了。)


SENSOR_ACCELEROMETER:
All values are in SI units (m/s^2) and measure contact forces.
这个模式下,所有的值都是用国际标准单位,并且能反映出相关力度
values[0]: force applied by the device on the x-axis
values[1]: force applied by the device on the y-axis
values[2]: force applied by the device on the z-axis
values[0]:在X轴方向的力度
values[1]:在Y轴方向的力度
values[2]:在Z轴方向的力度


Examples:
When the device is pushed on its left side toward the right, the x acceleration value is negative (the
device applies a reaction force to the push toward the left)
When the device lies flat on a table, the acceleration value is -STANDARD_GRAVITY, which correspond to
the force the device applies on the table in reaction to gravity.
which correspond to the force the device applies on the table in reaction to gravity.

例如:
当手机按照螺丝钉拧紧的方向"转动"时,X速度就是负的(反之X就是正的)(和尚注:不是按照原文翻译的,意思一样)
当手机放在水平的桌面上的时候,"加速度"值为-STANDARD_GRAVITY(和尚注:SDK中STANDARD_GRAVITY为:Standard
gravity (g) on Earth,次数为负的STANDARD_GRAVITY)

(和尚注:通过反复测试,借助DDMS的截图,得出如下结论,一句话:
SENSOR_ACCELEROMETER模式下,手机的重力被3个轴所分担,values[0]、values[1]、values[2]分别记录3个坐标轴上承
受的重力大小
更易懂的解释:
正常模式下:
  
如果手机的重力都由htc标志的长侧边承担,那么values[0]为-9.8
如果手机的重力都由htc标志对面的长侧边承担,那么values[0]为9.8
如果手机的重力都由USB口的一面承担,那么values[1]为-9.8
如果手机的重力都由USB口对面的窄面承担,那么values[1]为9.8
如果手机的重力都由的背部(Google标志的一面)承担values[2]为-9.8
如果手机的重力都由的手机屏幕承担values[2]为9.8
9.8为g的值
)


Note: the magnetic field's Z axis is inverted.

注意,磁场的Z轴是倒置的(和尚注:不知何意)



猜你喜欢

转载自blog.csdn.net/memory01/article/details/6750790