def arc_to(self, x1, y1):
x0, y0 = self.get_current_point()
dx, dy = x1 - x0, y1 - y0
if abs(dx) < 1e-8:
self.line_to(x1, y1)
else:
center = 0.5 * (x0 + x1) + 0.5 * (y0 + y1) * dy / dx
theta0 = cmath.phase(x0 - center + y0*1j)
theta1 = cmath.phase(x1 - center + y1*1j)
r = abs(x0 - center + y0*1j)
# we must ensure that the arc ends at (x1, y1)
if x0 < x1:
self.arc_negative(center, 0, r, theta0, theta1)
else:
self.arc(center, 0, r, theta0, theta1)
评论列表
文章目录