您好朋友,我需要將弧度值轉換爲度數。下面的代碼是讓弧度將弧度轉換爲IOS中的度數
UIView *view = [self view];
CGPoint center = CGPointMake(CGRectGetMidX([view bounds]), CGRectGetMidY([view bounds]));
CGPoint currentTouchPoint = [touch locationInView:view];
CGPoint previousTouchPoint = [touch previousLocationInView:view];
CGFloat angleInRadians = atan2f(currentTouchPoint.y - center.y, currentTouchPoint.x - center.x) - atan2f(previousTouchPoint.y - center.y, previousTouchPoint.x - center.x);
這是在touchesMoved完成:(NSSet中*)觸及withEvent:方法(*的UIEvent)事件。但我需要將這個angleInRadians CGFloat值轉換成像45.0 deg程度。我怎樣才能做到這一點。
我曾嘗試以下方法,但我不能找到解決辦法:
#define RADIANS_TO_DEGREES(radians) ((radians) * (180.0/M_PI))
CGFloat RadiansToDegrees(CGFloat radians) { return radians * 180/M_PI; };
#define RADIANS_TO_DEGREES(弧度)((弧度)*(180.0/M_PI))的作品,只是試過了 – AndyOS