Sub topic 4
What Inverse Kinematics Solves
This chapter explains the problem that inverse kinematics (IK) solves, how it differs from forward kinematics (FK), and where each approach fails. It assumes you can create an armature, add bones in Edit Mode, switch between Object, Edit, and Pose Mode, and set basic keyframes. The scripted examples need basic Python.
Prerequisites and Scope
You should already know that a pose bone is the animatable copy of a bone, and that bones in a chain are linked by parenting. If those ideas are unfamiliar, review the earlier chapters on armatures and bone hierarchy first. This chapter does not yet add an IK constraint. It builds the mental model that the next chapters rely on.
The Two Directions of Kinematics
Kinematics describes how a chain of rigid segments moves. A chain such as shoulder, elbow, and wrist has one fixed end (the root) and one free end (the tip). There are two ways to ask where the chain ends up.
- Forward kinematics takes joint rotations as input and produces the tip position as output. You rotate the upper arm, then the forearm, and the hand lands wherever those rotations put it.
- Inverse kinematics takes a desired tip position as input and produces joint rotations as output. You say where the hand should be, and the solver works out how the upper arm and forearm must rotate to get there.
Forward kinematics is a direct calculation. Each joint's rotation is applied down the chain in order, and there is exactly one result. Inverse kinematics runs the calculation backward, and that is harder, because the answer is not unique.
Why the Inverse Problem Is Hard
Consider a two-bone arm with fixed bone lengths. If the target is within reach, the solver must find two joint angles that put the tip on the target. Several things make this ambiguous.
- Multiple solutions. With a bent elbow, the elbow can point up, down, or sideways and the hand still reaches the same point. The tip position does not say which one you want.
- Unreachable targets. If the target is farther than the combined bone lengths, no rotation reaches it. If it is closer than the chain can fold, there may also be no valid pose.
- Extra degrees of freedom. A joint that can rotate on three axes has more freedom than one target position needs. The target fixes the tip's position, not the twist along each bone.
Blender's IK solver resolves these cases with defaults and with settings you control. It does not know your character's anatomy. Later chapters cover the settings that supply this missing information: pole targets for bend direction, and limits and locks for allowed motion.
How Blender Solves It
Blender uses an iterative solver. It does not compute a closed-form answer. Instead it starts from the current pose and repeatedly adjusts joint rotations to move the tip closer to the target, stopping when the tip is close enough or when it reaches an iteration limit. Two consequences follow.
- The result depends on the starting pose. Because the solver nudges the current pose rather than starting fresh, a chain that begins nearly straight can behave differently from one that begins bent.
- A chain that is perfectly straight and aimed directly at its target can be unstable. There is no bend direction to start from, so the solver may flip the joint to either side.
This is why the example rig in this tutorial gives the upper arm a slight bend. The solver needs some initial bend to indicate the preferred direction.
Seeing the Difference in a Rig
The following script builds the two-bone arm used throughout this tutorial. It also creates a separate hand_ik bone, which will become the IK target, and an elbow_pole bone, which will control bend direction in a later chapter. Run it in a new scene with the 3D Viewport active.
import bpy
arm_data = bpy.data.armatures.new("ArmRig")
rig = bpy.data.objects.new("ArmRig", arm_data)
bpy.context.collection.objects.link(rig)
bpy.context.view_layer.objects.active = rig
rig.select_set(True)
bpy.ops.object.mode_set(mode='EDIT')
eb = arm_data.edit_bones
upper = eb.new("upper_arm")
upper.head = (0.0, 0.0, 0.0)
upper.tail = (1.0, 0.1, 0.0) # slight bend so the IK solver has a bend direction
fore = eb.new("forearm")
fore.head = (1.0, 0.1, 0.0)
fore.tail = (2.0, 0.0, 0.0)
fore.parent = upper
fore.use_connect = True
hand_ik = eb.new("hand_ik")
hand_ik.head = (2.0, 0.0, 0.0)
hand_ik.tail = (2.0, 0.0, 0.3)
elbow_pole = eb.new("elbow_pole")
elbow_pole.head = (1.0, 2.0, 0.0)
elbow_pole.tail = (1.0, 2.0, 0.3)
bpy.ops.object.mode_set(mode='POSE')Note that forearm is parented to upper_arm with use_connect = True. The head of the forearm is locked to the tail of the upper arm, so the two bones behave as one chain. The hand_ik and elbow_pole bones have no parent. They are independent controls that the chain will follow or respond to once constraints are added.
To feel the FK side, select upper_arm in Pose Mode and rotate it with R. The forearm and everything past it swing along, and the hand moves as a result. Then rotate forearm to move the hand again. To place the hand at an exact spot, you must adjust both bones, and moving the shoulder later shifts the hand.
FK and IK Compared
Neither method is better in general. Each fits different motion.
| Aspect | FK | IK |
|---|---|---|
| You control | Joint rotations | Tip position |
| Tip follows | Whatever the rotations produce | The target |
| Moving the root | Tip moves with the chain | Tip stays on the target if it can reach |
| Arcs and overlap | Natural, smooth arcs | Can look linear unless you animate the target on arcs |
| Fixed contact | Hard to hold a hand or foot in place | Easy, the target holds the tip |
| Ambiguity | None | Needs pole targets, limits, and locks |
| Typical use | Swinging arms, tails, spines, hair | Planted feet, hands on props, climbing |
A useful rule is to ask whether the tip needs to stay in place while the rest of the body moves. A foot planted on the ground while the hips shift is a strong case for IK. An arm swinging freely during a walk is often easier to animate in FK, because the arc comes from rotating each joint in sequence.
Failure Modes to Expect
Knowing these early helps you recognize them later.
- Overstretching or a fully straight chain. When the target sits at or beyond the chain's reach, the chain straightens. At the exact limit, the solver can become unstable and the joint may pop.
- Flipping. The bend direction changes suddenly as the target crosses a line through the chain. A pole target fixes this.
- Unwanted joint motion. Without limits, an elbow can bend backward, because nothing tells the solver that the joint is a hinge.
- Jitter. If the iteration count is too low or the target is unreachable, the tip may never settle.
Choosing Between FK and IK
Use these criteria when deciding how to pose a limb.
- Does the end of the limb need to stay fixed in world space while the body moves? If yes, prefer IK.
- Is the motion mostly a free swing that follows through in an arc? Prefer FK.
- Do you need exact control over a joint's rotation, such as a wrist twist or a finger curl? Prefer FK for that joint.
- Do you need both? Build a rig that supports both and blend between them. A later chapter covers this with a driver on the IK constraint's influence.
Exercise
A character's foot must stay planted on the floor while the hips move up and down during a squat. Which method fits, and what must the solver be told so the knee does not flip?
Show answer
IK fits, because the foot target stays fixed while the hips move, and the solver adjusts the leg joints to keep the foot on it. The solver also needs a bend direction, which comes from a pole target in front of the knee, and ideally limits so the knee works as a hinge.
Exercise
Why does the example arm give the upper arm bone a slight bend (tail at y = 0.1) instead of making both bones perfectly straight?
Show answer
A perfectly straight chain has no bend direction, so the iterative solver can flip the joint to either side. The slight bend gives the solver an initial direction to follow.