Last active
August 29, 2015 13:56
-
-
Save r3econ/9137844 to your computer and use it in GitHub Desktop.
Degrees to radians conversion.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CGFloat DegreesToRadians(CGFloat degrees) | |
{ | |
return degrees * M_PI / 180; | |
}; | |
CGFloat RadiansToDegrees(CGFloat radians) | |
{ | |
return radians * 180 / M_PI; | |
}; | |
CGFloat DistanceBetweenTwoPoints(CGPoint pointA, CGPoint pointB) | |
{ | |
CGFloat dx = pointB.x - pointA.x; | |
CGFloat dy = pointB.y - pointA.y; | |
return sqrt(dx*dx + dy*dy); | |
}; | |
double AngleBetweenThreePoints(CGPoint pointA, CGPoint pointB, CGPoint pointC) | |
{ | |
CGFloat a = pointB.x - pointA.x; | |
CGFloat b = pointB.y - pointA.y; | |
CGFloat c = pointB.x - pointC.x; | |
CGFloat d = pointB.y - pointC.y; | |
CGFloat atanA = atan2(a, b); | |
CGFloat atanB = atan2(c, d); | |
return atanB - atanA; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment