This tutorial explains how inverse kinematics work, and it’s definitely worth a read: 2 Joint 2 Limb Inverse Kinematics