-
Notifications
You must be signed in to change notification settings - Fork 7
/
DCM.m
46 lines (31 loc) · 905 Bytes
/
DCM.m
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
33
34
35
36
37
38
39
40
41
42
43
44
45
function R = DCM(theta, axis)
% ------------------------------------------------------------------------------------------------------------------------ %
% Function R = DCM(theta,axis)
% Computes the rotation matrix about an AXIS by the angle THETA
% INPUTS:
% theta is the angle of rotation about the axis (degrees)
% axis denoted by string x, y, or z
% OUTPUTS:
% returns the direction cosine matrix for the given inputs
%
% Written By: Jesse Weisberg
% ------------------------------------------------------------------------------------------------------------------------ %
%[INSERT CODE HERE]
R = zeros(3,3);
c= cos(theta);
s= sin(theta);
if(axis=='z')
R=[c -s 0;
s c 0;
0 0 1];
elseif(axis=='x')
R=[1 0 0;
0 c -s;
0 s c];
elseif(axis=='y')
R=[c 0 s;
0 1 0;
-s 0 c];
else
print 'error';
end