def _create_blocks(self, city, size): blocks_count = size - 1 block_size = 96 inital_offset = 50 street_width = 4 half_street_width = street_width / 2.0 triangle_delta = 93 for x in range(blocks_count): for y in range(blocks_count): if x == y: origin = Point(street_width + 1 + x * self.multiplier, half_street_width + y * self.multiplier, 0) vertices = [ Point(0, 0, 0), Point(triangle_delta, 0, 0), Point(triangle_delta, triangle_delta, 0) ] block = Block(origin, vertices) city.add_block(block) origin = Point(half_street_width + x * self.multiplier, street_width + 1 + y * self.multiplier, 0) vertices = [ Point(0, 0, 0), Point(0, triangle_delta, 0), Point(triangle_delta, triangle_delta, 0) ] block = Block(origin, vertices) city.add_block(block) elif x + y == blocks_count - 1: origin = Point(half_street_width + x * self.multiplier, half_street_width + y * self.multiplier, 0) vertices = [ Point(0, 0, 0), Point(triangle_delta, 0, 0), Point(0, triangle_delta, 0) ] block = Block(origin, vertices) city.add_block(block) origin = Point( (x + 1) * self.multiplier - half_street_width, street_width + 1 + y * self.multiplier, 0) vertices = [ Point(0, 0, 0), Point(0, triangle_delta, 0), Point(-triangle_delta, triangle_delta, 0) ] block = Block(origin, vertices) city.add_block(block) else: origin = Point(inital_offset + x * self.multiplier, inital_offset + y * self.multiplier, 0) block = Block.square(origin, block_size) city.add_block(block)
def test_bounding_box_with_one_point_block_not_centered_at_0_0(self): origin = Point(34, 68) block = Block.square(origin, 0) self.assertEqual(block.bounding_box(), BoundingBox(origin, origin + Point(0, 0, 0.15)))