How to convert points to radians in Objective-C?

后端 未结 3 744
深忆病人
深忆病人 2021-01-17 08:13

In my app I\'m using UIBezierPath to draw an arc into a circle. I\'m trying to correlate a number to radians. So let\'s say a user has a certain number of points, and the po

3条回答
  •  臣服心动
    2021-01-17 08:34

    I think what you want is the unit circle. Remember back to trigonometry when you used the unit circle? Same thing will apply here. If you need to get π - in Swift just say let π = CGFloat.pi (hold alt+p for the special character). In Objective-C - I think it's CGFloat π = M_PI;.

    You could go from zero to 2π/3 for the first 1/3, then from 2π/3 to 4π/3, then from 4π/3 to (full circle).

    I should not that I didn't make this graphic - it's from a tutorial on RayWenderlich.com - but it's oriented perfectly for the iOS coordinate system.

提交回复
热议问题