New formulas for the Laplacian of distance functions and applications