Created
November 29, 2013 05:58
-
-
Save yoshiki/7702073 to your computer and use it in GitHub Desktop.
2つの線の間の角度を求める関数。
originを頂点としたinitialとcurrentに引かれた線の間の角度を求められる。
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
+ (CGFloat)angleWithOrigin:(CGPoint)origin initial:(CGPoint)initial current:(CGPoint)current { | |
CGFloat initialAngle = atan2(initial.y - origin.y, initial.x - origin.x); | |
CGFloat currentAngle = atan2(current.y - origin.y, current.x - origin.x); | |
return currentAngle - initialAngle; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment