Open tazdevil78 opened 4 years ago
Height of a pointy top hex of radius is 2*138 = 276. When the centerY of a hex is 138 the y value of the bounding box should be zero. This is not the value returned by getExternalBoundingBox() .
`` @Test public void yValue() { HexagonalGridBuilder builder = new HexagonalGridBuilder() .setGridHeight(3) .setGridWidth(3) .setGridLayout(HexagonalGridLayout.HEXAGONAL) .setOrientation(HexagonOrientation.POINTY_TOP) .setRadius(138); HexagonalGrid grid = builder.build(); Hexagon hex = (Hexagon) grid.getHexagons().iterator().next(); Rectangle rect = hex.getExternalBoundingBox(); double ctrY = hex.getCenterY(); // 138 double ht = 2*138; assertEquals(ctrY - ht/2, rect.getY(), 0.01f); // expected 0, actual 207 }
In the pointy orientation, a hexagon has width w = sqrt(3) size and height h = 2 size. https://www.redblobgames.com/grids/hexagons/#size-and-spacing
Height of a pointy top hex of radius is 2*138 = 276. When the centerY of a hex is 138 the y value of the bounding box should be zero. This is not the value returned by getExternalBoundingBox() .
``
@Test public void yValue() { HexagonalGridBuilder builder = new HexagonalGridBuilder() .setGridHeight(3) .setGridWidth(3) .setGridLayout(HexagonalGridLayout.HEXAGONAL) .setOrientation(HexagonOrientation.POINTY_TOP) .setRadius(138); HexagonalGrid grid = builder.build(); Hexagon hex = (Hexagon) grid.getHexagons().iterator().next(); Rectangle rect = hex.getExternalBoundingBox(); double ctrY = hex.getCenterY(); // 138 double ht = 2*138; assertEquals(ctrY - ht/2, rect.getY(), 0.01f); // expected 0, actual 207 }