Mechanics and cosmology in the medieval and early modern period