1
我正在开发Android上的晃动检测,我无法处理一个问题 - 旋转手机。我的算法可以正确检测抖动,但它也会作出反应。检测手机抖动
它看起来像这样:
//for every second
if(!alarmed) {
if(Math.abs(oldX - acceleration.x) > threshold ||
Math.abs(oldY - acceleration.y) > threshold ||
Math.abs(oldZ - acceleration.z) > threshold) {
// shake detected
}
}
oldX = acceleration.x;
oldY = acceleration.y;
oldZ = acceleration.z;
这是JavaScript的,因为我写的科尔多瓦。
任何帮助,将不胜感激。