A Smooth Analytical Formulation of Collision Detection and Rigid Body Dynamics With Contact