我试图实现Cyrus-Beck algorithm来进行线条裁剪。但它不起作用。我找不到问题。。。请帮忙。在
结构:
sign = functools.partial(math.copysign, 1)
mult = lambda a, b: a.x * b.x + a.y * b.y
class Point(object):
def __init__(self, x, y):
self.x = float(x)
self.y = float(y)
class Line(object):
def __init__(self, begin, end):
self.begin = begin
self.end = end
@property
def direction(self):
return Point(self.end.x - self.begin.x, self.end.y - self.begin.y)
@property
def normal(self):
return Point(self.end.y - self.begin.y, self.begin.x - self.end.x)
这是算法和class Polygon
帮我找出代码中的错误。在
目前没有回答
相关问题 更多 >
编程相关推荐