Skip to content

Instantly share code, notes, and snippets.

View tomalrussell's full-sized avatar

Tom Russell tomalrussell

  • University of Oxford
  • Oxford / London
  • X @tlrss
View GitHub Profile
@urschrei
urschrei / hexgrid.py
Last active May 4, 2022 11:57
Python Hexgrid
import math
def calculate_polygons(startx, starty, endx, endy, radius):
"""
Calculate a grid of hexagon coordinates of the given radius
given lower-left and upper-right coordinates
Returns a list of lists containing 6 tuples of x, y point coordinates
These can be used to construct valid regular hexagonal polygons