加速度计检测一侧到另一侧的运动 - 在方向改变的即时检测
-
21-09-2019 - |
题
标识有一个应用程序,做一件事情,如果你动摇的一种方式,另一种,如果你动摇它的其他。
大气压我的代码。
if (acceleration.x > 1.5) {
//朝向自己当臂向右
float duration = ([imageArray count]*0.04);
//HUMAN EYE KEEPS IMAGES IN EYE For 40 MILLISECONDS//
//NSLog(@"duration:%f", duration);
[theFlash setAnimationImages:imageArray];
[theFlash setAnimationRepeatCount:1];
theFlash.animationDuration = duration;
[theFlash startAnimating];
NSLog(@"images flashed forward");
}
if (acceleration.x < -1)
{
//arm to the left when facing you
float duration = ([imageArrayReversed count]*0.04);
//HUMAN EYE KEEPS IMAGES IN EYE For 40 MILLISECONDS//
NSLog(@"duration:%f", duration);
[theFlash setAnimationImages:imageArrayReversed];
[theFlash setAnimationRepeatCount:1];
theFlash.animationDuration = duration;
[theFlash startAnimating];
NSLog(@"images flashed backward");
}
的1倍-1的值正在研究认为不够太敏感。
然而,这个代码是不是给我所期望的结果。如图像闪烁ID(查看代码)一旦人开始移动设备的其他方式。
没有办法做到这一点?
解决方案
好了,你将不得不加速来获得速度整合。不幸的是,加速度计是有点吵,必将飘了一点,所以你将不得不筛选组成。我认为在所描述的过滤器 HTTP://www.musicdsp .ORG / showone.php?ID = 92 会做你的需要,设置为1/4左右的采样频率的截止频率。您需要band
输出,你就会有调整的共振参数。
不隶属于 StackOverflow