Module implementing Euler angle rotations and their conversions
See:
See also: Representing Attitude with Euler Angles and Quaternions: A Reference (2006) by James Diebel. A cached PDF link last found here:
http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.110.5134
Euler’s rotation theorem tells us that any rotation in 3D can be
described by 3 angles. Let’s call the 3 angles the Euler angle vector
and call the angles in the vector ,
and
. The vector is [
,
.
] and, in this description, the order of the
parameters specifies the order in which the rotations occur (so the
rotation corresponding to
is applied first).
In order to specify the meaning of an Euler angle vector we need to
specify the axes around which each of the rotations corresponding to
,
and
will occur.
There are therefore three axes for the rotations ,
and
; let’s call them
,
.
Let us express the rotation around axis i as a 3 by 3
rotation matrix A. Similarly
around j becomes 3 x 3
matrix B and
around k becomes matrix G. Then the
whole rotation expressed by the Euler angle vector [
,
.
], R is given by:
R = np.dot(G, np.dot(B, A))
See http://mathworld.wolfram.com/EulerAngles.html
The order expresses the fact that the rotations are
performed in the order of the vector (
around axis i =
A first).
To convert a given Euler angle vector to a meaningful rotation, and a rotation matrix, we need to define:
See: http://en.wikipedia.org/wiki/Rotation_matrix#Ambiguities
We are using the following conventions:
The convention of rotation around z, followed by rotation around y, followed by rotation around x, is known (confusingly) as “xyz”, pitch-roll-yaw, Cardan angles, or Tait-Bryan angles.
Functions
angle_axis2euler(theta, vector[, is_normalized]) | Convert angle, axis pair to Euler angles |
euler2angle_axis([z, y, x]) | Return angle, axis corresponding to these Euler angles |
euler2mat([z, y, x]) | Return matrix for rotations around z, y and x axes |
euler2quat([z, y, x]) | Return quaternion corresponding to these Euler angles |
mat2euler(M[, cy_thresh]) | Discover Euler angle vector from 3x3 matrix |
quat2euler(q) | Return Euler angles corresponding to quaternion q |