Nonsmooth dynamics approach to model collisions in multibody systems