Howdy all! You found my thread! ^^
I am currently developing a game that uses the accelerometer to determine the angle to set rotation of in-game objects to.
The equation I’m using to get the angle of accelerometer rotation is:
angle = math.atan2(-event.xGravity, event.yGravity)
This works just peachy…until you roll the phone down and the accel X value becomes positive, in which case the rotation goes completely crazy! XD
I’m a pretty visual kinda guy, so here’s an image to help describe the problem

My question is: is there some way to account for the sudden switch in values as you roll the device down, so that rolling the device doesn’t affect the rotation? (or “pitch”, right?)
Maybe a better equation to use…?
We’ve tried all the naive things like throwing in a few math.abs() statements; even tried some brutal quaternion equations for pitch & roll and whatnot - none of them helped ; _ ;
Anyone tackled this problem before? [import]uid: 144339 topic_id: 32258 reply_id: 332258[/import]