Iphone-SDK: accelerometer x,z to 360 degrees?
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 (开发者_StackOverflow社区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?
Use the atan2() function. To get a value in degrees:
#include <math.h>
...
float degrees = atan2(x, y) * 180 / 3.14159;
精彩评论