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


Python Rectangle.get_overlap方法代码示例

本文整理汇总了Python中rectangle.Rectangle.get_overlap方法的典型用法代码示例。如果您正苦于以下问题:Python Rectangle.get_overlap方法的具体用法?Python Rectangle.get_overlap怎么用?Python Rectangle.get_overlap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rectangle.Rectangle的用法示例。


在下文中一共展示了Rectangle.get_overlap方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_overlap

# 需要导入模块: from rectangle import Rectangle [as 别名]
# 或者: from rectangle.Rectangle import get_overlap [as 别名]
 def test_overlap(self):
     '''
     Test overlap between circles and rectangles.
     '''
     new_rect1 = Rectangle(100, 100)
     new_rect2 = Rectangle(50, 150, 50, 50)
     circ1 = Circle(25) 
     circ2 = Circle(30, 0, -5)
     self.assertEqual(-50, new_rect1.get_overlap(new_rect2))
     self.assertEqual(new_rect1.get_overlap(new_rect2),
                      new_rect2.get_overlap(new_rect1))
     self.assertEqual(-50, circ1.get_overlap(new_rect1))
     self.assertEqual(circ1.get_overlap(new_rect1),
                      new_rect1.get_overlap(circ1))
     self.assertAlmostEqual(math.sqrt(2)*25 - 25,
                            circ1.get_overlap(new_rect2))
     self.assertEqual(circ1.get_overlap(new_rect2),
                      new_rect2.get_overlap(circ1))
     self.assertEqual(-50, circ1.get_overlap(circ2))
     self.assertEqual(circ1.get_overlap(circ2),
                      circ2.get_overlap(circ1))
     circ1.set_position(80, 50)
     self.assertEqual(-20, circ1.get_overlap(new_rect2))
     self.assertEqual(circ1.get_overlap(new_rect2),
                      new_rect2.get_overlap(circ1))
开发者ID:msimberg,项目名称:packman,代码行数:27,代码来源:shapetest.py


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