本文整理汇总了Python中Path.Path.isConnected方法的典型用法代码示例。如果您正苦于以下问题:Python Path.isConnected方法的具体用法?Python Path.isConnected怎么用?Python Path.isConnected使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Path.Path
的用法示例。
在下文中一共展示了Path.isConnected方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testValid
# 需要导入模块: from Path import Path [as 别名]
# 或者: from Path.Path import isConnected [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())
示例2: jarviswalk
# 需要导入模块: from Path import Path [as 别名]
# 或者: from Path.Path import isConnected [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
示例3: testDisconnected
# 需要导入模块: from Path import Path [as 别名]
# 或者: from Path.Path import isConnected [as 别名]
def testDisconnected(self):
disconnectedPath = Path()
disconnectedPath.addPoint(self.p0)
disconnectedPath.addPoint(self.p1)
disconnectedPath.addPoint(self.p2)
self.assertFalse(disconnectedPath.isConnected())
示例4: testEmpty
# 需要导入模块: from Path import Path [as 别名]
# 或者: from Path.Path import isConnected [as 别名]
def testEmpty(self):
emptyPath = Path()
self.assertFalse(emptyPath.isConnected())
self.assertEquals(emptyPath.length(), 0)