For anyone who is interested, I've been researching this problem for the last few days and discovered that it's more complicated than a single calculation. It's a system of equations, but some of them are inequalities, e.g. the non-penetration constraints, and may or may not bound the solution...