May be someone faced with programming/analysis of kinematic schemes?
That's something like this:

Somehow you need to describe the leverage of their relationship, the movable and stationary of serinity — and then "click here" and see how it goes.
Interested in the General principles of the description of algorithms may ready open-source libraries.
Now I don't quite know even how to approach a problem. And, I suspect, to dig yourself and melee will be incredibly long.