-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrotation.m
More file actions
24 lines (23 loc) · 713 Bytes
/
Copy pathrotation.m
File metadata and controls
24 lines (23 loc) · 713 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
% Compute rotation matrix for a set of angles.
% Obtained from https://github.com/gibiansky/experiments/tree/master/quadcopter/matlab
function R = rotation(angles)
phi = angles(3);
theta = angles(2);
psi = angles(1);
R = zeros(3);
R(:, 1) = [
cos(phi) * cos(theta)
cos(theta) * sin(phi)
- sin(theta)
];
R(:, 2) = [
cos(phi) * sin(theta) * sin(psi) - cos(psi) * sin(phi)
cos(phi) * cos(psi) + sin(phi) * sin(theta) * sin(psi)
cos(theta) * sin(psi)
];
R(:, 3) = [
sin(phi) * sin(psi) + cos(phi) * cos(psi) * sin(theta)
cos(psi) * sin(phi) * sin(theta) - cos(phi) * sin(psi)
cos(theta) * cos(psi)
];
end