Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is not quite an answer, but I did develop a test to record rotation data and wanted to post it here (with a general analysis of the collected data) so that if others can think of better ways to test it or analyze the data, they're welcome to weigh in.</p> <p>For the test, I put the following javascript code inside a &lt;script&gt; tag in an otherwise skeletal HTML document:</p> <pre><code>var ax, ay, az; window.addEventListener("devicemotion", function(e) { // DO NOT PUT ALERTS IN THIS LISTENER BLOCK!! ax = e.accelerationIncludingGravity.x; ay = e.accelerationIncludingGravity.y; az = e.accelerationIncludingGravity.z; }, false); window.addEventListener("orientationchange", function() { orient = Math.abs(parseInt(window.orientation)); // returns positive integer value of device orientation // It's worth noting that on an iPad, the orientationchange event does not // fire until after the rotation has already taken place, so a value of 0 or // 180 corresponds to the accelerometer values for a Landscape-Portrait // rotation, while a value of 90 corresponds to the accelerometer values for // a Portrait-Landscape rotation event. ax = Math.abs(ax); ay = Math.abs(ay); az = Math.abs(az); //I put an ajax call here that sends orient, ax, ay and az as $_POST data to a PHP document }, false); </code></pre> <p>Here is the relevant PHP code in that PHP document:</p> <pre><code>&lt;?php //I stored my $_POST variables as $orient, $ax, $ay, and $az for consistency $XYangle = rad2deg(atan($ay/$ax)); $XZangle = rad2deg(atan($az/$ax)); $YZangle = rad2deg(atan($az/$ay)); //tab-delimit the data and enter it into a .txt file that can be imported into Excel for "easy" reading and sorting $string = $orient."\t".$ax."\t".$ay."\t".$az."\t".$XYangle."\t".$XZangle."\t".$YZangle."\n"; //Open file and write $string to file ?&gt; </code></pre> <p>After setting this up, I took an iPad and rotated it slowly hundreds of times in as many orientations (relative to gravity) as I could think of. I then took the recorded data and imported it into an Excel file, and sorted it various ways until trends began to appear.</p> <p>And what were those trends, you ask? My analysis is a touch rudimentary and doesn't necessarily account for what looks to me like outliers, but it seems like:</p> <p>A Portrait-Landscape rotation event will only occur if XYangle &lt; 28. However, as the value of az increases (you flatten the iPad with respect to the ground), it seems like XYangle must decrease. It seems like the closer az gets to 9.8, the less predictable the rotation events become.</p> <p>A Landscape-Portrait rotation event will only occur if XYangle > 45. Once again, as the value of az increases, the XYangle must also increase. Additionally, as az approaches 9.8, the rotation event becomes less predictable.</p> <p>I hope this gives someone a good starting point for some better testing and better analysis. I intend to use this data in an iOS rotation bug fix similar to what Scott Jehl did here: <a href="https://github.com/scottjehl/iOS-Orientationchange-Fix" rel="nofollow">https://github.com/scottjehl/iOS-Orientationchange-Fix</a> , and so far I've employed it nicely, but it's still not a very clean solution, especially as the user flattens out the mobile device.</p> <p>I'm hoping there's something my analysis missed that a more observant person can use to fine-tune the predictability of rotation events.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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