[Android] Sensor-accelerometer -2[turn]

Source: Internet
Author: User

The coordinate system of the Android sensor is not the same as its 2D design, with coordinate systems such as:

Once the sensor listener is registered with the Sensormanager object, an object of sensorevent can be obtained within the Onsensorchanged method.

The Sensorevent object has an important member variable public final float[] values, which are defined as follows:

Public final float[] values

The length and contents of the values array depends on which sensor type is being monitored

If the registration listener is an accelerometer, the values in the

Sensor.TYPE_ACCELEROMETER:

All values is in SI units (m/s^2)//SI is the meaning of the international unit, which is the same unit as the acceleration of high school

 values[0]: Acceleration minus Gx on the x-axis values[1]: Acceleration minus Gy on the y-axis values[2]: Acceleration minus Gz on the z-axis


You can see that the value of values[0~2] is a certain direction acceleration (acceleration) minus the gravity value in that direction (Gx, Gy, Gz), so the phone is stationary when its range is [ -10,10]

For example, the mobile phone screen is placed flat, then values[0]=0,values[1]=0,values[2]=10

Since the mobile phone is stationary and there is no acceleration in all directions, the cell phone flat puts the gravitational acceleration downward, i.e. gz=-10 (because the gravity direction is opposite to the z axis), so subtract 10

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.