Planar Multibody Dynamics: Formulation, Programming and Applications