私はCoreMotionを使用して、アプリケーション内のデバイス動作の測定値を取得しています。スウィフトでiOSデバイスの振動量を測定するには?
しかし、私が測定しようとしているのは、デバイスがどれくらい動いているか、つまりデバイスが大きく移動したときのしきい値を設定することです。任意の方向の量。私は、私が戻ってきた測定値が超高感度であり、すべてを正しく使用する方法がわからないことを発見しました。
注:私は揺れのジェスチャーを検出することについて知っています。それは私が求めているものではありません - 私は揺れの量を測定し、それを表示する正しい方法を求めています。
私はDeviceMotionから使っているコードのサンプル:
if let deviceMotion = motionManager.deviceMotion {
let quat = deviceMotion.attitude.quaternion;
var qRoll = radiansToDegrees(radians: atan2(2*(quat.y*quat.w - quat.x*quat.z), 1 - 2*quat.y*quat.y - 2*quat.z*quat.z)) ;
var qPitch = radiansToDegrees(radians: atan2(2*(quat.x*quat.w + quat.y*quat.z), 1 - 2*quat.x*quat.x - 2*quat.z*quat.z));
var qYaw = radiansToDegrees(radians: asin(2*quat.x*quat.y + 2*quat.w*quat.z));
let orientation = deviceMotion.attitude
var roll = radiansToDegrees(radians: orientation.roll)
var pitch = radiansToDegrees(radians: orientation.pitch)
var yaw = radiansToDegrees(radians: orientation.yaw)
}
と加速度計を使用して:
if motionManager.isAccelerometerAvailable {
motionManager.startAccelerometerUpdates(to: OperationQueue.current!, withHandler: { accelerometerData, error in
if let acceleration = accelerometerData?.acceleration {
print("ACCELEROMETER X: " + acceleration.x.description)
print("ACCELEROMETER Y: " + acceleration.y.description)
print("ACCELEROMETER Z: " + acceleration.z.description)
})
}
どのくらいAを測定するCoreMotionからの測定値を使用する正しい方法は何ですかデバイスが揺れている?
あなたのユースケースは何ですか? – nathan
CoreMotionとシェイキーネスの測定方法についてもっと知りたいのですが、ユースケースはデバイスをオブジェクトに置き、どれくらい揺れているかを測定することです。 – motionpotion