Skip to content

Instantly share code, notes, and snippets.

@odrobnik
Last active November 14, 2015 09:48
Show Gist options
  • Save odrobnik/f1eef9c02488be0e9827 to your computer and use it in GitHub Desktop.
Save odrobnik/f1eef9c02488be0e9827 to your computer and use it in GitHub Desktop.
Smallest Turning Angle in Radians - CW rotations position, CCW rotations negative
import Darwin
let π = CGFloat(M_PI)
let _2π = CGFloat(2.0 * π)
extension CGFloat
{
func angleDeltaForShortestRotation(#toAngle: CGFloat) -> CGFloat
{
return remainder(toAngle - self + _2π, _2π)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment