# Rotation Matrices

## Java applet for performing 2D rotations

this applet allows you to define an angle and see the result of rotating 5 points (forming a house), the resulting rotated coordinates of the point (20,20), and the 2×2 rotation matrix.

## ... and the corresponding applet for performing 3D rotations

this applet allows to rotate a 3D house

## Representing a human pose using 3D rotations

### Using a rotation matrix to encode a 3 DOF joint state

A 3x3 rotation matrix can be used to encode a rotation of an object in 3D space.

If we assume a 3 DOF joint in each joint of a person model, we can represent the corresponding joint state by a 3×3 rotation matrix `J`.

Here you see a sample. I modify these rotation matrices `J` (and its kinematic children as well) by multiplying another rotation matrix `R` onto the current rotation matrix, where `R` is a basic rotation matrix that represents a rotation around the X,Y,or Z axis of the current coordinate axes represented by `J`.

`J` can be interpretated as a local coordinate system as well. Note: the three axes (red:X, green:Y, blue:Z) rendered in each joint are just the 3×1 column vectors of `J`.

Having motion capture data where each marker is given by absolute world coordinates, we can compute Euler angles that encode the current articulation.

### Local coordinate systems

We first compute a local coordinate system in each joint in a hierarchical manner. This coordinate system first describes the absolute orientation of the joint in the world coordinate system:

• the Y-axis is always defined by the bone direction vector from the parent joint to the current joint. Note: this is not true for the animation above! Here the coordinate system can be rotated out of the bone! For this, the green Y-axes can only hardly be seen in the animation at the bottom since they lie in the (white) bone
• the second axis is defined as the cross-product of this Y-axis and a reference axis provided by the parent coordinate system
• the third axis is defined as the cross-product of the first two axes

### Relative orientation matrices

Having a coordinate system that describes the absolute orientation of the joint in the world coordinate system, we can represent this coordinate system as a 3×3 rotation matrix as well. Since we are not interested in the absolute orientation of the joint but just its relative orientation to its kinematic parent joint, we can represent the relative orientation of each joint (the actual joint state!) by a rotation matrix that rotates the absolute parent coordinate system into the absolute joint coordinate system.

### Extract Euler angles from a rotation matrix

Each joint is now encoded by a rotation matrix that describes the relative orientation to its parent joint. We now extract Euler angles from these rotation matrices. A 3×3 rotation matrix consists out of 9 numbers and is a non-minimal representation of a 3D rotation. By contrast, Euler angles are a non-minimal representation of 3D rotation by just 3 numbers (angles).

See e.g. Introduction to Robotics. Mechanics and Control. By J.Craig. Third edition. Page 43 how to extract the Euler angles in the ZYX rotation order convention. Note: these are interestingly the same angles for getting the same rotation matrix by successive rotations around the X,Y,Z axes where these axes are fixed!

This somehwat nonintuitve result holds in general: three rotations taken about fixed axes yield the same final orientation as the same three rotations taken in opposite order about the axes of the moving frame.

J.Craig. p.45

### Extract bone lengths

Finally we also have to extract the bone lengths if we later want to reconstruct the pose exactly. Bone lengths can vary between persons since persons have different sizes.

Thus we finally get a 15*3 Euler angles + 15 bone lengths = 60D pose representation vector:

PoseRepVec = <45 euler angles, 15 bone lengths>

### Sample Euler angles

Here are plots of all corresponding Euler angles for the walking sequence above:

• red: alpha (angle for rotation around Z axis)
• green: beta (angle for rotation around Y' axis)
• blue: gamma (angle for rotation around X'' axis)

The y axis is scaled to [-pi,pi].

The x axis is scaled to frame #0 - frame #549.

Click to enlarge.

The plots for marker(joint) #11 e.g. represents the orientation of the right foot relative to the right knee, i.e. the right knee joint state.

## Euler angle rotation demo

public/rotation_matrices.txt · Last modified: 2014/01/05 13:47 (external edit) · [] 