Kinematic Motion Control

Kinematics describes the motion of objects. In real time applications, motion of objects is usually pre-scripted or pre-prepared, or calculated in real time using simple dynamics. Pre-prepared motion values typically come from motion capture. Pre-scripted animations are most often created using either forward kinematics or inverse kinematics.


Forward Kinematics

With forward kinematics, an animator explicitly specifies the positions and orientations of the objects. To reduce the amount of work, the animator canspecify these values for key frames, and then have the computer calculate the inbetweens.

Inbetweening: Position

The simplest way to move rigid bodies is with linear interpolation. But this is not very realistic. Linear interpolation of vertices is no better. Non-linear interpolation moves objects more realistically along curved paths. Velocity typically varies as well, enhancing realism.

Explicit scripting can be controlled with 2 curves: a motion path Q(u) and a velocity curve V(u) representing motion characteristics. For a frame at time t,

  1. Find the distance s traveled at time t from V(u).
  2. Measure distance s along the motion path Q(u) to find u.
  3. Substitute u into equations of Q(u) to find position of the object.
  4. Render the object at that position.

Inbetweening: Rotation

Changes in orientation cannot be successfully reproduced using linear interpolation of the vertices. Rotation transformations must be applied.

We can make an object change orientation by applying rotation about 3 axes:

But to move from one orientation to another, how do we interpolate rotations? Answer: Quaternions.

Quaternions

A quaternion is a quadrinomial expression, with a real angle θ and an axis of rotation n = ix + jy + kz, where i, j and k are imaginary numbers. A quaternion may be expressed as a quadruple p = (θ, x, y, z) or as a scalar and a vector p = (θ, u).

For quaternions p = (θ, u) and q = (φ, v),

p + q = (θ + φ, u + v)

pq = (θφ - u•v, θv + φu + uxv )

|p| = sqrt (θ*θ + u•u)

For a vector r oriented at an angle θ about the vector n, there is a quaternion p = (cos(θ/2), sin(θ/2)n) = (s, (x, y, z)) that represents that orientation. This is equivalent to the rotation matrix:

 

 

 
 1 - 2(y*y + z*z) 
2xy - 2sz
2sy + 2xz
0
 

 

M =

 
2xy + 2sz
 1 - 2(x*x + z*z) 
-2sx + 2yz
0
 

 

 

 
-2sy + 2xz
2sx + 2yz
 1 - 2(x*x + y*y) 
0
 

 

 

 
 0 
 0 
 0 
 1 
 

A rotation matrix M can be mapped to a quaternion as follows:

s = +/- sqrt(M00 + M11 + M22 + M33) / 2

x = (M21 - M12) / 4s

y = (M02 - M20) / 4s

z = (M10 - M01) / 4s

Spherical Linear Interpolation (slerp) is used to iterate from one quaternion to another. Given 2 unit quaternions p and q separated by angle Ω, the inbetween quaternion at step u (where 0 <= u <= 1) is

slerp(p, q, u) = p*(sin(1-u)Ω)/sinΩ + q*(sinΩu)/sinΩ


Hierarchical Models

Few computer graphics objects are rigid models; most have moving parts. These parts move relative to one another, usually by rotating at a joint, with various orientation and positional constraints. Some examples are:

Relationships between the parts can be represented by a tree structure.



Inverse Kinematics

Specifying precise positions and angles can become tedious, especially for complex hierarchical models. Inverse kinematics allows an animator to drag part of the model to a goal position, subject to pre-defined constraints. Inverse kinematics was originally used for robotics.

The end effector is represented by a 9D vector e(θ) where the first 3 elements represent the position, and the next 6 elements represent two orthogonal orientation vectors. The joint chain that produces the end effector is θ = (θ1, θ2 ... θn) for a chain of n joints. If each joint has only 1 degree of freedom, rotating θi degrees about a vector ui of rotation , then e(θ) can easily be calculated using a series of matrix multiplications. The trick is to find these angles. The more joints there are in the chain, the harder this is to calculate.

Even with these calculations, awkward angles can be generated. A direct manipulation interface - where changes in the angles are incremental and small - helps to make the algorithm more stable.


References

3D Games, by Watt & Policarpo, 2001.

Introduction to Quaternions

Inverse Kinematics Positioning Using Nonlinear Programming for Highly Articulated Figures, by Zhao & Badler, ACM Transactions on Graphics,Vol 13,No.4, October1994, Pages 313-336.