Skip to content

Instantly share code, notes, and snippets.

@skynet
Created December 19, 2018 18:19
Show Gist options
  • Save skynet/66b16975bebc834a4b0f530dc7cb7566 to your computer and use it in GitHub Desktop.
Save skynet/66b16975bebc834a4b0f530dc7cb7566 to your computer and use it in GitHub Desktop.
Calculate the Tangent Line of a Circle
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]
}
@skynet
Copy link
Author

skynet commented Dec 19, 2018

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment