Using Grobner Bases to Generate Efficient Kinematic Solutions for the Dynamic Simulation of Multi-loop Mechanisms