I have a problem where I need to represent hexagons on a tile by their centre (which I refer to as a node) in my graph. Given a tile of hexagons, how can I find if two hexagons x
and y
are connected?
(source: domathtogether.com)
The following would work on hexagons with their position in two dimensional space, however I want to represent their position by an integer coordinate (0, 1), (0, 2), (0, 3), (1, 1), (1, 2), (1, 3) etc
.
if (n1->getPoint().getEuclideanDistance(n2->getPoint()) < diameter)
{
// The two are connected.
}