Skip to content

Instantly share code, notes, and snippets.

@bittz
Last active April 16, 2024 10:27
Show Gist options
  • Save bittz/a618c95edd78de5d59d3 to your computer and use it in GitHub Desktop.
Save bittz/a618c95edd78de5d59d3 to your computer and use it in GitHub Desktop.
Convert degrees to radians / radians to degrees in Swift.
import CoreGraphics
func degreesToRadians(degrees: CGFloat) -> CGFloat {
return degrees * CGFloat(M_PI) / 180
}
func radiansToDegress(radians: CGFloat) -> CGFloat {
return radians * 180 / CGFloat(M_PI)
}
@guru-teja
Copy link

Is there any limits to input of these functions?

@fewlinesofcode
Copy link

@guru-teja any float number

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment