Least constraint approach to the extraction of internal motions from molecular dynamics trajectories of flexible macromolecules