Simulation of inverse kinematics in Python