Hexagons.jl icon indicating copy to clipboard operation
Hexagons.jl copied to clipboard

Origin-center grids by default; fix a type conversion; update tests

Open evanfields opened this issue 4 years ago • 1 comments

  • Update the tests to ensure some basic behavior. The test coverage is still quite minimal, but nonetheless expanded relative to master. And I think all the behavior tested for should be uncontroversial.
  • Set the default x and y offset for center to be 0, not 1. This means that the zero index hexagon (e.g. HexagonCubic(0, 0, 0)) will be centered at the xy origin. This should fix both https://github.com/GiovineItalia/Hexagons.jl/issues/13 and https://github.com/GiovineItalia/Gadfly.jl/issues/1497 .
  • Fix axial to cubic conversion. The current master has
function convert(::Type{HexagonCubic}, hex::HexagonAxial)
    HexagonCubic(hex.q, hex.r, -hex.q - hex.r)
end

compare to Amit Patel's reference:

function axial_to_cube(hex):
    var x = hex.q
    var z = hex.r
    var y = -x-z
    return Cube(x, y, z)

i.e. the -q-r term should become the cubic y (second argument), but current master puts this term in cubic z.

evanfields avatar Nov 17 '20 19:11 evanfields

@bjarthur apologies for the pestering tag but looks like you have merge privileges here and this would fix the downstream Gadfly bug. Let me know if you'd like any changes!

evanfields avatar Apr 04 '21 02:04 evanfields