Overview of Inverse Kinematics

Luis Bermudez
Unity3DAnimation
Published in
7 min readJul 10, 2017

--

You’ve probably heard of Inverse Kinematics. IK is a popular tool in Unity and computer graphics, but if this is the first time you’ve tried to create or use an Inverse Kinematics system then you might want more details. I’m going to explain what IK is, define the vocabulary, and review the uses.

What is the necessary vocabulary to understand IK?

Before we get into the heart of IK, we need to define some IK-related vocabulary. IK is a method that is applied to an articulated body. What is an articulated body?

Articulated Body

An articulated body can represent most animated bodies such as humans and animals with skeletons. Simply put, an articulated body is a tree of linked chains. The linked chains are made up of joints and links, where a link is a rigid cylinder. Figure 1 shows an articulated body that represents a humanoid.

Figure 1: Human Articulated Body

Even the simple toy in the above cover photo represents an articulated body. It’s just missing elbow and knee joints.

Types of Joints

As for joints, there are two types. The first type of joint is a revolute joint. It is connected to a link that rotates around it. Figure 2 shows a revolute joint.

Figure 2: Revolute Joint

A revolute joint is much like the center pin of a clock — with a clock hand as a link.

The clock’s gold pin is a revolute joint.

A prismatic joint is a joint such that the connected link translates from the joint to extend/shorten the link. Figure 3 shows a prismatic joint.

Figure 3: Prismatic Joint

A prismatic joint acts much like extending/retracting the length of the retractable handle on your luggage. If you look closely, the retractable luggage handle has 4 prismatic joints. 2 prismatic joints half way down the handle, and another 2 prismatic joints all the way down the handle at the top of the luggage.

The four red arrows point to the four prismatic joints on the retractable luggage handle.

If you’re confused by prismatic joints, don’t worry. They are not used that often in Inverse Kinematics, and as you might be able to tell, no humans have prismatic joints — only revolute joints.

Hierarchical Structure

An articulated body has a root joint. The root joint is the base of the structure. The root joint for a humanoid is usually the center of the hips. The articulated body is formed from a tree of joints and links, starting at the root joint. A new joint and link is similar to a new branch on a tree. An inboard link/joint is a link/joint that is closer to the root joint within the tree hierarchy of the articulated body, as it relates to given joint/link. An outboard link/joint is a link/joint that is further away from the root joint within the tree hierarchy of the articulated body. In Figure 4, Joint A is the root joint, Link 1 is Joint B’s inboard link, Link 2 is Joint B’s outboard link.

End Effector

An end effector is a position at the most outboard position of the most outboard link. It is the free end of the chain of alternating joints and links. The end effector is not a joint. The end effector is merely the position at the end of an articulated body. An articulated body can have multiple end effectors, just like a binary tree can have multiple leaves.

Figure 4: The end effector is represented by a green circle.

Articulations and Poses

An articulation is a rotation/translation of a joint which moves a connected link. For example, in Figure 5, Joint A has an articulation of 45°, Joint B has an articulation of 15°, and Joint C has an articulation of -60°. On the other hand, a pose is a set of joint articulations which results in positioning the articulated body. In other words, the pose is a vector value of instead of a scalar value. For example, in Figure 4, the pose of the articulated body is <45°, 15°, -60°>.

Figure 5: Articulated Body with A as the root joint

What is Forward Kinematics?

Before we can get into what Inverse Kinematics is, we need to figure out what Forward Kinematics is. The Forward Kinematics function/algorithm takes a pose as the input, and calculates the position of the end effector as the output. Forward Kinematics is the inverse function of Inverse Kinematics. With Forward Kinematics, you need to define the whole pose of an articulated body so as to provide the function/algorithm with the pose input. This means you need to define the articulation of each joint in the articulated body. This might be fine if you have a low number of joints, but with a high number of joints this tends to be tedious.

What is Inverse Kinematics?

Now, imagine if you’d like the end effector of your articulated body to reach a particular target position. This means that you know the end effector position you’d like to target, but you don’t know what the pose of the articulated body needs to be for the end effector to reach this target position. This is where Inverse Kinematics shines!

Figure 6: The target position is represented by a red circle. The target position is defined as the input, and the resulting pose required for the end effector to reach the target position is the output.

Inverse Kinematics is the inverse function/algorithm of Forward Kinematics. The Inverse Kinematics function/algorithm takes a target position as the input, and calculates the pose required for the end effector to reach the target position — the pose is the output.

As you can see, the input and output are switched between FK and IK. With Inverse Kinematics, you do not need to define the whole pose of an articulated body — this gets calculated for your by the IK algorithm. With IK, you only need to define a position as the input.

Inverse Kinematics does all the challenging computational work of calculating what the pose is. Figure 6 represents this well. In the Before Scene, there is an articulated body with some known pose. It defines a target position for the end effector to try to reach. Once the IK algorithm is applied to the articulated body, we have reached the After Scene. The After Scene shows that a new pose has been computed, such that the end effector is now at the target position.

What are the uses of IK?

At this point, we know that IK is applied to an articulated body, we know what an articulated body is made up of, and we know the difference between IK and FK. We have a good overview of IK so far, but let’s round it out with some good use cases of IK as well. IK can be used for a humanoid arm to reach for an object/target, as we’ve seen. IK can also be used for foot stepping, such that we tell the foot where to step and the IK figures out how to configure the leg joints. IK is not usually used as an animation itself (reaching for an object), but more as an animation tool. So, if you are implementing a walk cycle, you could position some of the key frames using the IK tool.

Figure 7: IK is applied with foot rotation as the goal. Joints L & R rotate to conform to the inclined plane.

Another key point about IK is that your goal/target is not limited to position alone — your goal can be defined as a rotation. For example, if your feet need to rotate based on uneven terrain, your IK rotation goal can be defined based on the floor’s normal. See Figure 7. This way your feet are inclined along the floor, such as when you are walking up an incline. Note that you can also use IK to have your head (or even eyes) look in a certain direction. If you want your head to follow an object, you can use IK to have the head follow the object around.

IK Demo

I’ll leave you with an IK demo to finish the article. This character moves his left hand and right leg with moving IK targets.

IK Demo in Unity3D

Looking for an implementation? This is The Simplest IK Algorithm.

If you enjoyed this article, please to help others find it!

I would like to thank masters of computer graphics Eric Haines, Ed Angel, and Rick Parent for contributing their valuable feedback in this introductory article.

--

--