Iphone-SDK: accelerometer x, z to 360 degrees?

How can I take the x, z values ​​created by the accelerometer and translate them as values ​​that will represent a point in 360 degrees of rotation of the iphone? (Landscaping) it can be from -2 to 2 (0 for the midpoint), and it can be from 0 to 360 if it represents a value for the entire iphone rotation.

I need this for Landscape game im making what is the best solution in this case?

+3
source share
1 answer

Use the atan2 () function. To get the value in degrees:

#include <math.h>

...

float degrees = atan2(x, y) * 180 / 3.14159;
+4
source

Source: https://habr.com/ru/post/1728530/


All Articles