Metric for the shortest path between two cells of a class I octahedral Goldberg polyhedron. Consider the following class I octahedral Goldberg polyhedron, $GP_{IV}(9,0)$:

Every cell of this polyhedron can be uniquely determined using three coordinates, $x, y, z \in \mathbb{Z}$, such that $\lvert x \rvert + \lvert y \rvert + \lvert z \rvert = 9$. In fact, every class I octahedral Goldberg polyhedron, $GP_{IV}(m, 0)$, is described by the equation
\begin{equation}
\lvert x \rvert + \lvert y \rvert + \lvert z \rvert = m
\end{equation}
where $x, y, z \in \mathbb{Z}$.
The neighbors of a cell are given by the function
\begin{align}
neighbors(x, y, z) = \{ (x^\prime, y^\prime, z^\prime) &\mid x^\prime \in \{x-1, x, x+1\}\\
&\wedge y^\prime \in \{y-1, y, y+1\}\\
&\wedge z^\prime \in \{z-1, z, z+1\}\\
&\wedge (x^\prime, y^\prime, z^\prime) \neq (x, y, z)\\
&\wedge \lvert x^\prime \rvert + \lvert y^\prime \rvert + \lvert z^\prime \rvert = m\}
\end{align}
where $m = \lvert x \rvert + \lvert y \rvert + \lvert z \rvert$.
Now, there are three types of cells:


*

*Six red squares, which are described by the coordinates $(\pm m, 0, 0)$, $(0, \pm m, 0)$, and $(0, 0, \pm m)$.

*Yellow hexagons, which are described by the coordinates $(x, y, 0)$, $(x, 0, y)$, and $(0, y, z)$, where $x, y, z \neq 0$.

*Blue hexagons, which are described by the coordinates $(x, y, z)$ where $x, y, z \neq 0$.


So, what I want is to define a shortest path metric between two coordinates. When one of the coordinates is a square cell, the metric is:
\begin{equation}
d((x, y, z), (x^\prime, y^\prime, z^\prime)) = \begin{cases}
\lvert x - x^\prime \rvert & y, z = 0 \\
\lvert y - y^\prime \rvert & x, z = 0 \\
\lvert z - z^\prime \rvert & x, y = 0
\end{cases}
\end{equation}
However, I can't figure out the other cases. What I do know is that if two cells are in the same triangular face then the metric is
\begin{equation}
d((x, y, z), (x^\prime, y^\prime, z^\prime)) = \max (\lvert x - x^\prime \rvert, \lvert y - y^\prime \rvert, \lvert z - z^\prime \rvert)
\end{equation}
because within a triangle the cells are like a flat hexagonal grid. Unfortunately, the metric seems to be significantly more complex when the cells are in different triangular faces. Any insights on how to determine the other cases will be greatly appreciated.
 A: If you draw the graph of cells with an edge between neighbours, you see that you have 8 triangular grids joined together as the faces of an octahedron. And clearly the shortest path from A to B passes through each face at most once, so you just have to handle 4 cases:


*

*A,B are on the same face (including the boundary): You already did this case.

*A,B are on adjacent faces P,Q: P+Q forms a rhombus triangular grid and clearly the shortest path from A to B stays within P+Q, because any part that strays outside can be reflected inside without changing the length (first reflect into a hemisphere that contains P+Q and then reflect inside P+Q). And so the answer is similar to case 1.

*A,B are on opposite faces P,Q within the same hemisphere (i.e. that touch only at a corner): The shortest path from A to B clearly stays within that hemisphere, because any stray part can be reflected inside. And the first time the path exits P, it ends up in a face adjacent to Q, so case 2 takes over. So you just need to check the two faces adjacent to P that the path can exit into, and in each subcase you have a half-hexagonal triangular grid.

*A,B are on opposite faces P,Q of the octahedron: The shortest path from A to B must exit P into one of 3 adjacent faces. So you just need to check all three of them. Case 3 applies to each of them, and in all 6 resulting subcases you get a triangular grid shaped like this, so it is easy to solve:

  O---O---O
 / \ / \ /
O---O---O


