So I’m working on a personal project, and Android air-mouse app. However this is a math question, not a programming question.
What I need to do is get the phone’s acceleration along the x,y,z axis separately. If it’s not accelerating along an axis I need 0 (or as close as I can get when accounting for noise). I have a 3 axis accelerometer reporting acceleration in meters/second, and orientation data along each axis in radians to work with.
For example if I accelerate the phone up at 4m/s I’d like to get the result of 4m/s on the z axis, but x, and y are 0. If I accelerate the phone up at 2 m/s, and to the right at 2 m/s I’d like to get the result x,z =2, and y = 0. Simple, but here’s where it ties my head in knots, AKA the math part.
Gravity is constantly accelerating my phone, and since I can’t make gravity stop that crap, I need to correct for it to get true acceleration relative to the ground. This means that my phone on it’s back. at rest, has an acceleration of z=9.8m/s, x,y = 0. If I tilt it .5 radians on the y axis, while still at rest, it reports something like 4.5 m/s on the y axis, and 8.1 m/s on the z axis.
I’m thinking if I can use the orientation to calculate what gravity should be on each axis then I can subtract it from the accelerometer readings to get true acceleration.
My first question is am I approaching this problem from the right angle:)? Is there a simpler approach to this? I’m thinking probably no.
My second, and third questions are if I’m on the right track then I’m thinking I could simplify the problem to that of a bike rolling down a hill, is this correct? If so The steeper the hill the faster it goes, but was is the math for putting numbers on “faster”? In other words how do I calculate gravitational acceleration down an incline?