mixite icon indicating copy to clipboard operation
mixite copied to clipboard

External Bounding Box has incorrect Y value

Open tazdevil78 opened this issue 4 years ago • 1 comments

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 }

tazdevil78 avatar Jan 31 '20 03:01 tazdevil78

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

tazdevil78 avatar Jan 31 '20 03:01 tazdevil78