def normal_direction(p, p1, p2):
"""Compute normal direction at p in the segment p1->p->p2."""
e1 = (p1 - p) / norm(p1 - p)
e2 = Snake.rotate(e1, np.pi / 2.)
x = np.dot(p2 - p, e1)
y = np.dot(p2 - p, e2)
theta = np.arctan2(y, x)
return Snake.rotate(e1, theta / 2.)
评论列表
文章目录