[76e9f4]: / tool_funcs / getAxisRotMat.m

Download this file

33 lines (28 with data), 1.2 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
%-------------------------------------------------------------------------%
% Copyright (c) 2021 Modenese L. %
% Author: Luca Modenese, 2021 %
% email: l.modenese@imperial.ac.uk %
% ----------------------------------------------------------------------- %
function [aRotMat, axis_ind] = getAxisRotMat(aStringAxis)
% uniform the input
stringAxis = lower(aStringAxis);
% get the corresponding rotation matrix as implicit function
switch stringAxis
case 'x'
aRotMat = @(a)[1 0 0;
0 cos(a) -sin(a);
0 sin(a) cos(a)];
axis_ind = 1;
case 'y'
aRotMat = @(a)[cos(a) 0 sin(a);
0 1 0;
-sin(a) 0 cos(a)];
axis_ind = 2;
case 'z'
aRotMat = @(a)[ cos(a) -sin(a) 0;
sin(a) cos(a) 0;
0 0 1];
axis_ind = 3;
otherwise
error('Please specify a rotation axis as ''x'', ''y'' or ''z''.')
end