flins.support.hexmath package

Submodules

flins.support.hexmath.axial module

Grid-scale computing. Axial coordinates.

Hexagonal axial coordinate helper functions, assuming pointy side up.

flins.support.hexmath.axial.to_cart(q, r)[source]

Convert axial coordinates into cartesian coordinates

flins.support.hexmath.axial.to_cube(q, r)[source]

Convert axial coordinates to cube coordinates

flins.support.hexmath.cube module

Cubic coordinate helper functions assuming pointy side up.

This draws heavily from the excellent reference:

https://www.redblobgames.com/grids/hexagons/

flins.support.hexmath.cube.closest(i, j, k, points)[source]

Which point (in a list) is closest to a single passed point?

flins.support.hexmath.cube.distance(i_1, j_1, k_1, i_2, j_2, k_2)[source]

Distance between two hexagons in cube coordinates

flins.support.hexmath.cube.neighbors(i, j, k)[source]

Give me a list of neighboring hexagon locations

flins.support.hexmath.cube.rotate_about_center(i, j, k, n_steps)[source]

Rotate the coordinate i,j,k about the 0,0,0 center by n_steps

Each step is one 60 degree rotation to the right. Negative steps are 60 degree rotations to the left.

flins.support.hexmath.cube.to_axial(i, j, k)[source]

Convert cube coordinates to axial coordinates

flins.support.hexmath.cube.to_cart(i, j, k)[source]

Convert cube coordinates to cartesian

flins.support.hexmath.cube.to_offset(i, j, k)[source]

Convert cube coordinates to offset coordinates, odd rows shifted by +1/2 col

flins.support.hexmath.cube.validate(i, j, k)[source]

Is this a valid cube coordinate?

flins.support.hexmath.cube.within_radius(i, j, k, n, original=(0, 0, 0))[source]

Is this new location within a radius from an original (default origin)

flins.support.hexmath.offset module

Grid-scale computing. Offset coordinates.

Hexagonal offset coordinate helper functions, assuming pointy side up.

flins.support.hexmath.offset.to_cart(col, row)[source]

Convert offset coordinates (odd row shifted +1/2 col), into Cartesian coordinates. NOTE: This produces an output rotated by 60deg from that of axial.to_cart

flins.support.hexmath.offset.to_cube(col, row)[source]

Convert offset coordinates to cube coordinates

Module contents