Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I hope that this codes clarify everything. Although the values this code returns can't be matched directly with the values of beta and gamma:</p> <p>Mozilla returns the sin of the angle so, to get the angle...</p> <pre><code>X: Math.asin(eventInfo.x)*180/Math.PI Y: Math.asin(eventInfo.y)*180/Math.PI Z: Math.asin(eventInfo.z)*180/Math.PI </code></pre> <p>Webkit returns the acceleration in each axe. Then, to get the angle... (The sing changes is just to unify returned values)</p> <pre><code>X: Math.asin(clean(eventInfo.accelerationIncludingGravity.x/GRAVITY))*180/Math.PI Y: Math.asin(clean(-eventInfo.accelerationIncludingGravity.y/GRAVITY))*180/Math.PI Z: Math.asin(clean(-eventInfo.accelerationIncludingGravity.z/GRAVITY))*180/Math.PI </code></pre> <p>Being clean: (Because sometimes, the data returned, even without accelerating the phone, it's more than 9.8)</p> <pre><code>function clean(data) { if(data&lt;-1.0) { return -1.0; } else {if(data&gt;1.0) { return 1.0; }else { return data; }} } </code></pre> <p>The meaning of each axe is: X-> inclination of the mobile to its right or left. Will be + if you tilt the mobile to its right (clockwise), keeping the buttons of volume up. Y-> Tells if the mobile is up -if the lock/on-off button is up- (angle +) or down (angle -). It tells the inclination of the mobile relative to the floor. (angle of Y vector with plane X-Z) Z-> Tells if the mobile screen is facing up (angle +) or upside down (angle -). It's the angle of the Z vector on the plane Y-X</p> <p>Hope this is worthy for you!</p> <p>Anyway, I'm working on some GWT classes to make working with this easier :) It's not difficult but I do not have so much time. I'll tell you</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload