Geometry of Constrained Dynamical Systems