Made Distance algorithms for 1, 2, or 3 dimensions