Euler Angles from Rotation Matrix
48 views (last 30 days)
Show older comments
Gregory Cottone
on 6 Mar 2021
Commented: Gregory Cottone
on 14 Mar 2021
Hello!
I'm trying to get symbolic form of alpha, beta, gamma angles from a rotation matrix R in the sequence 3-1-3 (i.e. first rotation of gamma about Z axis, then a rotation of alpha about X axis and finally a rotation of gamma about Z axis) but I don't know how to do so.
Could someone can help me?
Thank you!
syms alpha beta gamma
R1 = [1, 0, 0; 0, cos(alpha), -sin(alpha); 0, sin(alpha), cos(alpha)]; % Rotation matrix about X axis of an angle alpha
R3 = [cos(gamma), -sin(gamma), 0; sin(gamma), cos(gamma), 0; 0, 0, 1]; % Rotation matrix about Z axis of an angle gamma
R313 = R3*R1*R3; % Final rotation matrix in the sequence 3-1-3
0 Comments
Accepted Answer
David Goodmanson
on 7 Mar 2021
Edited: David Goodmanson
on 7 Mar 2021
Hi Gregory,
If you mean you want the form of the rotation martrix in terms of alpha,beta,gamma, that's just
syms a b g
R1 = [1, 0, 0; 0, cos(b), -sin(b); 0, sin(b), cos(b)];
R3m = [cos(a), -sin(a), 0; sin(a), cos(a), 0; 0, 0, 1];
R3n = [cos(g), -sin(g), 0; sin(g), cos(g), 0; 0, 0, 1];
Rtot = R3m*R1*R3n
Rtot =
[cos(a)*cos(g) -cos(b)*sin(a)*sin(g), -cos(a)*sin(g) -cos(b)*cos(g)*sin(a), sin(a)*sin(b)]
[cos(g)*sin(a) +cos(a)*cos(b)*sin(g), cos(a)*cos(b)*cos(g) -sin(a)*sin(g), -cos(a)*sin(b)]
[ sin(b)*sin(g), cos(g)*sin(b), cos(b)]
If you mean you have a rotation matrix M and need expressions for a,b,g then
b = acos(M33) % M33 = M(3,3) etc.
Two choices here; b and (2*pi-b) are possible since cos is the same either way. That essentially means you get to pick the sign of sin(b). Denote that sign by S. Then
g = atan2(S*M31,S*M32)
a = atan2(S*M13,-S*M23)
Generally one of the euler angles is restricted to 0,theta<pi. That might or might not determine the angle b uniquely.
3 Comments
David Goodmanson
on 11 Mar 2021
Depending on your convention, you might have to use
R3(g)R1(b)R3(a) instead of R3(a)R1(b)R3(g). a,b,g = alpha,beta,gamma
For euler angles, if all three of them have the domain 0<=angle<=2*pi, then for every physical rotation there are two different sets of angles that give the same 3d rotation. This is not a good situation. Restricting one of the angles to 0<=angle<=pi gets rid of that problem, and the restriced set of angles still cover every possible 3d rotation.
More Answers (0)
See Also
Categories
Find more on Coordinate Systems in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!