Skip to content

Instantly share code, notes, and snippets.

@yoshiki
Created November 29, 2013 05:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yoshiki/7702073 to your computer and use it in GitHub Desktop.
Save yoshiki/7702073 to your computer and use it in GitHub Desktop.
2つの線の間の角度を求める関数。 originを頂点としたinitialとcurrentに引かれた線の間の角度を求められる。
+ (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