0

知道如何将加速度计数据转换为度数吗?我已经开发了一个加速度计应用程序,我需要获得度数?

  UIAccelerometer *accel = [UIAccelerometer sharedAccelerometer];
     accel.delegate = self;
     accel.updateInterval = 1.0f/50.0f;

- (void)accelerometer:(UIAccelerometer *)acel didAccelerate:(UIAcceleration *)aceler 
    {

          NSLog(@"%f %f %f",aceler.x,aceler.y,aceler.z);

    }

我需要度数?

4

1 回答 1

4

XY 角度的一个简单示例:

- (void)accelerometer:(UIAccelerometer *)acel didAccelerate:(UIAcceleration *)aceler 
{
   // get angle in radians
   float angle = atan2(aceler.x, aceler.y);
   // convert to degrees
   float angleInDegrees = (angle * 180/M_PI);
   NSLog(@"%f degrees",angleInDegrees); 
}
于 2012-09-03T08:12:36.073 回答