Sub topic 8
Controlling Bend Direction with Pole Targets
This chapter assumes you can add bones in Edit Mode, switch to Pose Mode, and add an IK constraint with a target bone and a chain length. The Python examples use bpy and need basic scripting familiarity. They continue the arm rig from the earlier chapters: upper_arm, forearm, hand_ik, and elbow_pole.
Why an IK chain needs a bend hint
An IK solver is given a target position for the end of a chain. For a two-bone arm, the elbow can sit anywhere on a circle around the line from shoulder to hand. Every point on that circle gives a valid solution. Without extra information, the solver picks whichever one is closest to the current pose. That choice can change suddenly when you move the target, and the elbow then snaps to the other side.
A pole target gives the solver a second reference point. The solver rotates the whole chain around the line from the chain root to the IK target until the bend plane points at the pole. The elbow now has one stable answer.
The pole target and the pole angle
The IK constraint has two settings for this.
- Pole Target is an object, or an armature plus a bone name, that the bend should face.
- Pole Angle is a rotation offset around the root-to-target axis, applied after the chain aims at the pole.
The pole angle exists because the solver aims a particular local axis of the chain at the pole. That axis depends on how each bone was rolled in Edit Mode. The result is often a fixed offset, commonly 90 or -90 degrees, between where the elbow points and where the pole is. You do not calculate this offset. You adjust it until the elbow faces the pole.
The script below adds the constraint from the topic's code example:
import math
import bpy
rig = bpy.data.objects["ArmRig"]
forearm = rig.pose.bones["forearm"]
ik = forearm.constraints.new('IK')
ik.target = rig
ik.subtarget = "hand_ik"
ik.pole_target = rig
ik.pole_subtarget = "elbow_pole"
ik.pole_angle = math.radians(-90.0) # adjust until the elbow bends toward the pole
ik.chain_count = 2 # forearm and upper_arm; 0 would use the whole chainSeveral points about this script:
- The constraint sits on
forearm, the last bone in the chain. IK always lives on the tip bone. targetandpole_targetare both the armature object. Thesubtargetandpole_subtargetstrings name the bones inside it.pole_angleis in radians in Python. The UI shows degrees.chain_count = 2limits the solve toforearmandupper_arm. A value of 0 would run IK up to the root of the whole hierarchy.
Where to place the pole bone
Place the pole in the direction you want the joint to point, and keep it well away from the chain.
- Put the elbow pole behind the arm and out to the side, so the elbow points backward and outward.
- Put a knee pole in front of the leg, so the knee points forward.
- Keep the pole roughly in the same plane as the bend, at about the distance of the limb length.
- Do not parent the pole to the IK-controlled bone or to anything inside the chain. A pole that moves with the chain creates a dependency loop, and the result will shake or lag.
In the example rig, elbow_pole is at (1.0, 2.0, 0.0). The upper arm points along +X with a slight +Y bend. The pole is on the +Y side of the elbow, so the elbow bends toward +Y.
Finding the right pole angle
The pole angle is easiest to find by trial. Use this routine.
- Set the pole angle to 0.
- Look at the chain. If the chain already bends toward the pole, you are done.
- If it bends sideways, try 90 or -90 degrees.
- If it bends directly away, try 180 degrees.
- Fine tune in small steps once the direction is close.
When you do this, the chain often looks twisted for a moment after you set the target. That is normal. The bones rotate around the root-to-target axis, so a wrong angle shows as the whole arm rolled to one side.
A table of the usual results helps when you are searching:
| Symptom with pole angle 0 | Try next |
|---|---|
| Elbow bends 90 degrees to the side | 90 or -90 degrees |
| Elbow bends away from the pole | 180 degrees |
| Elbow bends close, but slightly off | Adjust by 5 to 15 degrees |
| Chain twists along its length | Check bone roll, then retry the angle |
The right value depends on bone roll. If you rebuild the bones with a different roll, the pole angle needs to change too. Setting roll consistently in Edit Mode (for example, with Recalculate Roll on the whole limb) makes the angle the same for the left and right arms. Mirrored limbs often need opposite signs, such as -90 on one side and 90 on the other.
How the pole works with chain length
The pole acts on the chain the IK constraint covers. If chain_count is 2, the pole rotates both bones around the shoulder-to-hand axis. If the chain is longer, for example a shoulder, upper arm, and forearm, the pole turns the entire chain from its root. In that case the root of the chain is the first bone included in the count, not the armature root.
Be careful with a chain that is longer than you need. A third bone in the chain, such as a clavicle, will rotate to help reach the target. Set the chain count to the bones that should actually move.
Pole target behavior at the edges
A pole target works well in most poses, but there are limits.
- Pole in line with the chain. If the pole lies exactly on the line from root to target, the bend plane is undefined. The elbow can flip when the target crosses that line.
- Straight limb. When the arm is fully extended, the bend is not visible. Bend direction only shows once the limb starts to fold. A slight bend in the rest pose, like the
0.1offset in the example, gives the solver a bend to work from. - Pole too close to the root. The angle between the pole and the root-to-target axis changes quickly. Small pole movements then cause large elbow swings.
- Target moved past the pole's side. If the IK target moves around behind the root, the pole's relative direction flips and the elbow can pop.
The most reliable fix for popping is to keep the pole far enough from the chain and to make sure the target does not cross the pole's line during the animation.
Verifying the pole from a script
To check what is set on a constraint, read it back from the pose bone. This is useful when you are comparing left and right arms.
import math
import bpy
rig = bpy.data.objects["ArmRig"]
ik = rig.pose.bones["forearm"].constraints["IK"]
print("target:", ik.target.name, ik.subtarget)
print("pole:", ik.pole_target.name, ik.pole_subtarget)
print("pole angle (degrees):", round(math.degrees(ik.pole_angle), 1))
print("chain count:", ik.chain_count)If pole_subtarget prints an empty string, the pole target is the whole armature object rather than a bone. The pole then points to the object's origin, which is rarely what you want.
Common errors
- The pole has no effect. Check that
pole_targetis set and thatpole_subtargetnames an existing bone. A misspelled bone name is silently ignored. - The chain looks rolled to one side. The pole angle is wrong. Adjust it in 90-degree steps first.
- The elbow jitters while animating. The pole is parented inside the chain, or the pole sits on the root-to-target line.
- Left and right arms behave differently. The bone rolls differ, or the mirrored pole angle has the wrong sign.
- The whole body twists.
chain_countis 0 or too large, so IK runs through the spine and pelvis.
Exercise
An IK arm bends sideways instead of toward the pole bone. The pole angle is 0 and the chain count is 2. What do you change first, and why?
Show answer
Change the pole angle, trying 90 or -90 degrees first. The solver aims a local bone axis at the pole, and the bone roll sets which axis that is, so a fixed offset is usually needed. If 90 and -90 both fail, try 180, then check the bone roll.
Exercise
You parent the elbow pole bone to the forearm, and the elbow starts to shake when you move the hand target. Why does this happen, and how do you fix it?
Show answer
The pole depends on the forearm, and the forearm's IK solution depends on the pole. This creates a dependency loop, so the result lags and shakes. Unparent the pole from the chain and parent it to a root or torso bone instead.