def offset(self, distance):
"""Create another Line `distance` from this one."""
(x1, y1), (x2, y2) = self
dx = x2 - x1
dy = y2 - y1
hyp = math.hypot(dx, dy)
offx = dy / hyp * distance
offy = -dx / hyp * distance
return Line(Point(x1 + offx, y1 + offy), Point(x2 + offx, y2 + offy))
评论列表
文章目录