本文整理汇总了Python中polygon.Polygon.getVertex方法的典型用法代码示例。如果您正苦于以下问题:Python Polygon.getVertex方法的具体用法?Python Polygon.getVertex怎么用?Python Polygon.getVertex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类polygon.Polygon
的用法示例。
在下文中一共展示了Polygon.getVertex方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from polygon import Polygon [as 别名]
# 或者: from polygon.Polygon import getVertex [as 别名]
def main():
poly = Polygon(Point(0, 0), Point(0, 1), Point(1, 1))
print("Attemptine to print polygon.")
print("Note: if this doesn't work you have a problem in either \
numVertices or in getVertex\n")
print("Result should be: { (0,0) (0,1) (1,1) }")
print("Result is: ", end="")
printPoly(poly)
print("")
print("Testing insertVertex with (1,0) and 5")
print("Result should be: False")
print("Result is: ",poly.insertVertex(Point(1, 0), 5))
print("Result should be: { (0,0) (0,1) (1,1) }")
print("Result is: ", end="")
printPoly(poly)
print("")
print("Testing insertVertex with (1,0) and -1")
print("Result should be: False")
print("Result is: ",poly.insertVertex(Point(1,0),-1))
print("Result should be: { (0,0) (0,1) (1,1) }")
print("Result is: ", end="")
printPoly(poly)
print("")
print("Testing insertVertex with (2,-1) and 3")
print("Result should be: True")
print("Result is: ",poly.insertVertex(Point(2, -1), 3))
print("Result should be: { (2,-1) (0,0) (0,1) (1,1) }")
print("Result is: ", end="")
printPoly(poly)
print("")
print("Testing insertVertex with (1,0) and 3")
print("Result should be: True")
print("Result is: ",poly.insertVertex(Point(1, 0), 3))
print("Printing resulting polygon:")
print("Result should be: { (2,-1) (0,0) (0,1) (1,1) (1,0) }")
print("Result is: ", end="")
printPoly(poly)
print("")
print("Testing findVertex with (1,1)")
print("Result should be: 3")
print("Result is: ",poly.findVertex(Point(1, 1)),"\n")
print("Testing findVertex with (1,2)")
print("Result should be: False")
print("Result is: ",poly.findVertex(Point(1, 2)),"\n")
print("Testing getVertex with -1")
print("Result should be: False")
print("Result is: ",poly.getVertex(-1),"\n")
print("Testing getVertex with 5")
print("Result should be: False")
print("Result is: ",poly.getVertex(5),"\n")
print("Testing deleteVertex with -1")
print("Result should be: False")
print("Result is: ",poly.deleteVertex(-1))
print("Result should be: { (2,-1) (0,0) (0,1) (1,1) (1,0) }")
print("Result is: ", end="")
printPoly(poly)
print("")
print("Testing deleteVertex with 6")
print("Result should be: False")
print("Result is: ",poly.deleteVertex(6))
print("Result should be: { (2,-1) (0,0) (0,1) (1,1) (1,0) }")
print("Result is: ", end="")
printPoly(poly)
print("")
print("Testing deleteVertex with 0")
print("Result should be: True")
print("Result is: ",poly.deleteVertex(0))
print("Printing resulting polygon:")
print("Result should be: { (0,0) (0,1) (1,1) (1,0) }")
print("Result is: ", end="")
printPoly(poly)
print("")
print("Testing perimeter")
print("Result should be: 4.0")
print("Result is: ",poly.perimeter(),"\n")
print("Testing deleteVertex with 2 and then 1 ")
print("Result should be: True")
print("Result is: ",poly.deleteVertex(2))
print("Printing resulting polygon:")
print("Result should be: { (0,0) (0,1) (1,0) }")
print("Result is: ", end="")
printPoly(poly)
print("Result should be: False")
print("Result is: ",poly.deleteVertex(1))
print("Printing resulting polygon:")
print("Result should be: { (0,0) (0,1) (1,0) }")
#.........这里部分代码省略.........