本文整理匯總了Python中polygon.Polygon.insertVertex方法的典型用法代碼示例。如果您正苦於以下問題:Python Polygon.insertVertex方法的具體用法?Python Polygon.insertVertex怎麽用?Python Polygon.insertVertex使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類polygon.Polygon
的用法示例。
在下文中一共展示了Polygon.insertVertex方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: main
# 需要導入模塊: from polygon import Polygon [as 別名]
# 或者: from polygon.Polygon import insertVertex [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) }")
#.........這裏部分代碼省略.........