Beispiel #1
0
 def test_convex_hull_deterministic(self):
     length = None
     for i in range(100):
         points = [
             Vec2d(189, 442),
             Vec2d(189, 378),
             Vec2d(125, 378),
             Vec2d(125, 442),
             Vec2d(189, 350),
             Vec2d(189, 286),
             Vec2d(125, 286),
             Vec2d(125, 350),
             Vec2d(167, 346),
             Vec2d(167, 282),
             Vec2d(103, 282),
             Vec2d(103, 346),
             Vec2d(133, 376),
             Vec2d(133, 312),
             Vec2d(69, 312),
             Vec2d(69, 376),
             Vec2d(133, 442),
             Vec2d(133, 378),
             Vec2d(69, 378),
             Vec2d(69, 442)
         ]
         num_points = len(generate_convex_hull(points))
         if length:
             self.assertEquals(num_points, length)
         else:
             length = num_points
Beispiel #2
0
 def test_convex_hull_deterministic(self):
     length = None
     for i in range(100):
         points = [Vec2d(189, 442), Vec2d(189, 378), Vec2d(125, 378), Vec2d(125, 442), Vec2d(189, 350), Vec2d(189, 286), Vec2d(125, 286), Vec2d(125, 350), Vec2d(167, 346), Vec2d(167, 282), Vec2d(103, 282), Vec2d(103, 346), Vec2d(133, 376), Vec2d(133, 312), Vec2d(69, 312), Vec2d(69, 376), Vec2d(133, 442), Vec2d(133, 378), Vec2d(69, 378), Vec2d(69, 442)]
         num_points = len(generate_convex_hull(points))
         if length:
             self.assertEquals(num_points, length)
         else:
             length = num_points
Beispiel #3
0
    def compute_c_polygon(self, agent):
        agent_points = copy_points_list(agent.get_points())

        all_points = []
        for point in self.get_points():
            for agent_point in agent_points:
                all_points.append(point - agent_point)

        c_polygon_points = generate_convex_hull(all_points)
        return Polygon(c_polygon_points)
Beispiel #4
0
    def compute_c_polygon(self, agent):
        agent_points = copy_points_list(agent.get_points())

        all_points = []
        for point in self.get_points():
            for agent_point in agent_points:
                all_points.append(point - agent_point)

        c_polygon_points = generate_convex_hull(all_points)
        return Polygon(c_polygon_points)
Beispiel #5
0
 def test_convex_hull(self):
     points = [
         Vec2d(1, 0),
         Vec2d(0, 0),
         Vec2d(0.5, 0.5),
         Vec2d(0, 1),
         Vec2d(1, 1)
     ]
     self.assertEqual(
         generate_convex_hull(points),
         [Vec2d(1, 1), Vec2d(1, 0),
          Vec2d(0, 0), Vec2d(0, 1)])
Beispiel #6
0
 def test_broken_hull_history3(self):
     points = [
         Vec2d(579, 518),
         Vec2d(500, 512),
         Vec2d(528, 501),
         Vec2d(573, 477),
         Vec2d(510, 541),
         Vec2d(533, 565),
         Vec2d(542, 578),
         Vec2d(516, 437),
         Vec2d(575, 401),
         Vec2d(519, 470)
     ]
     hull_points = generate_convex_hull(points)
     self.assertEqual(len(hull_points), 6)
Beispiel #7
0
 def test_broken_hull_history1(self):
     points = [
         Vec2d(60, 130),
         Vec2d(65, 83),
         Vec2d(105, 74),
         Vec2d(141, 136),
         Vec2d(79, 123)
     ]
     hull_points = generate_convex_hull(points)
     self.assertEqual(
         hull_points,
         [Vec2d(141, 136),
          Vec2d(105, 74),
          Vec2d(65, 83),
          Vec2d(60, 130)])
Beispiel #8
0
 def test_broken_hull_history2(self):
     points = [
         Vec2d(105, 150),
         Vec2d(113, 134),
         Vec2d(84, 111),
         Vec2d(143, 137),
         Vec2d(136, 97),
         Vec2d(138, 60)
     ]
     hull_points = generate_convex_hull(points)
     self.assertEqual(
         hull_points,
         [Vec2d(105, 150),
          Vec2d(143, 137),
          Vec2d(138, 60),
          Vec2d(84, 111)])
Beispiel #9
0
 def test_convex_hull(self):
     points = [Vec2d(1, 0), Vec2d(0, 0), Vec2d(0.5, 0.5),Vec2d(0, 1), Vec2d(1, 1)]
     self.assertEqual(generate_convex_hull(points), [Vec2d(1, 1), Vec2d(1, 0), Vec2d(0, 0), Vec2d(0, 1)])
Beispiel #10
0
 def test_broken_hull_history3(self):
     points = [Vec2d(579, 518), Vec2d(500, 512), Vec2d(528, 501), Vec2d(573, 477), Vec2d(510, 541), Vec2d(533, 565), Vec2d(542, 578), Vec2d(516, 437), Vec2d(575, 401), Vec2d(519, 470)]
     hull_points = generate_convex_hull(points)
     self.assertEqual(len(hull_points), 6)
Beispiel #11
0
 def test_broken_hull_history2(self):
     points = [Vec2d(105, 150), Vec2d(113, 134), Vec2d(84, 111), Vec2d(143, 137), Vec2d(136, 97), Vec2d(138, 60)]
     hull_points = generate_convex_hull(points)
     self.assertEqual(hull_points, [Vec2d(105, 150), Vec2d(143, 137), Vec2d(138, 60), Vec2d(84, 111)])
Beispiel #12
0
 def test_broken_hull_history1(self):
     points = [Vec2d(60, 130), Vec2d(65, 83), Vec2d(105, 74), Vec2d(141, 136), Vec2d(79, 123)]
     hull_points = generate_convex_hull(points)
     self.assertEqual(hull_points, [Vec2d(141, 136), Vec2d(105, 74), Vec2d(65, 83), Vec2d(60, 130)])