-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathderiving.m
56 lines (45 loc) · 1.2 KB
/
deriving.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
46
47
48
49
50
51
52
53
54
55
56
close all
clear all
%About x (or [1, 0, 0])
C_1 = @(t) [1, 0, 0;
0, cos(t), -sin(t);
0, sin(t), cos(t)];
%About y (or [0, 1, 0])
C_2 = @(t) [cos(t), 0, sin(t);
0, 1, 0;
-sin(t), 0, cos(t)];
%About z (or [0, 0, 1])
C_3 = @(t) [cos(t), -sin(t), 0;
sin(t), cos(t), 0;
0, 0, 1];
%Make matrices for printing
syms a;
syms b;
syms c;
fprintf('Transform about the x (or [1, 0, 0]) axis is: \n')
pretty(C_1(a))
fprintf('Transform about the y (or [0, 1, 0]) axis is: \n')
pretty(C_2(a))
fprintf('Transform about the z (or [0, 0, 1]) axis is: \n')
pretty(C_3(a))
fprintf('Hence the 3-2-1 transform is: \n');
zyx = C_3(a)*C_2(b)*C_1(c);
pretty(zyx);
fprintf('Diff zyx with respect to a\n');
pretty(diff(zyx, 'a'));
fprintf('Diff zyx with respect to b\n');
pretty(diff(zyx, 'b'));
fprintf('Diff zyx with respect to c\n');
pretty(diff(zyx, 'c'));
syms x
syms y
syms z
p = [x; y; z]
uvw = zyx*p;
pretty(uvw)
fprintf('Diff uvw wrt a\n');
pretty(diff(uvw, 'a'))
fprintf('Diff uvw wrt b\n');
pretty(diff(uvw, 'b'))
fprintf('Diff uvw wrt b\n');
pretty(diff(uvw, 'c'))