views:

871

answers:

2

I have a 3 axis accelerometer(any mobile phone) but I can't find any good formulas to interpret the data that's coming from it. No matter what I do the movements are jerky/insensitive. I read that I also need Euler angle or Rotation Matrix?

I will appreciate any good materials for reading...

+3  A: 

Are you trying to build a 3D mouse program for the iPhone? (There are a few out there already.) Can you describe exactly what user motion you want to correspond to what action?

The easiest thing to do is to get the pitch of the device by taking the arc cosine of the dot product of the acceleration vector with (0, 0, 1000).

If you are trying to implement a device in which sliding the iPhone back and forth through space moves a pointer back and forth on a screen, that would be difficult because it would require relatively violent hand motions to produce accelerations that are large compared to gravitational acceleration. MEMS accelerometers like the one in the iPhone are great at measuring the direction of gravity but pretty poor at measuring actual accelerations of the device itself.

If you describe your application a little, I might be able to give you more specific pointers.

There are a number of different ways of representing spatial rotations, but quaternions are very popular in the game programming community. A Google search gives you some links to some primers. The GamaSutra one is a good place to start.

http://www.gamasutra.com/features/19980703/quaternions_01.htm
http://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation
http://www.flipcode.com/documents/matrfaq.html
Leo
Try Core Location?
Leo
What it's designed for and what you use it for are two different things.
Leo
+4  A: 

For what it's worth, some accelerometer samples from Apple:

  • AccelerometerGraph sample application graphs the motion of the device. It demonstrates how to use the UIAccelerometer class and how to use Quartz2D and Core Animation to provide a high performance graph view. It also demonstrates a low-pass filter that you can use to isolate the effects of gravity, and a high-pass filter that you can use to remove the effects of gravity.
  • GLGravity sample application demonstrates how to use the UIAccelerometer class in combination with OpenGL rendering. It shows how to extract the gravity vector from the accelerometer values using a basic low-pass filter, and how to build an OpenGL transformation matrix from it.

And if you're aiming for something like the tilt control from Wolfenstein 3D, you could go read the source code for that.... :-)

Sixten Otto