Defining Rotations edit page

MTEX offers the following functions to define rotations

rotation.byEuler

rotation.byAxisAngle

rotation.byMatrix

rotation.byRodrigues

rotation.byHomochoric

rotation(quat)

rotation.id

rotation.map

rotation.fit

rotation.rand

odf.discreteSample

rotation.nan

rotation.load

rotation.inversion

rotation.mirroring

At the end all functions return a variable of type rotation which represents a list of rotations that are internally stored as quaternions. An overview of different rotation representations by three dimensional vectors and their properties can be found in the section Representations.

Euler Angles

One of the most common ways to describe a rotation is as three subsequent rotations about fixed axes, e.g., first around the z axis, second around the x axis and third again around the z. The corresponding rotational angles are commonly called Euler angles. Beside the most common ZXZ convention other choices of the axes are sometimes used. Sorted by popularity in the texture analysis community these are

  • Bunge (phi1,Phi,phi2) - ZXZ
  • Matthies (alpha,beta,gamma) - ZYZ
  • Roe (Psi,Theta,Phi)
  • Kocks (Psi,Theta,phi)
  • Canova (omega,Theta,phi)

The default Euler angle convention in MTEX are the Bunge Euler angles, with axes Z, X, and Z. The following command defines a rotation by its three Bunge Euler angles

rot = rotation.byEuler(30*degree,50*degree,10*degree)
rot = rotation
 
  Bunge Euler angles in degree
  phi1  Phi phi2
    30   50   10

Note that the angles needs to be multiplied with degree since all commands in MTEX expect the input in radiant. Furthermore, the order of the first and the third Euler angle are interchanged in comparison to standard notation for reasons explained here.

In order to define a rotation by a Euler angle convention different to the default Euler angle convention you to specify the convention as an additional parameter, e.g.

rot = rotation.byEuler(30*degree,50*degree,10*degree,'Roe')
rot = rotation
 
  Bunge Euler angles in degree
  phi1  Phi phi2
   120   50  280

This does not change the way MTEX displays the rotation on the screen. The default Euler angle convention for displaying a rotation can be changed by the command setMTEXpref, for a permanent change the file mtex_settings.m should be edited. Compare

setMTEXpref('EulerAngleConvention','Roe')
rot
rot = rotation
 
  Roe Euler angles in degree
  Psi Theta   Phi
   30    50    10
setMTEXpref('EulerAngleConvention','Bunge')
rot
rot = rotation
 
  Bunge Euler angles in degree
  phi1  Phi phi2
   120   50  280

Axis angle parametrization and Rodrigues Frank vector

A very simple possibility to specify a rotation is to specify the rotation axis and the rotation angle.

rot = rotation.byAxisAngle(xvector,30*degree)
rot = rotation
 
  Bunge Euler angles in degree
  phi1  Phi phi2
     0   30    0

Conversely, we can extract the rotational axis and the rotation angle of a rotation by

rot.axis
rot.angle ./degree
ans = vector3d
  x y z
  1 0 0
ans =
   30.0000

Closely related to the axis angle parametrization of a rotation is the Rodriguez Frank vector.

R = rot.Rodrigues
R = vector3d
         x        y        z
  0.267949        0        0

This is the rotational axis scaled by \(\tan \omega/2\), where \(\omega\) is the rotational angle.

2 * atan(norm(R))./degree
ans =
   30.0000

We can also define a rotation by a Rodrigues Frank vector by

rotation.byRodrigues(R)
ans = rotation
 
  Bunge Euler angles in degree
  phi1  Phi phi2
     0   30    0

Rotation Matrix

Another common way to represent rotations is by 3x3 matrices. The column of such a rotation matrix coincide with the new positions of the x, y and z vector after the rotation. For a given rotation we may compute the matrix by

M = rot.matrix
M =
    1.0000         0         0
         0    0.8660   -0.5000
         0    0.5000    0.8660

Conversely, we may define a rotation by its matrix with the command

rot = rotation.byMatrix(M)
rot = rotation
 
  Bunge Euler angles in degree
  phi1  Phi phi2
     0   30    0

Four vectors defining a rotation

Another useful method to define a rotation is by describing how in acts on two given directions. More precisely, given four vectors u1, v1, u2, v2 there is a unique rotation rot such that rot * u1 = v1 and rot * u2 = v2. E.g., to find the rotation the maps the x-axis onto the y-axis and keeps the z-axis we do

u1 = vector3d.X;
v1 = vector3d.Y;
u2 = vector3d.Z;
v2 = vector3d.Z;


rot = rotation.map(u1,v1,u2,v2)
rot = rotation
 
  Bunge Euler angles in degree
  phi1  Phi phi2
    90    0    0

The above definition require that the angle between u1 and u2 is the same as between v1 and v2. The function gives an error if this condition is not meet. If only two vectors are specified, then the rotation with the smallest angle is returned that rotates the first vector onto the second one.

rot = rotation.map(zvector,yvector)
rot = rotation
 
  Bunge Euler angles in degree
  phi1  Phi phi2
   180   90  180

More generally, one can fit a rotation rot to a list of left and right vectors l and r such that rot * l is the best approximation of r. This is done by the function rotation.fit

% take five random left vectors
left = vector3d.rand(5);

% rotate them by rot and perturb them a little bit
right = rot * left + 0.1 * vector3d.rand(1,5);

% recover the rotation rot
rotation.fit(left,right)
ans = rotation
 
  Bunge Euler angles in degree
     phi1     Phi    phi2
  182.717 92.0857 177.089

Random Rotations

MTEX offers several ways for generating random rotations. The most easiest way is to use the command rotation.rand which generates an arbitrary number of random rotations

rotation.rand(100)
ans = rotation
  size: 100 x 1

If you are interested in random rotations that follow a certain distribution have a look at random sampling.

Quaternions

A last possibility to define a rotation is by quaternion coordinates a, b, c, d.

q = quaternion(1,0,0,0)

rot = rotation(q)
q = quaternion
  a b c d
  1 0 0 0
 
rot = rotation
 
  Bunge Euler angles in degree
  phi1  Phi phi2
     0    0    0