Distances in 2D rectangular coordinates