Resolution loop and gaussian weights for the distance.