Skip to content

Instantly share code, notes, and snippets.

@loganwright
Created March 10, 2015 13:20
Show Gist options
  • Save loganwright/2c9eb6305d7ea1ac1346 to your computer and use it in GitHub Desktop.
Save loganwright/2c9eb6305d7ea1ac1346 to your computer and use it in GitHub Desktop.
Geometry
@import UIKit;
CGFloat degreesToRadians(CGFloat degrees);
CGFloat distanceBetweenDegrees(CGFloat min, CGFloat max);
CGPoint pointOnArc(CGPoint center, CGFloat radius, CGFloat angleInDegrees);
#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