Created
December 11, 2011 21:09
-
-
Save gf3/1462758 to your computer and use it in GitHub Desktop.
This file contains 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
# ### Point.angleForCircle( origin, point ) -> Number | |
# | |
# * **origin** ( `Point` ): Origin of circle. | |
# * **point** ( `Point` ): Point to find angle of. | |
# | |
# Get the angle (in degrees) of a point for a given origin of a circle. | |
Point.angleForCircle = (origin, point) -> | |
x = origin.x - point.x | |
y = origin.y - point.y | |
r = Math.sqrt Math.pow(x, 2) + Math.pow(y, 2) | |
if y < 0 and x > 0 | |
Raphael.deg Math.acos x / r | |
if x < 0 and y > 0 | |
Raphael.deg Math.asin y / r | |
else | |
Raphael.deg Math.atan y / x | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment