function [M,R_x,R_y,R_z] = RotFromEulerZYX(thetas)

% thetas is a vector of three angles interpreted as ZYX rotation angles.

% thetas(1) is the rotation angle around the x-axis, thetas(2) is the rotation angle around the new y-axis and thetas(3) is the rotation angle around the doubly-new z-axis.

if thetas(1)==0 thetas(1)=2*pi;
end

if thetas(2)==0 thetas(2)=2*pi;
end

if thetas(3)==0 thetas(3)=2*pi;
end


R_x=RotUsingRodriguesFormula(thetas(1)*[1;0;0]);
R_y=RotUsingRodriguesFormula(thetas(2)*[0;1;0]);
R_z=RotUsingRodriguesFormula(thetas(3)*[0;0;1]);

M=R_z*R_y*R_x;


end

