Make Swift Assume Degrees for Trigonometry Calculations

后端 未结 7 2438
抹茶落季
抹茶落季 2020-12-06 14:01

Is it possible to change a setting, property, etc in Swift for iOS so that it assumes degrees for trigonometry calculations rather than radians?

For example si

7条回答
  •  南方客
    南方客 (楼主)
    2020-12-06 14:29

    There's no setting or property to change the built-in trigonometric functions. You should just work strictly in radians if you want to simplify your expressions, or define your own sindeg, cosdeg, etc.

    Each of the floating-point types has a built-in static member named pi whose value is the best approximation to π. For example: Double.pi, Float.pi, CGFloat.pi.

    Also, sin 90˚ is 1, not 0.

提交回复
热议问题