Created
March 4, 2014 19:47
-
-
Save nevyn/9354137 to your computer and use it in GitHub Desktop.
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 <CoreGraphics/CGGeometry.h> | |
static inline CGVector TCVectorMultiply(CGVector vector, CGFloat m); | |
static inline CGVector TCVectorMinus(CGPoint p1, CGPoint p2) | |
{ | |
return CGVectorMake( | |
p1.x - p2.x, | |
p1.y - p2.y | |
); | |
} | |
static inline CGFloat TCVectorLength(CGVector vector) | |
{ | |
return sqrtf(vector.dx * vector.dx + vector.dy * vector.dy); | |
} | |
static inline CGVector TCVectorUnit(CGVector vector) | |
{ | |
CGFloat invLen = 1.0 / TCVectorLength(vector); | |
return TCVectorMultiply(vector, invLen); | |
} | |
static inline CGVector TCVectorMultiply(CGVector vector, CGFloat m) | |
{ | |
return CGVectorMake( | |
vector.dx * m, | |
vector.dy * m | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment