def get_angle_formed_by(p1,p2,p3): # angle formed by three positions in space
# based on code submitted by Paul Sherwood
r1 = distance(p1,p2)
r2 = distance(p2,p3)
r3 = distance(p1,p3)
small = 1.0e-10
if (r1 + r2 - r3) < small:
# This seems to happen occasionally for 180 angles
theta = math.pi
else:
theta = math.acos( (r1*r1 + r2*r2 - r3*r3) / (2.0 * r1*r2) )
return theta;
#------------------------------------------------------------------------------
评论列表
文章目录