Seb
8 years ago
Hello,
I'm trying to compose Euler rotation matrices shown in
https://en.wikipedia.org/wiki/Euler_angles#Rotation_matrix. For
example, The Z1Y2X3 Tait-Bryan rotation shown in the table can be
represented in Numpy using the function:
def z1y2x3(alpha, beta, gamma):
"""Rotation matrix given Euler angles"""
return np.array([[np.cos(alpha) * np.cos(beta),
np.cos(alpha) * np.sin(beta) * np.sin(gamma) -
np.cos(gamma) * np.sin(alpha),
np.sin(alpha) * np.sin(gamma) +
np.cos(alpha) * np.cos(gamma) * np.sin(beta)],
[np.cos(beta) * np.sin(alpha),
np.cos(alpha) * np.cos(gamma) +
np.sin(alpha) * np.sin(beta) * np.sin(gamma),
np.cos(gamma) * np.sin(alpha) * np.sin(beta) -
np.cos(alpha) * np.sin(gamma)],
[-np.sin(beta), np.cos(beta) * np.sin(gamma),
np.cos(beta) * np.cos(gamma)]])
which given alpha, beta, gamma as:
angles = np.radians(np.array([30, 20, 10]))
returns the following matrix:
In [31]: z1y2x3(angles[0], angles[1], angles[2])
Out[31]:
array([[ 0.81379768, -0.44096961, 0.37852231],
[ 0.46984631, 0.88256412, 0.01802831],
[-0.34202014, 0.16317591, 0.92541658]])
If I understand correctly, one should be able to compose this matrix by
multiplying the rotation matrices that it is made of. However, I cannot
reproduce this matrix via composition; i.e. by multiplying the
underlying rotation matrices. Any tips would be appreciated.
I'm trying to compose Euler rotation matrices shown in
https://en.wikipedia.org/wiki/Euler_angles#Rotation_matrix. For
example, The Z1Y2X3 Tait-Bryan rotation shown in the table can be
represented in Numpy using the function:
def z1y2x3(alpha, beta, gamma):
"""Rotation matrix given Euler angles"""
return np.array([[np.cos(alpha) * np.cos(beta),
np.cos(alpha) * np.sin(beta) * np.sin(gamma) -
np.cos(gamma) * np.sin(alpha),
np.sin(alpha) * np.sin(gamma) +
np.cos(alpha) * np.cos(gamma) * np.sin(beta)],
[np.cos(beta) * np.sin(alpha),
np.cos(alpha) * np.cos(gamma) +
np.sin(alpha) * np.sin(beta) * np.sin(gamma),
np.cos(gamma) * np.sin(alpha) * np.sin(beta) -
np.cos(alpha) * np.sin(gamma)],
[-np.sin(beta), np.cos(beta) * np.sin(gamma),
np.cos(beta) * np.cos(gamma)]])
which given alpha, beta, gamma as:
angles = np.radians(np.array([30, 20, 10]))
returns the following matrix:
In [31]: z1y2x3(angles[0], angles[1], angles[2])
Out[31]:
array([[ 0.81379768, -0.44096961, 0.37852231],
[ 0.46984631, 0.88256412, 0.01802831],
[-0.34202014, 0.16317591, 0.92541658]])
If I understand correctly, one should be able to compose this matrix by
multiplying the rotation matrices that it is made of. However, I cannot
reproduce this matrix via composition; i.e. by multiplying the
underlying rotation matrices. Any tips would be appreciated.
--
Seb
Seb