Map 2D coordinates to a 1D variable.

Implement converting an (x, y) pair to a one-dimensional distance.
Map 1D variable to 2D coordinates.

Converts distance to an (x, y) pair.