One Quickie


Converting degrees to radians and back (Graphics->General)
Most programming interfaces that deal with angles talk in radians (2 pi radians in a circle), like CGAffineTransformRotate. I personally think better in degrees (360 degrees in a circle).

Convert degrees to radians by multiplying by 180 / pi.

Convert radians to degrees by multiplying by pi / 180

I have a couple of #defines I stick into a common header for projects that need it;

#define BWDegToRad(d)   ((d) * M_PI / 180.0)
#define BWRadToDeg(r)   ((r) * 180 / M_PI)



borkware home | products | miniblog | rants | quickies | cocoaheads
Advanced Mac OS X Programming book

webmonster@borkware.com