且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

iOS - 如何判断设备是否被提升/丢弃(CoreMotion)

更新时间:2023-10-05 09:23:22

此问题已弹出

长篇小说,您需要 userAcceleration 。检查其在x,y和z方向上的分量。如果z分量很重要,x和y不是,那么你的手机是垂直加速度(被提升/放弃)。

Long story short, you need the userAcceleration. Check for its component in the x, y and z directions. If the z component is significant and the x and y are not then your phone is accelerationg vertically (being raised / dropped).

如果你想检测震动,用户加速度的突然变化。您可能需要使用高通滤波器

If you want to detect shakes then look for the sudden changes in the user acceleration. You might want to use a high-pass filter for that.