本文整理汇总了Python中UM.Math.Polygon.Polygon.mirror方法的典型用法代码示例。如果您正苦于以下问题:Python Polygon.mirror方法的具体用法?Python Polygon.mirror怎么用?Python Polygon.mirror使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UM.Math.Polygon.Polygon
的用法示例。
在下文中一共展示了Polygon.mirror方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_mirror
# 需要导入模块: from UM.Math.Polygon import Polygon [as 别名]
# 或者: from UM.Math.Polygon.Polygon import mirror [as 别名]
def test_mirror(self, data):
polygon = Polygon(numpy.array(data["points"], numpy.float32)) #Create a polygon with the specified points.
polygon.mirror(data["axis_point"], data["axis_direction"]) #Mirror over the specified axis.
points = polygon.getPoints()
assert len(points) == len(data["points"]) #Must have the same amount of vertices.
for point_index in range(len(points)):
assert len(points[point_index]) == len(data["answer"][point_index]) #Same dimensionality (2).
for dimension in range(len(points[point_index])):
assert Float.fuzzyCompare(points[point_index][dimension], data["answer"][point_index][dimension]) #All points must be equal.
示例2: test_mirrorDiagonal
# 需要导入模块: from UM.Math.Polygon import Polygon [as 别名]
# 或者: from UM.Math.Polygon.Polygon import mirror [as 别名]
def test_mirrorDiagonal(self):
p = Polygon(numpy.array([ #Make a triangle.
[0.0, 0.0],
[2.0, 0.0],
[1.0, 2.0]
], numpy.float32))
p.mirror([0, 4], [1, 1]) #Mirror over the diagonal axis. The diagonal axis also has an offset.
self.assertEqual(len(p), 3)
self.assertEqual(p[0], [-4.0, 4.0])
self.assertEqual(p[1], [-4.0, 6.0])
self.assertEqual(p[2], [-2.0, 5.0])
示例3: test_mirrorHorizontalFar
# 需要导入模块: from UM.Math.Polygon import Polygon [as 别名]
# 或者: from UM.Math.Polygon.Polygon import mirror [as 别名]
def test_mirrorHorizontalFar(self):
p = Polygon(numpy.array([ #Make a triangle.
[0.0, 0.0],
[2.0, 0.0],
[1.0, 2.0]
], numpy.float32))
p.mirror([10, 0], [0, 1]) #Mirror over the vertical axis with an offset.
self.assertEqual(len(p), 3)
self.assertEqual(p[0], [20.0, 0.0])
self.assertEqual(p[1], [18.0, 0.0])
self.assertEqual(p[2], [19.0, 2.0])
示例4: test_mirrorVertical
# 需要导入模块: from UM.Math.Polygon import Polygon [as 别名]
# 或者: from UM.Math.Polygon.Polygon import mirror [as 别名]
def test_mirrorVertical(self):
p = Polygon(numpy.array([ #Make a triangle.
[0.0, 0.0],
[2.0, 0.0],
[1.0, 2.0]
], numpy.float32))
p.mirror([0, 0], [1, 0]) #Mirror over the horizontal axis.
self.assertEqual(len(p), 3)
self.assertEqual(p[0], [0.0, 0.0])
self.assertEqual(p[1], [2.0, 0.0])
self.assertEqual(p[2], [1.0, -2.0])
示例5: test_mirrorEmpty
# 需要导入模块: from UM.Math.Polygon import Polygon [as 别名]
# 或者: from UM.Math.Polygon.Polygon import mirror [as 别名]
def test_mirrorEmpty(self):
p = Polygon(numpy.array([], numpy.float32)) #Empty polygon.
p.mirror([0, 0], [1, 0]) #Mirror over the horizontal axis.
self.assertEqual(len(p), 0)
示例6: test_mirrorSingleVertex
# 需要导入模块: from UM.Math.Polygon import Polygon [as 别名]
# 或者: from UM.Math.Polygon.Polygon import mirror [as 别名]
def test_mirrorSingleVertex(self):
p = Polygon(numpy.array([[10.0, 0.0]], numpy.float32)) #Single vertex.
p.mirror([0, 0], [1, 0]) #Mirror over the horizontal axis.
self.assertEqual(len(p), 1)
self.assertEqual(p[0], [-10.0, 0.0])