def test_coordinates_pointy(self): grid = Grid(OrientationPointy, Point(10, 20), Point(20, 10)) hex = grid.hex_at(Point(666, 666)) self.assertPointEqual(Point(650.85880, 665.00000), grid.hex_center(hex), 0.00001) corners = grid.hex_corners(hex) expected_corners = [ Point(668.17930, 670.00000), Point(650.85880, 675.00000), Point(633.53829, 670.00000), Point(633.53829, 660.00000), Point(650.85880, 655.00000), Point(668.17930, 660.00000), ] for expected_point, point in zip(expected_corners, corners): self.assertPointEqual(expected_point, point, 0.00001)
def test_coordinates_flat(self): grid = Grid(OrientationFlat, Point(10, 20), Point(20, 10)) hex = grid.hex_at(Point(666, 666)) self.assertPointEqual(Point(670.00000, 660.85880), grid.hex_center(hex), 0.00001) corners = grid.hex_corners(hex) expected_corners = [ Point(690.00000, 660.85880), Point(680.00000, 669.51905), Point(660.00000, 669.51905), Point(650.00000, 660.85880), Point(660.00000, 652.19854), Point(680.00000, 652.19854), ] for expected_point, point in zip(expected_corners, corners): self.assertPointEqual(expected_point, point, 0.00001)