The 3D fcc (face-centered-cubic) lattice, which has the same packing ratio as the 3D hexagonal close packed lattice, has the following 12 vectors connecting each vertex with its neighbors: 


$(1,-1,0), (-1,1,0), (-1,-1,0), (1,1,0)$


$(1,0,-1), (-1,0,1), (-1,0,-1), (1,0,1)$


$(0,1,-1), (0,-1,1), (0,-1,-1), (0,1,1)$


If I have an arbitrary point $(x,y,z)$, I need a piecewise formula for finding which vertex in the lattice is the closest to it. I do not want an "algorithmic" solution, i.e. calculating distances to many vertices or computing voronoi cells. 


Thank You!



Closest vertex in a 3D fcc lattice
Recall that the face-centred cubic lattice comprises all vectors in $\mathbb{Z}^3$ whose coordinate sum is even.


Let $(x, y, z) \in \mathbb{R}^3$. For each coordinate, define the *discrepancy* to be the distance to the closest integer, i.e. $\delta(x) := |x - \lfloor x \rceil |$.


For the two coordinates with lowest discrepancy, replace them with their nearest integers. For the coordinate with highest discrepancy, either replace it with the nearest integer or the second-nearest integer, depending on which one has the correct parity to make the coordinate sum even.


