Computes the distance between two points.