Created
December 19, 2018 18:19
-
-
Save skynet/66b16975bebc834a4b0f530dc7cb7566 to your computer and use it in GitHub Desktop.
Calculate the Tangent Line of a Circle
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
function tangentLine(M, r, alpha) { | |
T = { | |
x: M.x + Math.cos(alpha) * r, | |
y: M.y + Math.sin(alpha) * r | |
} | |
v = { | |
x: T.y - M.y, | |
y: M.x - T.x | |
} | |
norm = Math.hypot(v.x, v.y) | |
v.x/= norm | |
v.y/= norm | |
return [T, v] | |
} |
Author
skynet
commented
Dec 19, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment