Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

External Bounding Box has incorrect Y value #59

Open
tazdevil78 opened this issue Jan 31, 2020 · 1 comment
Open

External Bounding Box has incorrect Y value #59

tazdevil78 opened this issue Jan 31, 2020 · 1 comment

Comments

@tazdevil78
Copy link

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
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant