Add tangent() function
This commit is contained in:
parent
d2774f151d
commit
3cad4f27af
|
@ -62,6 +62,15 @@ def dotproduct(v1, v2):
|
||||||
def circlepoint(r, a):
|
def circlepoint(r, a):
|
||||||
return (r * math.cos(a), r * math.sin(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):
|
def rotm(angle):
|
||||||
"Rotation matrix"
|
"Rotation matrix"
|
||||||
return [[math.cos(angle), -math.sin(angle), 0],
|
return [[math.cos(angle), -math.sin(angle), 0],
|
||||||
|
|
Loading…
Reference in New Issue