Add tangent() function

This commit is contained in:
Florian Festi 2017-02-18 18:53:01 +01:00
parent d2774f151d
commit 3cad4f27af
1 changed files with 9 additions and 0 deletions

View File

@ -62,6 +62,15 @@ def dotproduct(v1, v2):
def circlepoint(r, a):
return (r * math.cos(a), r * math.sin(a))
def tangent(x, y, r):
"angle and length of a tangent to a circle at x,y with raduis r"
l1 = vlength((x, y))
a1 = math.atan2(y, x)
a2 = math.asin(r / l1)
l2 = math.cos(a2) * l1
return (a1+a2, l2)
def rotm(angle):
"Rotation matrix"
return [[math.cos(angle), -math.sin(angle), 0],