Fork me on GitHub

角度与弧度的转换

iphone里面角度和弧度经常要转换

比如旋转一个图片,你要用到CGAffineTransformMakeRotation,他就需要一个弧度值做完输入。

下面是两个宏,来实现互转

1。弧度转角度
 #define RADIANS_TO_DEGREES(radians) ((radians) * (180.0 / M_PI))

NSLog(@"Output radians as degrees: %f", RADIANS_TO_DEGREES(0.785398));

 

2。角度转弧度
 // Degrees to radians
#define DEGREES_TO_RADIANS(angle) ((angle) / 180.0 * M_PI)
 
NSLog(@"Output degrees as radians: %f", DEGREES_TO_RADIANS(45));
M_PI 定义在Math.h内,其值为3.14159265358979323846264338327950288

posted on 2012-02-12 11:10  pengyingh  阅读(960)  评论(0编辑  收藏  举报

导航