Using event.accelerationIncludingGravityon Android, it returns a value
event.accelerationIncludingGravity
x: -0.2 y: +0.1 z: +9.1
when resting on a flat surface. However, I want to get acceleration without gravity, but event.accelerationnot supported. Is there a way to convert it to math? In HTML5Rocks is an example of removing the factor of gravity, but it does not seem to work.
event.acceleration
// Convert the value from acceleration to degrees acceleration.x|y is the // acceleration according to gravity, we'll assume we're on Earth and divide // by 9.81 (earth gravity) to get a percentage value, and then multiply that // by 90 to convert to degrees. var tiltLR = Math.round(((acceleration.x) / 9.81) * -90); var tiltFB = Math.round(((acceleration.y + 9.81) / 9.81) * 90 * facingUp);
Sample script acceleration of graphic display (not from HTML5Rocks)
. x y, 0, , , , , x y , . / ^ 2. ( ). 9,86 / ^ 2. , , , . , , . z, . 300 .