I've found another method that I'm gonna try to get working. Because the one I posted above will only work if the leg consist of two parts. I might want to use more.

Check this out: http://freespace.virgin.net/hugo.elias/models/m_ik.htm

Yet again, I understand the concept but I don't remember shit when it comes to math... How do I calculate the force vector? And how do I calculate the dot product?