Exemple #1
0
 def new_room_verts(self, branch_room, branch_wall, num_verts):
     WALL_MIN = 100
     WALL_MAX = 500
     end = Vec2d(branch_room.verts[branch_wall])
     startidx = (branch_wall + 1) % len(branch_room.verts)
     start = Vec2d(branch_room.verts[startidx])
     gap = (start - end).get_length()
     room_radius = uniform(max(WALL_MIN, gap / 2), WALL_MAX)
     num_verts = int(max(4, 4 * room_radius / WALL_MIN / 2))
     verts = irregular(start, end, room_radius, num_verts)
     return verts
Exemple #2
0
 def test_irregular(self):
     start = Vec2d(3, -4)
     face = Vec2d(-6, 0)
     radius = 5
     # irregular poly's circle center is at (0, 0)
     num_verts = 5
     actual = irregular(start, face, radius, num_verts)
     self.assertEquals(len(actual), 5)
     self.assertEquals(actual[0], Vec2d(+3, -4))
     self.assertEquals(actual[1], Vec2d(-3, -4))
     for point in actual:
         self.assertAlmostEquals(point.get_length_sqrd(), 25.0)
Exemple #3
0
 def test_irregular_impossible(self):
     start = Vec2d(-10, -0)
     face = Vec2d(20, 0)
     radius = 9
     num_verts = 3
     self.assertRaises(lambda: irregular(start, face, radius, num_verts), ValueError)