How to calculate horizontal angle from from (Iphone) Accelerometer data.

In summary: You can calculate the angle given the acceleration data by integrating the data. To do this, you need to find the angular velocity and then use that to calculate the angular displacement.
  • #1
Hi All,

Thanks in Advance.Need help on maths related to angular motion.We have a device that returns the acceleration in ax,ay,az for motion along a curve.we are trying to calculate the
angle using these acceleration values and the radius (which is fix in our case).

Below is what we are trying to do with these values.However whatever angles
we are getting from calculation does not match the actual angle.what could
wrong we be doing there. kindly enlighten me.

Is there any other method to calculate the angle given these set of data is
available with us.Calculating angle of rotation from acceleration data[ax,ay,az].

1)Calculate resultant acceleration from ax,ay,az.
Resultant Acceleration = SQRT (ax^2 + ay^2 +az^2) * G; //G = 9806.7 mm/s2;

2) Calculate angular Acceleration
Resultant Acceleration = Radius * Angular acceleration;
Angular acceleration (Alpha) = Radius / Resultant Acceleration ;

3) Angular velocity (omega) = omega zero ( previous) + alpha* time;

4) Angular displacement = Angular velocity *time;

5) Convert angular displacement from radian to degree.
Angle = angular displacement *57.3;

6) Sample Data

ax ay az dt(time difference)
0.018169 -0.036337 -1.144622 0.009766
0.054506 -0.036337 -1.071948 0.009766
-0.109012 -0.054506 -1.199128 0.018311
-0.163517 0.018169 -1.453488 0.009521
-0.163517 -0.036337 -1.398983 0.009033
Physics news on
  • #2
Hmm, I not entirely clear what your doing. As you say the radius is fixed I assume this is some sort of circular motion. In that case I think you're best off double integrating the acceleration data to get displacement then relate the displacement to the angle.
  • #3
Hi Reasonableman,

Thanks for reply and sorry for late reply.We are using Iphone Accelerometer to measure the Range of Motion. We said radius is fixed as the arm/hand of the user will be fixed in our case.

Now regarding the use of double integrating, let me explain what i have understood by this please correct me if i am wrong here

Theta_n = Theta_(n-1) + Omega_(n-1) * t_(n-1) + 0.5 alpha_n*Power(tn, 2);

Theta is angular displacement.

We are doing this still results are not correct. Also shared here is an excel that has values generated for various angles along with the calculation.

Again thanks for your help.


  • Sample
    92.2 KB · Views: 259
  • #4
RaviTiwari, you said Angular acceleration (Alpha) = Radius / Resultant Acceleration , is this right??
if Resultant Acceleration = Radius * Angular acceleration ==> Angular acceleration (Alpha) =Resultant Acceleration/Radius,
despite, the unities are not compatible, so I suggest to calculate the speed by integring the acceleration then use this formula:
angular velocity=speed/radius.
  • #5
Here would be my process. Using your time step and cartesian acceleration measurements, calculate cartesian velocities and change in positions. We now have [tex]dx,dy,dz,\dot{x},\dot{y},\dot{z},\ddot{x},\ddot{y},\ddot{z}[/tex]

From here, you can calculate the spherical trasnlations:
[tex] r = \sqrt{x^2 + y^2 + z^2} [/tex]
[tex] \theta = \tan\left(\frac{y}{x}\right)[/tex]
[tex]\psi = \sin\left(\frac{z}{r}\right)[/tex]
If at any point now you wish to know velocities/accelerations in that coordinate system, you can take derivatives to find velocity
[tex]\dot{r} = \frac{x\dot{x}+y\dot{y}+z\dot{z}}{r}[/tex]
[tex]\dot{\theta} = \frac{x\dot{y}+y\dot{x}}{x^2 + y^2}[/tex]
[tex]\dot{\psi} = \frac{r\dot{z}-z\dot{r}}{r^2\sqrt{1-\left(\frac{z}{r}\right)2}}[/tex]

Similarily, you can derivate that to get accelerations in spherical coordinate systems.
  • #6
Hi RaviTiwari,

I'm an artist trying to build a video installation with an iphone and I need to accomplish a very similar thing: I'll have an iphone moving in a constant pendular motion and I need to determine it's angle/position.

My problem is that the last time I did some real math was back in College in 1996. Did you manage to implement the code to determine the angle based on the iphone accelerometer? If so, would it be possible for you to share the code with me?

Otherwise, does anyone know where I can find a thorough mathematical explanation of what is needed so that I can give a try at understanding it and implementing it?

Thanks in advance,

Related to How to calculate horizontal angle from from (Iphone) Accelerometer data.

1. How do I obtain accelerometer data from my iPhone?

The accelerometer data can be obtained through the built-in sensors on your iPhone, which can be accessed through the settings or a third-party app. Make sure to calibrate the sensors before collecting data to ensure accuracy.

2. What is the formula for calculating horizontal angle from accelerometer data?

The formula for calculating horizontal angle from accelerometer data is: θ = atan2(Ay, Az), where Ay and Az are the y and z-axis acceleration values, respectively.

3. Can I use the accelerometer data directly to calculate the horizontal angle?

No, the accelerometer data needs to be processed and converted into angles using the appropriate formula. This is because the data collected from the accelerometer is in terms of acceleration, not angles.

4. Are there any limitations when using the accelerometer data to calculate horizontal angle?

Yes, the accuracy of the calculated horizontal angle may be affected by external factors such as device orientation, movement, and sensor error. It is important to calibrate and properly position the device for more accurate results.

5. Are there any alternative methods for calculating horizontal angle from accelerometer data?

Yes, there are alternative methods such as using gyroscope data in conjunction with accelerometer data, or using a digital compass. These methods may provide more accurate results, but may also require additional hardware or processing.

Similar threads

  • Introductory Physics Homework Help
  • General Engineering