これは完全な答えではありませんが、ローテーションデータを記録するテストを開発し、他の人がテストまたはデータを分析するためのより良い方法を考えられるように、ここに投稿したいと思いました(収集されたデータの一般的な分析とともに)。彼らは参加を歓迎します。
テストのために、次のjavascriptコードを<script>タグ内に配置しました。それ以外の場合は骨格のHTMLドキュメントです。
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);
そのPHPドキュメントに関連するPHPコードは次のとおりです。
<?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
?>
これを設定した後、私はiPadを手に取り、考えられる限り多くの方向(重力に対して)にゆっくりと何百回も回転させました。次に、記録されたデータを取得してExcelファイルにインポートし、傾向が現れるまでさまざまな方法で並べ替えました。
そして、それらの傾向は何でしたか?私の分析はちょっと初歩的なものであり、外れ値のように見えるものを必ずしも説明しているわけではありませんが、次のように見えます。
Portrait-Landscape回転イベントは、XYangle <28の場合にのみ発生します。ただし、azの値が大きくなると(iPadを地面に対して平らにする)、XYangleを小さくする必要があるようです。azが9.8に近づくほど、回転イベントの予測が難しくなるようです。
ランドスケープ-ポートレート回転イベントは、XYangle> 45の場合にのみ発生します。ここでも、azの値が増加すると、XYangleも増加する必要があります。さらに、azが9.8に近づくと、回転イベントの予測が難しくなります。
これが誰かに、より良いテストとより良い分析のための良い出発点になることを願っています。このデータは、Scott Jehlがここで行ったのと同様のiOSローテーションバグ修正で使用する予定です:https ://github.com/scottjehl/iOS-Orientationchange-Fix 、これまでのところうまく使用していますが、まだ使用されていません特にユーザーがモバイルデバイスをフラット化する場合、非常にクリーンなソリューションです。
より注意深い人がローテーションイベントの予測可能性を微調整するために使用できる、私の分析が見逃した何かがあることを願っています。