19066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project/*
29066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Copyright (C) 2008 The Android Open Source Project
39066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
49066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Licensed under the Apache License, Version 2.0 (the "License");
59066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * you may not use this file except in compliance with the License.
69066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * You may obtain a copy of the License at
79066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
89066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *      http://www.apache.org/licenses/LICENSE-2.0
99066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
109066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Unless required by applicable law or agreed to in writing, software
119066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * distributed under the License is distributed on an "AS IS" BASIS,
129066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
139066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * See the License for the specific language governing permissions and
149066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * limitations under the License.
159066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */
169066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
179066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Projectpackage android.hardware;
189066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
199066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project/**
2074cde2cee9e53006a710f4e80700cd560c2d0e4dMathias Agopian * <p>
2174cde2cee9e53006a710f4e80700cd560c2d0e4dMathias Agopian * This class represents a {@link android.hardware.Sensor Sensor} event and
2274cde2cee9e53006a710f4e80700cd560c2d0e4dMathias Agopian * holds informations such as the sensor's type, the time-stamp, accuracy and of
2374cde2cee9e53006a710f4e80700cd560c2d0e4dMathias Agopian * course the sensor's {@link SensorEvent#values data}.
2474cde2cee9e53006a710f4e80700cd560c2d0e4dMathias Agopian * </p>
259066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
2674cde2cee9e53006a710f4e80700cd560c2d0e4dMathias Agopian * <p>
2774cde2cee9e53006a710f4e80700cd560c2d0e4dMathias Agopian * <u>Definition of the coordinate system used by the SensorEvent API.</u>
2874cde2cee9e53006a710f4e80700cd560c2d0e4dMathias Agopian * </p>
2974cde2cee9e53006a710f4e80700cd560c2d0e4dMathias Agopian *
3074cde2cee9e53006a710f4e80700cd560c2d0e4dMathias Agopian * <p>
310f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian * The coordinate-system is defined relative to the screen of the phone in its
3274cde2cee9e53006a710f4e80700cd560c2d0e4dMathias Agopian * default orientation. The axes are not swapped when the device's screen
3374cde2cee9e53006a710f4e80700cd560c2d0e4dMathias Agopian * orientation changes.
3474cde2cee9e53006a710f4e80700cd560c2d0e4dMathias Agopian * </p>
3574cde2cee9e53006a710f4e80700cd560c2d0e4dMathias Agopian *
3674cde2cee9e53006a710f4e80700cd560c2d0e4dMathias Agopian * <p>
370f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian * The X axis is horizontal and points to the right, the Y axis is vertical and
380f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian * points up and the Z axis points towards the outside of the front face of the
390f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian * screen. In this system, coordinates behind the screen have negative Z values.
400f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian * </p>
410f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian *
420f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian * <p>
430f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian * <center><img src="../../../images/axis_device.png"
440f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian * alt="Sensors coordinate-system diagram." border="0" /></center>
4574cde2cee9e53006a710f4e80700cd560c2d0e4dMathias Agopian * </p>
4674cde2cee9e53006a710f4e80700cd560c2d0e4dMathias Agopian *
4774cde2cee9e53006a710f4e80700cd560c2d0e4dMathias Agopian * <p>
489066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <b>Note:</b> This coordinate system is different from the one used in the
4974cde2cee9e53006a710f4e80700cd560c2d0e4dMathias Agopian * Android 2D APIs where the origin is in the top-left corner.
5074cde2cee9e53006a710f4e80700cd560c2d0e4dMathias Agopian * </p>
519066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
520f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian * @see SensorManager
530f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian * @see SensorEvent
540f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian * @see Sensor
559066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
569066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */
579066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
589066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Projectpublic class SensorEvent {
599066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
6074cde2cee9e53006a710f4e80700cd560c2d0e4dMathias Agopian     * <p>
610f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * The length and contents of the {@link #values values} array depends on
620f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * which {@link android.hardware.Sensor sensor} type is being monitored (see
630f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * also {@link SensorEvent} for a definition of the coordinate system used).
6474cde2cee9e53006a710f4e80700cd560c2d0e4dMathias Agopian     * </p>
6574cde2cee9e53006a710f4e80700cd560c2d0e4dMathias Agopian     *
660f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * <h4>{@link android.hardware.Sensor#TYPE_ACCELEROMETER
670f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * Sensor.TYPE_ACCELEROMETER}:</h4> All values are in SI units (m/s^2)
680f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     *
6974cde2cee9e53006a710f4e80700cd560c2d0e4dMathias Agopian     * <ul>
7074cde2cee9e53006a710f4e80700cd560c2d0e4dMathias Agopian     * <p>
710f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * values[0]: Acceleration minus Gx on the x-axis
720f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * </p>
7374cde2cee9e53006a710f4e80700cd560c2d0e4dMathias Agopian     * <p>
740f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * values[1]: Acceleration minus Gy on the y-axis
750f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * </p>
7674cde2cee9e53006a710f4e80700cd560c2d0e4dMathias Agopian     * <p>
770f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * values[2]: Acceleration minus Gz on the z-axis
780f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * </p>
7974cde2cee9e53006a710f4e80700cd560c2d0e4dMathias Agopian     * </ul>
800f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     *
8174cde2cee9e53006a710f4e80700cd560c2d0e4dMathias Agopian     * <p>
820f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * A sensor of this type measures the acceleration applied to the device
830f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * (<b>Ad</b>). Conceptually, it does so by measuring forces applied to the
840f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * sensor itself (<b>Fs</b>) using the relation:
850f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * </p>
860f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     *
87612ff27425cf2976396d992f32b58ab900c7d708Brad Fitzpatrick     * <b><center>Ad = - &#8721;Fs / mass</center></b>
880f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     *
8974cde2cee9e53006a710f4e80700cd560c2d0e4dMathias Agopian     * <p>
900f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * In particular, the force of gravity is always influencing the measured
910f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * acceleration:
920f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * </p>
930f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     *
94612ff27425cf2976396d992f32b58ab900c7d708Brad Fitzpatrick     * <b><center>Ad = -g - &#8721;F / mass</center></b>
950f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     *
9674cde2cee9e53006a710f4e80700cd560c2d0e4dMathias Agopian     * <p>
970f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * For this reason, when the device is sitting on a table (and obviously not
980f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * accelerating), the accelerometer reads a magnitude of <b>g</b> = 9.81
990f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * m/s^2
1000f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * </p>
1010f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     *
10274cde2cee9e53006a710f4e80700cd560c2d0e4dMathias Agopian     * <p>
1030f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * Similarly, when the device is in free-fall and therefore dangerously
1040f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * accelerating towards to ground at 9.81 m/s^2, its accelerometer reads a
1050f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * magnitude of 0 m/s^2.
1060f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * </p>
1070f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     *
10874cde2cee9e53006a710f4e80700cd560c2d0e4dMathias Agopian     * <p>
1090f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * It should be apparent that in order to measure the real acceleration of
1100f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * the device, the contribution of the force of gravity must be eliminated.
1110f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * This can be achieved by applying a <i>high-pass</i> filter. Conversely, a
1120f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * <i>low-pass</i> filter can be used to isolate the force of gravity.
1130f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * </p>
114fa33565714e4192dbab446ee1fbccb87dd414bedMathias Agopian     *
115fa33565714e4192dbab446ee1fbccb87dd414bedMathias Agopian     * <pre class="prettyprint">
116fa33565714e4192dbab446ee1fbccb87dd414bedMathias Agopian     *
117fa33565714e4192dbab446ee1fbccb87dd414bedMathias Agopian     *     public void onSensorChanged(SensorEvent event)
118fa33565714e4192dbab446ee1fbccb87dd414bedMathias Agopian     *     {
119fa33565714e4192dbab446ee1fbccb87dd414bedMathias Agopian     *          // alpha is calculated as t / (t + dT)
120fa33565714e4192dbab446ee1fbccb87dd414bedMathias Agopian     *          // with t, the low-pass filter's time-constant
121fa33565714e4192dbab446ee1fbccb87dd414bedMathias Agopian     *          // and dT, the event delivery rate
122fa33565714e4192dbab446ee1fbccb87dd414bedMathias Agopian     *
123fa33565714e4192dbab446ee1fbccb87dd414bedMathias Agopian     *          final float alpha = 0.8;
124fa33565714e4192dbab446ee1fbccb87dd414bedMathias Agopian     *
125d11ee90b6ed54421f0016ffb7de77e5c812bc17fScott Main     *          gravity[0] = alpha * gravity[0] + (1 - alpha) * event.values[0];
126d11ee90b6ed54421f0016ffb7de77e5c812bc17fScott Main     *          gravity[1] = alpha * gravity[1] + (1 - alpha) * event.values[1];
127d11ee90b6ed54421f0016ffb7de77e5c812bc17fScott Main     *          gravity[2] = alpha * gravity[2] + (1 - alpha) * event.values[2];
128fa33565714e4192dbab446ee1fbccb87dd414bedMathias Agopian     *
129d11ee90b6ed54421f0016ffb7de77e5c812bc17fScott Main     *          linear_acceleration[0] = event.values[0] - gravity[0];
130d11ee90b6ed54421f0016ffb7de77e5c812bc17fScott Main     *          linear_acceleration[1] = event.values[1] - gravity[1];
131d11ee90b6ed54421f0016ffb7de77e5c812bc17fScott Main     *          linear_acceleration[2] = event.values[2] - gravity[2];
132fa33565714e4192dbab446ee1fbccb87dd414bedMathias Agopian     *     }
133fa33565714e4192dbab446ee1fbccb87dd414bedMathias Agopian     * </pre>
134fa33565714e4192dbab446ee1fbccb87dd414bedMathias Agopian     *
13574cde2cee9e53006a710f4e80700cd560c2d0e4dMathias Agopian     * <p>
13674cde2cee9e53006a710f4e80700cd560c2d0e4dMathias Agopian     * <u>Examples</u>:
13774cde2cee9e53006a710f4e80700cd560c2d0e4dMathias Agopian     * <ul>
13874cde2cee9e53006a710f4e80700cd560c2d0e4dMathias Agopian     * <li>When the device lies flat on a table and is pushed on its left side
13974cde2cee9e53006a710f4e80700cd560c2d0e4dMathias Agopian     * toward the right, the x acceleration value is positive.</li>
1400f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     *
14174cde2cee9e53006a710f4e80700cd560c2d0e4dMathias Agopian     * <li>When the device lies flat on a table, the acceleration value is
14274cde2cee9e53006a710f4e80700cd560c2d0e4dMathias Agopian     * +9.81, which correspond to the acceleration of the device (0 m/s^2) minus
14374cde2cee9e53006a710f4e80700cd560c2d0e4dMathias Agopian     * the force of gravity (-9.81 m/s^2).</li>
1440f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     *
14574cde2cee9e53006a710f4e80700cd560c2d0e4dMathias Agopian     * <li>When the device lies flat on a table and is pushed toward the sky
14674cde2cee9e53006a710f4e80700cd560c2d0e4dMathias Agopian     * with an acceleration of A m/s^2, the acceleration value is equal to
14774cde2cee9e53006a710f4e80700cd560c2d0e4dMathias Agopian     * A+9.81 which correspond to the acceleration of the device (+A m/s^2)
14874cde2cee9e53006a710f4e80700cd560c2d0e4dMathias Agopian     * minus the force of gravity (-9.81 m/s^2).</li>
14974cde2cee9e53006a710f4e80700cd560c2d0e4dMathias Agopian     * </ul>
1500f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     *
1510f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     *
1520f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * <h4>{@link android.hardware.Sensor#TYPE_MAGNETIC_FIELD
1530f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * Sensor.TYPE_MAGNETIC_FIELD}:</h4>
15474cde2cee9e53006a710f4e80700cd560c2d0e4dMathias Agopian     * All values are in micro-Tesla (uT) and measure the ambient magnetic field
15574cde2cee9e53006a710f4e80700cd560c2d0e4dMathias Agopian     * in the X, Y and Z axis.
1560f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     *
157ad7f33a29c6ce41f2b662d1de9af7e9cf92f4dc9Mathias Agopian     * <h4>{@link android.hardware.Sensor#TYPE_GYROSCOPE Sensor.TYPE_GYROSCOPE}:
158ad7f33a29c6ce41f2b662d1de9af7e9cf92f4dc9Mathias Agopian     * </h4> All values are in radians/second and measure the rate of rotation
159ad7f33a29c6ce41f2b662d1de9af7e9cf92f4dc9Mathias Agopian     * around the device's local X, Y and Z axis. The coordinate system is the
160ad7f33a29c6ce41f2b662d1de9af7e9cf92f4dc9Mathias Agopian     * same as is used for the acceleration sensor. Rotation is positive in the
161ad7f33a29c6ce41f2b662d1de9af7e9cf92f4dc9Mathias Agopian     * counter-clockwise direction. That is, an observer looking from some
162ad7f33a29c6ce41f2b662d1de9af7e9cf92f4dc9Mathias Agopian     * positive location on the x, y or z axis at a device positioned on the
163ad7f33a29c6ce41f2b662d1de9af7e9cf92f4dc9Mathias Agopian     * origin would report positive rotation if the device appeared to be
164ad7f33a29c6ce41f2b662d1de9af7e9cf92f4dc9Mathias Agopian     * rotating counter clockwise. Note that this is the standard mathematical
165ad7f33a29c6ce41f2b662d1de9af7e9cf92f4dc9Mathias Agopian     * definition of positive rotation and does not agree with the definition of
166ad7f33a29c6ce41f2b662d1de9af7e9cf92f4dc9Mathias Agopian     * roll given earlier.
167fa33565714e4192dbab446ee1fbccb87dd414bedMathias Agopian     * <ul>
168fa33565714e4192dbab446ee1fbccb87dd414bedMathias Agopian     * <p>
169fa33565714e4192dbab446ee1fbccb87dd414bedMathias Agopian     * values[0]: Angular speed around the x-axis
170fa33565714e4192dbab446ee1fbccb87dd414bedMathias Agopian     * </p>
171fa33565714e4192dbab446ee1fbccb87dd414bedMathias Agopian     * <p>
172fa33565714e4192dbab446ee1fbccb87dd414bedMathias Agopian     * values[1]: Angular speed around the y-axis
173fa33565714e4192dbab446ee1fbccb87dd414bedMathias Agopian     * </p>
174fa33565714e4192dbab446ee1fbccb87dd414bedMathias Agopian     * <p>
175fa33565714e4192dbab446ee1fbccb87dd414bedMathias Agopian     * values[2]: Angular speed around the z-axis
176fa33565714e4192dbab446ee1fbccb87dd414bedMathias Agopian     * </p>
177fa33565714e4192dbab446ee1fbccb87dd414bedMathias Agopian     * </ul>
178fa33565714e4192dbab446ee1fbccb87dd414bedMathias Agopian     * <p>
179ad7f33a29c6ce41f2b662d1de9af7e9cf92f4dc9Mathias Agopian     * Typically the output of the gyroscope is integrated over time to
180ad7f33a29c6ce41f2b662d1de9af7e9cf92f4dc9Mathias Agopian     * calculate a rotation describing the change of angles over the timestep,
181ad7f33a29c6ce41f2b662d1de9af7e9cf92f4dc9Mathias Agopian     * for example:
182fa33565714e4192dbab446ee1fbccb87dd414bedMathias Agopian     * </p>
183ad7f33a29c6ce41f2b662d1de9af7e9cf92f4dc9Mathias Agopian     *
184fa33565714e4192dbab446ee1fbccb87dd414bedMathias Agopian     * <pre class="prettyprint">
185fa33565714e4192dbab446ee1fbccb87dd414bedMathias Agopian     *     private static final float NS2S = 1.0f / 1000000000.0f;
186ad7f33a29c6ce41f2b662d1de9af7e9cf92f4dc9Mathias Agopian     *     private final float[] deltaRotationVector = new float[4]();
187fa33565714e4192dbab446ee1fbccb87dd414bedMathias Agopian     *     private float timestamp;
188ad7f33a29c6ce41f2b662d1de9af7e9cf92f4dc9Mathias Agopian     *
189ad7f33a29c6ce41f2b662d1de9af7e9cf92f4dc9Mathias Agopian     *     public void onSensorChanged(SensorEvent event) {
190ad7f33a29c6ce41f2b662d1de9af7e9cf92f4dc9Mathias Agopian     *          // This timestep's delta rotation to be multiplied by the current rotation
191ad7f33a29c6ce41f2b662d1de9af7e9cf92f4dc9Mathias Agopian     *          // after computing it from the gyro sample data.
192fa33565714e4192dbab446ee1fbccb87dd414bedMathias Agopian     *          if (timestamp != 0) {
193fa33565714e4192dbab446ee1fbccb87dd414bedMathias Agopian     *              final float dT = (event.timestamp - timestamp) * NS2S;
194ad7f33a29c6ce41f2b662d1de9af7e9cf92f4dc9Mathias Agopian     *              // Axis of the rotation sample, not normalized yet.
195ad7f33a29c6ce41f2b662d1de9af7e9cf92f4dc9Mathias Agopian     *              float axisX = event.values[0];
196ad7f33a29c6ce41f2b662d1de9af7e9cf92f4dc9Mathias Agopian     *              float axisY = event.values[1];
197ad7f33a29c6ce41f2b662d1de9af7e9cf92f4dc9Mathias Agopian     *              float axisZ = event.values[2];
198ad7f33a29c6ce41f2b662d1de9af7e9cf92f4dc9Mathias Agopian     *
199ad7f33a29c6ce41f2b662d1de9af7e9cf92f4dc9Mathias Agopian     *              // Calculate the angular speed of the sample
200ad7f33a29c6ce41f2b662d1de9af7e9cf92f4dc9Mathias Agopian     *              float omegaMagnitude = sqrt(axisX*axisX + axisY*axisY + axisZ*axisZ);
201ad7f33a29c6ce41f2b662d1de9af7e9cf92f4dc9Mathias Agopian     *
202ad7f33a29c6ce41f2b662d1de9af7e9cf92f4dc9Mathias Agopian     *              // Normalize the rotation vector if it's big enough to get the axis
203ad7f33a29c6ce41f2b662d1de9af7e9cf92f4dc9Mathias Agopian     *              if (omegaMagnitude > EPSILON) {
204ad7f33a29c6ce41f2b662d1de9af7e9cf92f4dc9Mathias Agopian     *                  axisX /= omegaMagnitude;
205ad7f33a29c6ce41f2b662d1de9af7e9cf92f4dc9Mathias Agopian     *                  axisY /= omegaMagnitude;
206ad7f33a29c6ce41f2b662d1de9af7e9cf92f4dc9Mathias Agopian     *                  axisZ /= omegaMagnitude;
207ad7f33a29c6ce41f2b662d1de9af7e9cf92f4dc9Mathias Agopian     *              }
208ad7f33a29c6ce41f2b662d1de9af7e9cf92f4dc9Mathias Agopian     *
209ad7f33a29c6ce41f2b662d1de9af7e9cf92f4dc9Mathias Agopian     *              // Integrate around this axis with the angular speed by the timestep
210ad7f33a29c6ce41f2b662d1de9af7e9cf92f4dc9Mathias Agopian     *              // in order to get a delta rotation from this sample over the timestep
211ad7f33a29c6ce41f2b662d1de9af7e9cf92f4dc9Mathias Agopian     *              // We will convert this axis-angle representation of the delta rotation
212ad7f33a29c6ce41f2b662d1de9af7e9cf92f4dc9Mathias Agopian     *              // into a quaternion before turning it into the rotation matrix.
213ad7f33a29c6ce41f2b662d1de9af7e9cf92f4dc9Mathias Agopian     *              float thetaOverTwo = omegaMagnitude * dT / 2.0f;
214ad7f33a29c6ce41f2b662d1de9af7e9cf92f4dc9Mathias Agopian     *              float sinThetaOverTwo = sin(thetaOverTwo);
215ad7f33a29c6ce41f2b662d1de9af7e9cf92f4dc9Mathias Agopian     *              float cosThetaOverTwo = cos(thetaOverTwo);
216ad7f33a29c6ce41f2b662d1de9af7e9cf92f4dc9Mathias Agopian     *              deltaRotationVector[0] = sinThetaOverTwo * axisX;
217ad7f33a29c6ce41f2b662d1de9af7e9cf92f4dc9Mathias Agopian     *              deltaRotationVector[1] = sinThetaOverTwo * axisY;
218ad7f33a29c6ce41f2b662d1de9af7e9cf92f4dc9Mathias Agopian     *              deltaRotationVector[2] = sinThetaOverTwo * axisZ;
219ad7f33a29c6ce41f2b662d1de9af7e9cf92f4dc9Mathias Agopian     *              deltaRotationVector[3] = cosThetaOverTwo;
220fa33565714e4192dbab446ee1fbccb87dd414bedMathias Agopian     *          }
221fa33565714e4192dbab446ee1fbccb87dd414bedMathias Agopian     *          timestamp = event.timestamp;
222ad7f33a29c6ce41f2b662d1de9af7e9cf92f4dc9Mathias Agopian     *          float[] deltaRotationMatrix = new float[9];
223ad7f33a29c6ce41f2b662d1de9af7e9cf92f4dc9Mathias Agopian     *          SensorManager.getRotationMatrixFromVector(deltaRotationMatrix, deltaRotationVector);
224ad7f33a29c6ce41f2b662d1de9af7e9cf92f4dc9Mathias Agopian     *          // User code should concatenate the delta rotation we computed with the current rotation
225ad7f33a29c6ce41f2b662d1de9af7e9cf92f4dc9Mathias Agopian     *          // in order to get the updated rotation.
226ad7f33a29c6ce41f2b662d1de9af7e9cf92f4dc9Mathias Agopian     *          // rotationCurrent = rotationCurrent * deltaRotationMatrix;
227fa33565714e4192dbab446ee1fbccb87dd414bedMathias Agopian     *     }
228fa33565714e4192dbab446ee1fbccb87dd414bedMathias Agopian     * </pre>
229ad7f33a29c6ce41f2b662d1de9af7e9cf92f4dc9Mathias Agopian     * <p>
230ad7f33a29c6ce41f2b662d1de9af7e9cf92f4dc9Mathias Agopian     * In practice, the gyroscope noise and offset will introduce some errors
231ad7f33a29c6ce41f2b662d1de9af7e9cf92f4dc9Mathias Agopian     * which need to be compensated for. This is usually done using the
232ad7f33a29c6ce41f2b662d1de9af7e9cf92f4dc9Mathias Agopian     * information from other sensors, but is beyond the scope of this document.
233ad7f33a29c6ce41f2b662d1de9af7e9cf92f4dc9Mathias Agopian     * </p>
2340f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * <h4>{@link android.hardware.Sensor#TYPE_LIGHT Sensor.TYPE_LIGHT}:</h4>
23574cde2cee9e53006a710f4e80700cd560c2d0e4dMathias Agopian     * <ul>
23674cde2cee9e53006a710f4e80700cd560c2d0e4dMathias Agopian     * <p>
23774cde2cee9e53006a710f4e80700cd560c2d0e4dMathias Agopian     * values[0]: Ambient light level in SI lux units
23874cde2cee9e53006a710f4e80700cd560c2d0e4dMathias Agopian     * </ul>
2390f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     *
2401260a89b54436fdd6d80e7c98b7db3c55f85104cMathias Agopian     * <h4>{@link android.hardware.Sensor#TYPE_PRESSURE Sensor.TYPE_PRESSURE}:</h4>
2411260a89b54436fdd6d80e7c98b7db3c55f85104cMathias Agopian     * <ul>
2421260a89b54436fdd6d80e7c98b7db3c55f85104cMathias Agopian     * <p>
2431260a89b54436fdd6d80e7c98b7db3c55f85104cMathias Agopian     * values[0]: Atmospheric pressure in hPa (millibar)
2441260a89b54436fdd6d80e7c98b7db3c55f85104cMathias Agopian     * </ul>
2451260a89b54436fdd6d80e7c98b7db3c55f85104cMathias Agopian     *
2460f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * <h4>{@link android.hardware.Sensor#TYPE_PROXIMITY Sensor.TYPE_PROXIMITY}:
2470f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * </h4>
2480f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     *
24974cde2cee9e53006a710f4e80700cd560c2d0e4dMathias Agopian     * <ul>
25074cde2cee9e53006a710f4e80700cd560c2d0e4dMathias Agopian     * <p>
25174cde2cee9e53006a710f4e80700cd560c2d0e4dMathias Agopian     * values[0]: Proximity sensor distance measured in centimeters
25274cde2cee9e53006a710f4e80700cd560c2d0e4dMathias Agopian     * </ul>
2530f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     *
25474cde2cee9e53006a710f4e80700cd560c2d0e4dMathias Agopian     * <p>
2550f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * <b>Note:</b> Some proximity sensors only support a binary <i>near</i> or
2560f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * <i>far</i> measurement. In this case, the sensor should report its
2570f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * {@link android.hardware.Sensor#getMaximumRange() maximum range} value in
2580f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * the <i>far</i> state and a lesser value in the <i>near</i> state.
2590f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * </p>
2600f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     *
2617a0541d6b803da02b8724b1d140d6ccaaec23a36Kevin Powell     *  <h4>{@link android.hardware.Sensor#TYPE_GRAVITY Sensor.TYPE_GRAVITY}:</h4>
2627badd2c402f9e8e9fd13f6915ad2e32301f9f305Mathias Agopian     *  <p>A three dimensional vector indicating the direction and magnitude of gravity.  Units
2637badd2c402f9e8e9fd13f6915ad2e32301f9f305Mathias Agopian     *  are m/s^2. The coordinate system is the same as is used by the acceleration sensor.</p>
2647badd2c402f9e8e9fd13f6915ad2e32301f9f305Mathias Agopian     *  <p><b>Note:</b> When the device is at rest, the output of the gravity sensor should be identical
2657badd2c402f9e8e9fd13f6915ad2e32301f9f305Mathias Agopian     *  to that of the accelerometer.</p>
2667a0541d6b803da02b8724b1d140d6ccaaec23a36Kevin Powell     *
2677a0541d6b803da02b8724b1d140d6ccaaec23a36Kevin Powell     *  <h4>{@link android.hardware.Sensor#TYPE_LINEAR_ACCELERATION Sensor.TYPE_LINEAR_ACCELERATION}:</h4>
2687a0541d6b803da02b8724b1d140d6ccaaec23a36Kevin Powell     *  A three dimensional vector indicating acceleration along each device axis, not including
2697a0541d6b803da02b8724b1d140d6ccaaec23a36Kevin Powell     *  gravity.  All values have units of m/s^2.  The coordinate system is the same as is used by the
2707badd2c402f9e8e9fd13f6915ad2e32301f9f305Mathias Agopian     *  acceleration sensor.
2717badd2c402f9e8e9fd13f6915ad2e32301f9f305Mathias Agopian     *  <p>The output of the accelerometer, gravity and  linear-acceleration sensors must obey the
2727badd2c402f9e8e9fd13f6915ad2e32301f9f305Mathias Agopian     *  following relation:</p>
2737badd2c402f9e8e9fd13f6915ad2e32301f9f305Mathias Agopian     *   <p><ul>acceleration = gravity + linear-acceleration</ul></p>
2747a0541d6b803da02b8724b1d140d6ccaaec23a36Kevin Powell     *
2757a0541d6b803da02b8724b1d140d6ccaaec23a36Kevin Powell     *  <h4>{@link android.hardware.Sensor#TYPE_ROTATION_VECTOR Sensor.TYPE_ROTATION_VECTOR}:</h4>
2767badd2c402f9e8e9fd13f6915ad2e32301f9f305Mathias Agopian     *  <p>The rotation vector represents the orientation of the device as a combination of an <i>angle</i>
2777badd2c402f9e8e9fd13f6915ad2e32301f9f305Mathias Agopian     *  and an <i>axis</i>, in which the device has rotated through an angle &#952 around an axis
2787badd2c402f9e8e9fd13f6915ad2e32301f9f305Mathias Agopian     *  &lt;x, y, z>.</p>
2797badd2c402f9e8e9fd13f6915ad2e32301f9f305Mathias Agopian     *  <p>The three elements of the rotation vector are
2807badd2c402f9e8e9fd13f6915ad2e32301f9f305Mathias Agopian     *  &lt;x*sin(&#952/2), y*sin(&#952/2), z*sin(&#952/2)>, such that the magnitude of the rotation
2817badd2c402f9e8e9fd13f6915ad2e32301f9f305Mathias Agopian     *  vector is equal to sin(&#952/2), and the direction of the rotation vector is equal to the
2827badd2c402f9e8e9fd13f6915ad2e32301f9f305Mathias Agopian     *  direction of the axis of rotation.</p>
2837badd2c402f9e8e9fd13f6915ad2e32301f9f305Mathias Agopian     *  </p>The three elements of the rotation vector are equal to
2847badd2c402f9e8e9fd13f6915ad2e32301f9f305Mathias Agopian     *  the last three components of a <b>unit</b> quaternion
2857badd2c402f9e8e9fd13f6915ad2e32301f9f305Mathias Agopian     *  &lt;cos(&#952/2), x*sin(&#952/2), y*sin(&#952/2), z*sin(&#952/2)>.</p>
2867badd2c402f9e8e9fd13f6915ad2e32301f9f305Mathias Agopian     *  <p>Elements of the rotation vector are unitless.
2877badd2c402f9e8e9fd13f6915ad2e32301f9f305Mathias Agopian     *  The x,y, and z axis are defined in the same way as the acceleration
2887badd2c402f9e8e9fd13f6915ad2e32301f9f305Mathias Agopian     *  sensor.</p>
289d84d2b7b1ee5c37da878534f4d493d8d00a3f65fMathias Agopian     *  The reference coordinate system is defined as a direct orthonormal basis,
290d84d2b7b1ee5c37da878534f4d493d8d00a3f65fMathias Agopian     *  where:
291d84d2b7b1ee5c37da878534f4d493d8d00a3f65fMathias Agopian     * </p>
292d84d2b7b1ee5c37da878534f4d493d8d00a3f65fMathias Agopian     *
293d84d2b7b1ee5c37da878534f4d493d8d00a3f65fMathias Agopian     * <ul>
294d84d2b7b1ee5c37da878534f4d493d8d00a3f65fMathias Agopian     * <li>X is defined as the vector product <b>Y.Z</b> (It is tangential to
295d84d2b7b1ee5c37da878534f4d493d8d00a3f65fMathias Agopian     * the ground at the device's current location and roughly points East).</li>
296d84d2b7b1ee5c37da878534f4d493d8d00a3f65fMathias Agopian     * <li>Y is tangential to the ground at the device's current location and
29752bfc243684b2f340da326aaa38e9021e4e3b2e6Scott Main     * points towards magnetic north.</li>
298d84d2b7b1ee5c37da878534f4d493d8d00a3f65fMathias Agopian     * <li>Z points towards the sky and is perpendicular to the ground.</li>
299d84d2b7b1ee5c37da878534f4d493d8d00a3f65fMathias Agopian     * </ul>
300d84d2b7b1ee5c37da878534f4d493d8d00a3f65fMathias Agopian     *
301d84d2b7b1ee5c37da878534f4d493d8d00a3f65fMathias Agopian     * <p>
302d84d2b7b1ee5c37da878534f4d493d8d00a3f65fMathias Agopian     * <center><img src="../../../images/axis_globe.png"
303d84d2b7b1ee5c37da878534f4d493d8d00a3f65fMathias Agopian     * alt="World coordinate-system diagram." border="0" /></center>
304d84d2b7b1ee5c37da878534f4d493d8d00a3f65fMathias Agopian     * </p>
305d84d2b7b1ee5c37da878534f4d493d8d00a3f65fMathias Agopian     *
3067badd2c402f9e8e9fd13f6915ad2e32301f9f305Mathias Agopian     * <ul>
3077badd2c402f9e8e9fd13f6915ad2e32301f9f305Mathias Agopian     * <p>
3087badd2c402f9e8e9fd13f6915ad2e32301f9f305Mathias Agopian     * values[0]: x*sin(&#952/2)
3097badd2c402f9e8e9fd13f6915ad2e32301f9f305Mathias Agopian     * </p>
3107badd2c402f9e8e9fd13f6915ad2e32301f9f305Mathias Agopian     * <p>
3117badd2c402f9e8e9fd13f6915ad2e32301f9f305Mathias Agopian     * values[1]: y*sin(&#952/2)
3127badd2c402f9e8e9fd13f6915ad2e32301f9f305Mathias Agopian     * </p>
3137badd2c402f9e8e9fd13f6915ad2e32301f9f305Mathias Agopian     * <p>
3147badd2c402f9e8e9fd13f6915ad2e32301f9f305Mathias Agopian     * values[2]: z*sin(&#952/2)
3157badd2c402f9e8e9fd13f6915ad2e32301f9f305Mathias Agopian     * </p>
3167badd2c402f9e8e9fd13f6915ad2e32301f9f305Mathias Agopian     * <p>
3177badd2c402f9e8e9fd13f6915ad2e32301f9f305Mathias Agopian     * values[3]: cos(&#952/2) <i>(optional: only if value.length = 4)</i>
3187badd2c402f9e8e9fd13f6915ad2e32301f9f305Mathias Agopian     * </p>
3197badd2c402f9e8e9fd13f6915ad2e32301f9f305Mathias Agopian     * </ul>
3207a0541d6b803da02b8724b1d140d6ccaaec23a36Kevin Powell     *
3210f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * <h4>{@link android.hardware.Sensor#TYPE_ORIENTATION
3220f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * Sensor.TYPE_ORIENTATION}:</h4> All values are angles in degrees.
3230f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     *
3240f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * <ul>
3250f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * <p>
3260f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * values[0]: Azimuth, angle between the magnetic north direction and the
3270f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * y-axis, around the z-axis (0 to 359). 0=North, 90=East, 180=South,
3280f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * 270=West
3290f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * </p>
3300f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     *
3310f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * <p>
3320f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * values[1]: Pitch, rotation around x-axis (-180 to 180), with positive
3330f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * values when the z-axis moves <b>toward</b> the y-axis.
3340f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * </p>
3350f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     *
3360f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * <p>
3370f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * values[2]: Roll, rotation around y-axis (-90 to 90), with positive values
3380f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * when the x-axis moves <b>toward</b> the z-axis.
3390f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * </p>
3400f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * </ul>
3410f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     *
3420f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * <p>
3430f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * <b>Note:</b> This definition is different from <b>yaw, pitch and roll</b>
3440f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * used in aviation where the X axis is along the long side of the plane
3450f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * (tail to nose).
3460f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * </p>
3470f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     *
3480f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * <p>
3490f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * <b>Note:</b> This sensor type exists for legacy reasons, please use
3500f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * {@link android.hardware.SensorManager#getRotationMatrix
3510f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * getRotationMatrix()} in conjunction with
3520f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * {@link android.hardware.SensorManager#remapCoordinateSystem
3530f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * remapCoordinateSystem()} and
3540f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * {@link android.hardware.SensorManager#getOrientation getOrientation()} to
3550f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * compute these values instead.
3560f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * </p>
3570f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     *
3580f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * <p>
3590f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * <b>Important note:</b> For historical reasons the roll angle is positive
3600f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * in the clockwise direction (mathematically speaking, it should be
3610f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * positive in the counter-clockwise direction).
3620f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * </p>
3635819051eee071d622e5cb1f32c74112b1c7b1072Urs Fleisch     *
3645819051eee071d622e5cb1f32c74112b1c7b1072Urs Fleisch     * <h4>{@link android.hardware.Sensor#TYPE_RELATIVE_HUMIDITY
3655819051eee071d622e5cb1f32c74112b1c7b1072Urs Fleisch     * Sensor.TYPE_RELATIVE_HUMIDITY}:</h4>
3665819051eee071d622e5cb1f32c74112b1c7b1072Urs Fleisch     * <ul>
3675819051eee071d622e5cb1f32c74112b1c7b1072Urs Fleisch     * <p>
3685819051eee071d622e5cb1f32c74112b1c7b1072Urs Fleisch     * values[0]: Relative ambient air humidity in percent
3695819051eee071d622e5cb1f32c74112b1c7b1072Urs Fleisch     * </p>
3705819051eee071d622e5cb1f32c74112b1c7b1072Urs Fleisch     * </ul>
3715819051eee071d622e5cb1f32c74112b1c7b1072Urs Fleisch     * <p>
3725819051eee071d622e5cb1f32c74112b1c7b1072Urs Fleisch     * When relative ambient air humidity and ambient temperature are
3735819051eee071d622e5cb1f32c74112b1c7b1072Urs Fleisch     * measured, the dew point and absolute humidity can be calculated.
3745819051eee071d622e5cb1f32c74112b1c7b1072Urs Fleisch     * </p>
3755819051eee071d622e5cb1f32c74112b1c7b1072Urs Fleisch     * <u>Dew Point</u>
3765819051eee071d622e5cb1f32c74112b1c7b1072Urs Fleisch     * <p>
3775819051eee071d622e5cb1f32c74112b1c7b1072Urs Fleisch     * The dew point is the temperature to which a given parcel of air must be
3785819051eee071d622e5cb1f32c74112b1c7b1072Urs Fleisch     * cooled, at constant barometric pressure, for water vapor to condense
3795819051eee071d622e5cb1f32c74112b1c7b1072Urs Fleisch     * into water.
3805819051eee071d622e5cb1f32c74112b1c7b1072Urs Fleisch     * </p>
3815819051eee071d622e5cb1f32c74112b1c7b1072Urs Fleisch     * <center><pre>
3825819051eee071d622e5cb1f32c74112b1c7b1072Urs Fleisch     *                    ln(RH/100%) + m&#183;t/(T<sub>n</sub>+t)
3835819051eee071d622e5cb1f32c74112b1c7b1072Urs Fleisch     * t<sub>d</sub>(t,RH) = T<sub>n</sub> &#183; ------------------------------
3845819051eee071d622e5cb1f32c74112b1c7b1072Urs Fleisch     *                 m - [ln(RH/100%) + m&#183;t/(T<sub>n</sub>+t)]
3855819051eee071d622e5cb1f32c74112b1c7b1072Urs Fleisch     * </pre></center>
3865819051eee071d622e5cb1f32c74112b1c7b1072Urs Fleisch     * <dl>
3875819051eee071d622e5cb1f32c74112b1c7b1072Urs Fleisch     * <dt>t<sub>d</sub></dt> <dd>dew point temperature in &deg;C</dd>
3885819051eee071d622e5cb1f32c74112b1c7b1072Urs Fleisch     * <dt>t</dt>             <dd>actual temperature in &deg;C</dd>
3895819051eee071d622e5cb1f32c74112b1c7b1072Urs Fleisch     * <dt>RH</dt>            <dd>actual relative humidity in %</dd>
3905819051eee071d622e5cb1f32c74112b1c7b1072Urs Fleisch     * <dt>m</dt>             <dd>17.62</dd>
3915819051eee071d622e5cb1f32c74112b1c7b1072Urs Fleisch     * <dt>T<sub>n</sub></dt> <dd>243.12 &deg;C</dd>
3925819051eee071d622e5cb1f32c74112b1c7b1072Urs Fleisch     * </dl>
3935819051eee071d622e5cb1f32c74112b1c7b1072Urs Fleisch     * <p>for example:</p>
3945819051eee071d622e5cb1f32c74112b1c7b1072Urs Fleisch     * <pre class="prettyprint">
3955819051eee071d622e5cb1f32c74112b1c7b1072Urs Fleisch     * h = Math.log(rh / 100.0) + (17.62 * t) / (243.12 + t);
3965819051eee071d622e5cb1f32c74112b1c7b1072Urs Fleisch     * td = 243.12 * h / (17.62 - h);
3975819051eee071d622e5cb1f32c74112b1c7b1072Urs Fleisch     * </pre>
3985819051eee071d622e5cb1f32c74112b1c7b1072Urs Fleisch     * <u>Absolute Humidity</u>
3995819051eee071d622e5cb1f32c74112b1c7b1072Urs Fleisch     * <p>
4005819051eee071d622e5cb1f32c74112b1c7b1072Urs Fleisch     * The absolute humidity is the mass of water vapor in a particular volume
4015819051eee071d622e5cb1f32c74112b1c7b1072Urs Fleisch     * of dry air. The unit is g/m<sup>3</sup>.
4025819051eee071d622e5cb1f32c74112b1c7b1072Urs Fleisch     * </p>
4035819051eee071d622e5cb1f32c74112b1c7b1072Urs Fleisch     * <center><pre>
4045819051eee071d622e5cb1f32c74112b1c7b1072Urs Fleisch     *                    RH/100%&#183;A&#183;exp(m&#183;t/(T<sub>n</sub>+t))
4055819051eee071d622e5cb1f32c74112b1c7b1072Urs Fleisch     * d<sub>v</sub>(t,RH) = 216.7 &#183; -------------------------
4065819051eee071d622e5cb1f32c74112b1c7b1072Urs Fleisch     *                           273.15 + t
4075819051eee071d622e5cb1f32c74112b1c7b1072Urs Fleisch     * </pre></center>
4085819051eee071d622e5cb1f32c74112b1c7b1072Urs Fleisch     * <dl>
4095819051eee071d622e5cb1f32c74112b1c7b1072Urs Fleisch     * <dt>d<sub>v</sub></dt> <dd>absolute humidity in g/m<sup>3</sup></dd>
4105819051eee071d622e5cb1f32c74112b1c7b1072Urs Fleisch     * <dt>t</dt>             <dd>actual temperature in &deg;C</dd>
4115819051eee071d622e5cb1f32c74112b1c7b1072Urs Fleisch     * <dt>RH</dt>            <dd>actual relative humidity in %</dd>
4125819051eee071d622e5cb1f32c74112b1c7b1072Urs Fleisch     * <dt>m</dt>             <dd>17.62</dd>
4135819051eee071d622e5cb1f32c74112b1c7b1072Urs Fleisch     * <dt>T<sub>n</sub></dt> <dd>243.12 &deg;C</dd>
4145819051eee071d622e5cb1f32c74112b1c7b1072Urs Fleisch     * <dt>A</dt>             <dd>6.112 hPa</dd>
4155819051eee071d622e5cb1f32c74112b1c7b1072Urs Fleisch     * </dl>
4165819051eee071d622e5cb1f32c74112b1c7b1072Urs Fleisch     * <p>for example:</p>
4175819051eee071d622e5cb1f32c74112b1c7b1072Urs Fleisch     * <pre class="prettyprint">
4185819051eee071d622e5cb1f32c74112b1c7b1072Urs Fleisch     * dv = 216.7 *
4195819051eee071d622e5cb1f32c74112b1c7b1072Urs Fleisch     * (rh / 100.0 * 6.112 * Math.exp(17.62 * t / (243.12 + t)) / (273.15 + t));
4205819051eee071d622e5cb1f32c74112b1c7b1072Urs Fleisch     * </pre>
4210f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     *
422462db220a2986f7d9fc3d7e3e6af6615570eaa0bMathias Agopian     * <h4>{@link android.hardware.Sensor#TYPE_AMBIENT_TEMPERATURE Sensor.TYPE_AMBIENT_TEMPERATURE}:
423462db220a2986f7d9fc3d7e3e6af6615570eaa0bMathias Agopian     * </h4>
424462db220a2986f7d9fc3d7e3e6af6615570eaa0bMathias Agopian     *
425462db220a2986f7d9fc3d7e3e6af6615570eaa0bMathias Agopian     * <ul>
426462db220a2986f7d9fc3d7e3e6af6615570eaa0bMathias Agopian     * <p>
427462db220a2986f7d9fc3d7e3e6af6615570eaa0bMathias Agopian     * values[0]: ambient (room) temperature in degree Celsius.
428462db220a2986f7d9fc3d7e3e6af6615570eaa0bMathias Agopian     * </ul>
429462db220a2986f7d9fc3d7e3e6af6615570eaa0bMathias Agopian     *
4300f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * @see SensorEvent
4310f791a799dc81d93935fd2597297cf7ac2c0a044Mathias Agopian     * @see GeomagneticField
4324115c518753052add46b017bb3044da6f6169a7bMike Lockwood     */
4337a0541d6b803da02b8724b1d140d6ccaaec23a36Kevin Powell
4349066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public final float[] values;
4359066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
4369066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
43774cde2cee9e53006a710f4e80700cd560c2d0e4dMathias Agopian     * The sensor that generated this event. See
43874cde2cee9e53006a710f4e80700cd560c2d0e4dMathias Agopian     * {@link android.hardware.SensorManager SensorManager} for details.
4399066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
44074cde2cee9e53006a710f4e80700cd560c2d0e4dMathias Agopian   public Sensor sensor;
44174cde2cee9e53006a710f4e80700cd560c2d0e4dMathias Agopian
4429066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
44374cde2cee9e53006a710f4e80700cd560c2d0e4dMathias Agopian     * The accuracy of this event. See {@link android.hardware.SensorManager
44474cde2cee9e53006a710f4e80700cd560c2d0e4dMathias Agopian     * SensorManager} for details.
4459066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
4469066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public int accuracy;
44774cde2cee9e53006a710f4e80700cd560c2d0e4dMathias Agopian
44874cde2cee9e53006a710f4e80700cd560c2d0e4dMathias Agopian
4499066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
4509066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * The time in nanosecond at which the event happened
4519066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
4529066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public long timestamp;
4539066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
45474cde2cee9e53006a710f4e80700cd560c2d0e4dMathias Agopian
4559066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    SensorEvent(int size) {
4569066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        values = new float[size];
4579066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
4589066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project}
459