Calculates distance between two points