Beispiel #1
0
 def test_get_intersection_area_same_as_piece_if_fully_submerged(self):
     board = Board(Polygon([[0, 0], [0, 1000], [1000, 1000], [1000, 0]]),
                   [0, 0])
     piece = PolygonPiece(Polygon([[0, 0], [100, 100], [100, 0]]), [50, 50])
     actual_area = PolygonIntersector().intersection_area(
         board.get_points_in_plane(), piece.get_points_in_plane())
     self.assertEqual(piece.get_polygon().area(), actual_area)
Beispiel #2
0
 def test_intersection_half_of_square(self):
     board = Board(Polygon([[0, 0], [100, 100], [100, 0]]), [0, 0])
     piece = PolygonPiece(Polygon([[0, 0], [0, 100], [100, 100], [100, 0]]),
                          [0, 0])
     actual_area = PolygonIntersector().intersection_area(
         board.get_points_in_plane(), piece.get_points_in_plane())
     self.assertEqual(piece.get_polygon().area() / 2, actual_area)
Beispiel #3
0
 def test_polygon_used(self):
     polygon = Polygon([[0, 0], [0, 10], [10, 0], [10, 10]])
     piece = PolygonPiece(polygon, [1, 2])
     self.assertEqual(polygon, piece.get_polygon())