本文整理汇总了Python中Path.Path.addPoint方法的典型用法代码示例。如果您正苦于以下问题:Python Path.addPoint方法的具体用法?Python Path.addPoint怎么用?Python Path.addPoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Path.Path
的用法示例。
在下文中一共展示了Path.addPoint方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from Path import Path [as 别名]
# 或者: from Path.Path import addPoint [as 别名]
def __init__(s):
#Dane:
win=Window("Point",0,0,600,600)
master=win.getMaster()
desk=Desk(master)
C=desk.getC()
p1=Point(100,100)
p2=Point(200,100)
p3=Point(200,200)
p4=Point(100,200)
desk.addPoint(p1)
desk.addPoint(p2)
desk.addPoint(p3)
desk.addPoint(p4)
path=Path()
path.addPoint(p1)
path.addPoint(p2)
path.addPoint(p3)
path.addPoint(p4)
desk.addPath(path)
win.loop()
示例2: testValid
# 需要导入模块: from Path import Path [as 别名]
# 或者: from Path.Path import addPoint [as 别名]
def testValid(self):
validPath = Path()
validPath.addPoint(self.p0)
validPath.addPoint(self.p1)
validPath.addPoint(self.p2)
validPath.addPoint(self.p0)
self.assertTrue(validPath.isConnected())
示例3: testLength
# 需要导入模块: from Path import Path [as 别名]
# 或者: from Path.Path import addPoint [as 别名]
def testLength(self):
p = Path()
p.addPoint(self.p0)
p.addPoint(self.p1)
l0 = Line(self.p0, self.p1)
l1 = Line(self.p1, self.p2)
self.assertEquals(p.length(), l0.length())
p.addPoint(self.p2)
self.assertEquals(p.length(), l0.length() + l1.length())
示例4: jarviswalk
# 需要导入模块: from Path import Path [as 别名]
# 或者: from Path.Path import addPoint [as 别名]
def jarviswalk(points):
"""Implementation of Jarvis Walk aka Gift wrapping algorithm.
Based on the article http://en.wikipedia.org/wiki/Gift_wrapping_algorithm
"""
hull = Path()
xsorted = sorted(points, key=lambda point: point.x)
hull.addPoint(xsorted[0])
while True:
nextP = None
maxLinearPoint = None
maxLinearDistance = -1.0
possiblePoints = filter(lambda p: p not in hull.points[1:], xsorted)
for p in possiblePoints:
if p is hull.points[-1]: continue
line = Line(hull.points[-1], p)
allright, localMaxLinear, localMaxLinearDistance = allrightAndMaxLinearPoint(line, xsorted)
if allright:
nextP = p
break
if localMaxLinear is not None and localMaxLinearDistance != -1.0 and localMaxLinearDistance > maxLinearDistance:
maxLinearPoint, maxLinearDistance = (localMaxLinear, localMaxLinearDistance)
assert(nextP is not None or (maxLinearPoint is not None and maxLinearDistance > 0.0))
if nextP is not None:
hull.addPoint(nextP)
else:
hull.addPoint(maxLinearPoint)
if hull.isConnected():
break
return hull
示例5: testDisconnected
# 需要导入模块: from Path import Path [as 别名]
# 或者: from Path.Path import addPoint [as 别名]
def testDisconnected(self):
disconnectedPath = Path()
disconnectedPath.addPoint(self.p0)
disconnectedPath.addPoint(self.p1)
disconnectedPath.addPoint(self.p2)
self.assertFalse(disconnectedPath.isConnected())