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


Python Circle.set_position方法代码示例

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


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

示例1: test_overlap

# 需要导入模块: from circle import Circle [as 别名]
# 或者: from circle.Circle import set_position [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

示例2: test_circle_distance_from_frame

# 需要导入模块: from circle import Circle [as 别名]
# 或者: from circle.Circle import set_position [as 别名]
 def test_circle_distance_from_frame(self):
     '''
     Test overlap between circles and frame.
     '''
     new_circle = Circle(20)
     new_circle.set_position(160, 160)
     self.assertAlmostEqual(200 - math.sqrt(2)*20 - 20,
                            new_circle.get_distance_from_frame(200), 2) 
     new_circle.set_position(420, 180)
     self.assertAlmostEqual(-60, new_circle.get_distance_from_frame(200), 2)
     new_circle.set_position(180 + 1 / math.sqrt(2) * 180, 
                             180 + 1 / math.sqrt(2) * 180)
     self.assertAlmostEqual(0, new_circle.get_distance_from_frame(200), 2)
开发者ID:msimberg,项目名称:packman,代码行数:15,代码来源:shapetest.py


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