ManevilleF / hexx

Hexagonal tools lib in rust
Apache License 2.0
288 stars 23 forks source link

pointy_rectangle generates confusing results #106

Closed volodalexey closed 1 year ago

volodalexey commented 1 year ago

When I generate rectangle with pointY I see confused results.

To Reproduce Try to generate pointY rectangle with 2 columns and 3 rows:

for hex in shapes::pointy_rectangle([0, 1, 0, 2]) {
    println!("hex ({}, {})", hex.x, hex.y);
}

Actual result:

hex (0, 0)
hex (1, 0)
hex (0, 1)
hex (1, 1)
hex (-1, 2)
hex (0, 2)

As you can see, 3rd row begins with confused numbers -1, 2

Expected behavior According to this link I should see following 3rd row:

hex (0, 2)
hex (1, 2)

Screenshots Or Code snippet Picture from above link: bug

Is this an issue or am I doing something wrong?

ManevilleF commented 1 year ago

Hex uses axial coordinates, not offset ones like you linked. You can convert between coordinate systems if you wish.

The coordinates returned by pointy_rectangle are correct

volodalexey commented 1 year ago

@ManevilleF Thanks! Now I see where is the problem.