magpack.rotations.eul2rot#

eul2rot(seq, *args, degrees=True, reverse_order=False)#

Returns a stack of rotation matrices following the sequence and the corresponding angles.

Parameters:
reverse_order
seqstr

Sequence of rotation operations (first operation listed on the right, follows matrix multiplication rule).

argsarray_like

Unpacked list of angles (or array of angles) matching the length of the sequence.

degreesbool

True for degrees, False for radians.

reverse_orderbool

By default, the rightmost arguement is expanded first.

Returns:
np.ndarray

Stack of rotation matrices with shape(n, 3, 3). n is the product of the length of all args.

See also

tomo_rot, lamni_rot

Examples

Dual-axis tomography: Describes full 180° rotations for each of the two tilts: 0° and 30°.

>>> eul2rot('yz', np.linspace(1, 180), [0,30])

Laminography: Full 360° rotation around an axis that is slanted by 45° around the y-axis.

>>> eul2rot('zy', 45, np.linspace(1,360))

The regular order of producing the rotation matrix array assumes that the first array should be traversed before moving to the second array. By setting reverse_order=True, the last array is traversed first, before traversing the second to last array, and so on. The resulting operations describe the same rotations and geometry, but are ordered diffently.Example of the change of order shown below: (not true outputs)

>>> eul2rot('yzx', [0, 1, 2], [0,30], 45)
[[ 0  0 45]     # roty(0) @ rotz(0)  @ rotx(45)
 [ 1  0 45]     # roty(1) @ rotz(0)  @ rotx(45)
 [ 2  0 45]     # roty(2) @ rotz(0)  @ rotx(45)
 [ 3  0 45]     # roty(3) @ rotz(0)  @ rotx(45)
 [ 0 30 45]     # roty(0) @ rotz(30) @ rotx(45)
 [ 1 30 45]     # roty(1) @ rotz(30) @ rotx(45)
 [ 2 30 45]     # roty(2) @ rotz(30) @ rotx(45)
 [ 3 30 45]]    # roty(3) @ rotz(30) @ rotx(45)
>>> eul2rot('yzx', [0, 1, 2], [0,30], 45, reverse_order=True)
[[ 0  0 45]     # roty(0) @ rotz(0)  @ rotx(45)
 [ 0 30 45]     # roty(0) @ rotz(30) @ rotx(45)
 [ 1  0 45]     # roty(1) @ rotz(0)  @ rotx(45)
 [ 1 30 45]     # roty(1) @ rotz(30) @ rotx(45)
 [ 2  0 45]     # roty(2) @ rotz(0)  @ rotx(45)
 [ 2 30 45]     # roty(2) @ rotz(30) @ rotx(45)
 [ 3  0 45]     # roty(3) @ rotz(0)  @ rotx(45)
 [ 3 30 45]]    # roty(3) @ rotz(30) @ rotx(45)