Using Python in the script editor, I am currently moving my skeleton using motion capture data. For times when the data jumps to an inaccurate place or when there are gaps in the data, I want to use Inverse Kinematics logic to know where to move the bone.

Specifically, I would prefer to know the coordinate locations of where the bone head and bone tail would end up if inverse kinematics is applied and we know the locations and rotations of the bone's parent and its child. Is there a formula or Python code to calculate this?

edit: the reason why I can't manually set up inverse kinematics to do this is because when combined with my method of moving the armature with the mocap data, it totally freaks out so I want to do it case by case manually for a specific frame and bone when I need it

  • $\begingroup$ You're using python, so why not use a python module. Is this question about Blender? Otherwise it may be smart to ask in cs.stackexchange.com. $\endgroup$
    – Leander
    Apr 15, 2020 at 14:42
  • $\begingroup$ @Leander Yes, this Python script is to run in blender and the armature is in Blender's 3D viewport with animation. Interesting module that you've linked, I'll definitely check it out but I'm trying to minimize dependencies so I wonder if there is a formula to find out the IK positions manually based on parent and child bone pos and rot $\endgroup$
    – Jackie
    Apr 15, 2020 at 14:54
  • $\begingroup$ What Blender-specific problem are you struggling with? "Is there a formula to calculate inverse kinematics?" has nothing to do with Blender. Maybe you could make this question more Blender-related. $\endgroup$
    – Leander
    Apr 15, 2020 at 15:24
  • $\begingroup$ @Leander right.. well the question is more geared towards the scripting capabilities blender has, as I'm trying to drive a blender skeleton animation from the python script using blender specific commands in the script. I want to know the formula blender uses to solve the ik to see if I can integrate it, and see if there is a simpler explanation/sample code of it that anyone has $\endgroup$
    – Jackie
    Apr 15, 2020 at 15:29

1 Answer 1


Many parts of Blender are accessible through the python API, like bones. Constraint logic is only accessible as it is via the interface, meaning you can setup constraints with python and bake their transforms.

Here you can see Blender's code structure.


Inverse kinematics API, abstracting the itasc and iksolver modules. Note that while this system supports multiple inverse-kinematics solvers there is no plug-in system exposed from a user perspective.

You are probably interested in the iksolver_plugin.c file, which contains the code to calculate IK.

If you want to implement it from scratch, I recommend an iterative approximation.

Since you are mainly interested in arms and legs though, simple trigonometry will suffice as an IK system with only one joint only has "one" (or no) solution.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .