ios - How can I convert from degrees to radians? -
i trying convert obj-c
code swift
code don't know equivalent of code should ?
#define degrees_to_radians(degrees)((m_pi * degrees)/180)
i googled , found this
but don't understand how convert in swift in case?
xcode 9 • swift 4
extension binaryinteger { var degreestoradians: cgfloat { return cgfloat(int(self)) * .pi / 180 } } extension floatingpoint { var degreestoradians: self { return self * .pi / 180 } var radianstodegrees: self { return self * 180 / .pi } }
playground
45.degreestoradians // 0.785398163397448 int(45).degreestoradians // 0.785398163397448 int8(45).degreestoradians // 0.785398163397448 int16(45).degreestoradians // 0.785398163397448 int32(45).degreestoradians // 0.785398163397448 int64(45).degreestoradians // 0.785398163397448 uint(45).degreestoradians // 0.785398163397448 uint8(45).degreestoradians // 0.785398163397448 uint16(45).degreestoradians // 0.785398163397448 uint32(45).degreestoradians // 0.785398163397448 uint64(45).degreestoradians // 0.785398163397448 double(45).degreestoradians // 0.7853981633974483 cgfloat(45).degreestoradians // 0.785398163397448 float(45).degreestoradians // 0.7853981 float80(45).degreestoradians // 0.785398163397448278999
Comments
Post a Comment