2013-05-09 44 views
2

我想要做一個應用程序,如this。所以我在Google搜索G-Force計算,但沒有得到任何結果。請給我一些指導。計算G - iOS中的應用程序

+0

使用加速度計?問題在哪裏? – DrummerB 2013-05-09 10:39:10

+0

謝謝你的回覆。我使用了加速度計// UIAccelerationValue finalVal = sqrt((acceleration.x * acceleration.x)*(acceleration.y * acceleration.y)*(acceleration.z * acceleration.z)); 這是正確的嗎? – user247 2013-05-09 10:43:13

+1

@ user247您正在計算正方形的**產品**,但您需要**總和**。 – 2013-05-09 10:55:01

回答

1

這就像僞。希望你明白了:)

double gForce = sqrt (pow(Accelerometer.XAccel,2) + pow(Accelerometer.YAccel,2) + pow(Accelerometer.ZAccel,2))/9.81; 
+0

謝謝Econa,我總是得到0.00到0.01之間的值。請指導我 – user247 2013-05-09 10:48:03

+0

您不必除以9.81,API已經返回G值。 – DrummerB 2013-05-09 10:48:06

+0

在正常情況下,您應該得到1 G。我現在將寫得更具體。 – Daedelus 2013-05-09 10:50:36