Question

How is it possible to take the x,z values produced by the accelerometer and translate it as values that will represent a point in 360 degrees of the iphone rotation? (LANDSCAPED) it can be -2 to 2 (0 for the middle point) and it can be 0 to 360, as long as it represents a value for the whole iphone rotation.

I need it for a Landscape game im making what is the best solution in that case?

Was it helpful?

Solution

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

#include <math.h>

...

float degrees = atan2(x, y) * 180 / 3.14159;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top