Given a polygon in the $x-y$ plane, what is the simplest formula for expanding the polygon so that all sides lie on a grid?
The image below demonstrates the problem I am trying to solve. The filled in line is the original polygon, while the outer line shows the expected outcome.
My best idea so far is something along these lines:
$1$. Pick a starting point (let's say $A$ in the image)
$2.$ Snap this point to the grid ($AA$ in the image - I'm not sure how to do this exactly)
$3.$ Determine which is the longer direction between $AB$ (here, it's the $y$ direction)
$4.$ Calculate when the $Y$ direction intersects the $Y$ axis at point $AA$. Mark point $BB$ in the grid BELOW this.
$5.$ ... And that's why I'm asking for help....
I'm coming at this from a programming perspective, but I think a math perspective will produce much better results.