Monday, March 10, 2008

Orientation to begin again

Okay, I have the math and an example in MAX/MSP that uses the iPhone to detect the iPhone's orientation. The example and the math was from Liubo Borissov and many thanks to him. I don't have an iPhone but I will connect MAX to my Arduino. In good news for my wallet, I only need one accelerometer. The examples I was reading were only for accelerometers with two axises. The accelerometers I have are three axis accelerometers. That is very good so I can free up room in the element's vessel and inputs into the Arduino. The math works something like this. I form a vector from the origin to the change in gravity (static - dynamic). This is done from subtracting the dynamic x,y,z from the static x,y,z. From there I can create orientation from this vector by calculating the angles. So the vector value would be x0, y0, z0. I take the arc cosine of y0 divided by the length of the vector. Also the arc tangent of x0 divided by z0. From this I should get pitch and roll. I will put up the code and explain it more there. The static x,y,z are the threshold of the accelerometer standing still. Dynamic x,y,z would be anything outside that threshold.

0 Comments:

Post a Comment

<< Home