From 3D accelerometer to tilt angle +180/-180 - Android -


i'm trying obtain tilt angle of device using accelerometer. cheap android phone i'm using not support type_magnetic_field i'm trying use formulas on raw accelerometer values.

i thought had find answer on thread: 3d accelerometer calculate orientation

i left comment on there maybe needs own thread.

the voted answer there is: roll = atan2(y, z) * 180/m_pi; pitch = atan2(-x, sqrt(yy + zz)) * 180/m_pi;

at first worked great until increased pitch towards 90 degrees while keeping other axis steady. passed 70 degrees of pitch, roll surged , time @ 90 degrees of pitch, roll indicated on 100 degrees of tilt , kept progressing 180 kept moving pitch past 90 degree limit.

the workaround found far , it's not solution me change roll formula to:

atan2(y, sqrt(xx + zz)) * 180/m_pi;

with formula, roll angle behaves regardless of pitch range restricted +90/-90 degrees instead of +180/-180 need.

any ideas on how modify formula allow range of 180 , address pitch problem?


Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -