0
  • (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration

Using the above method we got an acceleration value of (x and y and z).Now i want to find angle between (x and y) and (y and z) and (z and x).How can i do this?

Can anyone help me ?

Thanks in advance.....

dragon
  • 317
  • 4
  • 18
  • The angles between x and y, y and z, z and x are all 90 degrees. Do you mean the angle between the acceleration vector (what you call acceleration value) and the x, y & z axes? – pheelicks May 11 '10 at 16:10

1 Answers1

2

If your acceleration vector is a = (x, y, z), then the angles between this vector and the three axes are given by:

cos (angleXaxis) = x / sqrt(x^2 + y^2 + z^2)

cos (angleYaxis) = y / sqrt(x^2 + y^2 + z^2)

cos (angleZaxis) = z / sqrt(x^2 + y^2 + z^2)

To get the angles themselves you'll need to use the inverse cos function

Community
  • 1
  • 1
pheelicks
  • 7,461
  • 2
  • 45
  • 50