以度为单位转换数据加速度计

时间:2014-01-15 14:28:01

标签: ios accelerometer

我想要转换de数据加速器的程度。 但我不太清楚代码(目标c)。有人帮我意识到这一点? 我需要看到程度而不是加速度计数据! 我有这个:

#import "APLGraphViewController.h"
#import "APLGraphView.h"
#import "APLAppDelegate.h"
#import "math.h"
@interface APLGraphViewController ()
@property (weak, nonatomic) IBOutlet UILabel *xLabel;
@property (weak, nonatomic) IBOutlet UILabel *yLabel;
@property (weak, nonatomic) IBOutlet UILabel *zLabel;
@property (weak, nonatomic) IBOutlet UISlider *updateIntervalSlider;
@end
@implementation APLGraphViewController
#pragma mark - View lifecycle
-(void)viewDidLoad
{
    [super viewDidLoad];
     self.updateIntervalSlider.value = 0.0f;
}
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self startUpdatesWithSliderValue:(int)(self.updateIntervalSlider.value * 100)];
}
- (void)viewDidDisappear:(BOOL)animated
{
    [super viewDidDisappear:animated];
    [self stopUpdates];
}
 #pragma mark - Responding to events
- (IBAction)takeSliderValueFrom:(UISlider *)sender
{
    [self startUpdatesWithSliderValue:(int)(sender.value * 100)];
}
- (void)setLabelValueX:(double)x y:(double)y z:(double)z
{
    self.xLabel.text = [NSString stringWithFormat:@"x: %f", x];
    self.yLabel.text = [NSString stringWithFormat:@"y: %f", y];
    self.zLabel.text = [NSString stringWithFormat:@"z: %f", z];
}
- (void)setLabelValueRoll:(double)roll pitch:(double)pitch yaw:(double)yaw
{
    self.xLabel.text = [NSString stringWithFormat:@"roll: %f", roll];
    self.yLabel.text = [NSString stringWithFormat:@"pitch: %f", pitch];
    self.zLabel.text = [NSString stringWithFormat:@"yaw: %f", yaw];
}
#pragma mark - Update methods stub implementations
- (void)startUpdatesWithSliderValue:(int)sliderValue
{
    return;
}
- (void)stopUpdates
{
    return;
} 
@end

我如何获得学位?

感谢

1 个答案:

答案 0 :(得分:1)

加速度计测量线性加速度,而不是角度旋转。听起来像你想要陀螺仪数据(偏航,俯仰和滚转)而不是加速度计数据。看一下CMDeviceMotion类的文档。它给出了沿3轴的旋转速率。