Created
March 10, 2015 13:20
-
-
Save loganwright/2c9eb6305d7ea1ac1346 to your computer and use it in GitHub Desktop.
Geometry
This file contains hidden or 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
@import UIKit; | |
CGFloat degreesToRadians(CGFloat degrees); | |
CGFloat distanceBetweenDegrees(CGFloat min, CGFloat max); | |
CGPoint pointOnArc(CGPoint center, CGFloat radius, CGFloat angleInDegrees); |
This file contains hidden or 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
#import "Geometry.h" | |
CGFloat degreesToRadians(CGFloat degrees) { | |
return degrees * M_PI / 180.0; | |
} | |
CGFloat distanceBetweenDegrees(CGFloat min, CGFloat max) { | |
int degrees = abs((int)min - (int)max) % 360; | |
return degrees; | |
} | |
CGPoint pointOnArc(CGPoint center, CGFloat radius, CGFloat angleInDegrees) { | |
CGFloat radians = degreesToRadians(angleInDegrees); | |
CGFloat x = radius * cos(radians) + center.x; | |
CGFloat y = radius * sin(radians) + center.y; | |
return CGPointMake(x, y); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment