Explain the principle of virtual work and its application in determining the equilibrium of rigid bodies subjected to external forces and moments.