IRDYn/GC_calibration/rot.m

22 lines
814 B
Mathematica
Raw Normal View History

2024-11-06 15:46:33 +00:00
function rotMatrix = rot(axis,angle)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% return a rotation matrix from a rotation around axis about angle
% axis: 1-x,2-y,3-z
% angle:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
switch axis
case 1
rotMatrix = [1 0 0;
0 cos(angle) -sin(angle);
0 sin(angle) cos(angle)];
case 2
rotMatrix = [cos(angle) 0 sin(angle);
0 1 0;
-sin(angle) 0 cos(angle)];
case 3
rotMatrix = [cos(angle) -sin(angle) 0;
sin(angle) cos(angle) 0;
0 0 1];
otherwise
rotMatrix = eye(3);
end