add the gradient of the distance