def sample(self, N=100):
"""Compute N points of the Bezier curve. Returns two lists, containing the x and y coordinates."""
def p(t, coord):
n = len(coord)
res = 0
for k in range(n):
res += coord[k] * binom(n - 1, k) * t ** k * (1 - t) ** (n - 1 - k)
return (res)
x = [p(t / N, self.controlPoints_x) for t in range(N)]
y = [p(t / N, self.controlPoints_y) for t in range(N)]
return x, y
评论列表
文章目录