当前位置: 首页>>代码示例>>Python>>正文


Python Polygon.getVertex方法代码示例

本文整理汇总了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) }")
#.........这里部分代码省略.........
开发者ID:micheniverse,项目名称:141labs,代码行数:103,代码来源:testpolygon.py


注:本文中的polygon.Polygon.getVertex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。