A General Formulation for the Stiffness Matrix of Parallel Mechanisms