I took a course relating to this sort of thing a few months ago. The topic was "Dynamics of Machines". You can break this problem down and get to the solution, using techniques that have been developed.
Here's a course a found online that will certainly have the technique in it somewhere, I...