當前位置: 首頁>>代碼示例>>Python>>正文


Python Polygon.deleteVertex方法代碼示例

本文整理匯總了Python中polygon.Polygon.deleteVertex方法的典型用法代碼示例。如果您正苦於以下問題:Python Polygon.deleteVertex方法的具體用法?Python Polygon.deleteVertex怎麽用?Python Polygon.deleteVertex使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在polygon.Polygon的用法示例。


在下文中一共展示了Polygon.deleteVertex方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: main

# 需要導入模塊: from polygon import Polygon [as 別名]
# 或者: from polygon.Polygon import deleteVertex [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) }")
#.........這裏部分代碼省略.........
開發者ID:micheniverse,項目名稱:141labs,代碼行數:103,代碼來源:testpolygon.py


注:本文中的polygon.Polygon.deleteVertex方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。