Calculating 2-D and 3-D Distances Between Points