2014-01-15 96 views
-3

我想轉換度數據加速度。 但我不知道代碼(目標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 

我怎樣才能獲得學位?

謝謝

+0

似乎與XCode沒有關係。看起來更像是一個數學問題,而不是Objective-C的知識。 – Larme

+0

可以,我會使用函數「atan2(),」不,但我可以正確實施它,你知道,請幫我嗎? – user3119558

回答

1

加速度計測量線性加速度,而不是角度旋轉。這聽起來像你想要陀螺儀數據(偏航,俯仰和滾轉)而不是加速計數據。查看CMDeviceMotion類的文檔。它提供了沿着3個軸的旋轉速率。

+0

對不起但我不想!我想用Z軸加速度計來測量它以度數給出的數值,lika是一個跳動水平... – user3119558

+0

@ user3119558'CMAcceleration'在'g'中,'CMRotationRate'在'radians'。你需要哪一個?你有沒有讀過類參考? – Desdenova

+0

好吧,但如果我讀tha acc數據,我想知道設備的傾斜度的軸.. – user3119558