2012-04-07 132 views
0

我在我的項目中使用加速計功能,我需要從代碼中排除某些軸。我想排除Y & Z並僅使用X.謝謝如何從加速度計代碼中排除特定軸?

這是我正在使用的代碼。

-(void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration{ 

    double const kThreshold = 1.5; 
    // double const kThreshold = 2.0; 
    if (fabsf(acceleration.x) > kThreshold 
     || fabsf(acceleration.y) > kThreshold 
     || fabsf(acceleration.z) > kThreshold) 
+0

從你寫這真的不清楚是什麼你正在努力。 – 2012-04-07 08:09:18

回答

2

如果你只是想檢查上面kThreshold加速爲x軸,然後更改:

if (fabsf(acceleration.x) > kThreshold 
     || fabsf(acceleration.y) > kThreshold 
     || fabsf(acceleration.z) > kThreshold) 

到:

if (fabsf(acceleration.x) > kThreshold) 
相關問題