how to calculate the distance to objects