Skip to content

Instantly share code, notes, and snippets.

@rlabbe
Created February 17, 2015 19:11
Show Gist options
  • Save rlabbe/a19ebb657276fa36c5d5 to your computer and use it in GitHub Desktop.
Save rlabbe/a19ebb657276fa36c5d5 to your computer and use it in GitHub Desktop.
def triangle_angles(p0, p1, p2):
A = p1 - p0
B = p2 - p1
C = p0 - p2
angles = []
for e1, e2 in ((A,-B), (B,-C), (C,-A)):
num = np.dot(e1, e2)
denom = np.linalg.norm(e1) * np.linalg.norm(e2)
angles.append(np.arccos(num/denom))
return angles
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment