-
Notifications
You must be signed in to change notification settings - Fork 3
/
skew3.m
52 lines (48 loc) · 968 Bytes
/
skew3.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
function [V,dV] = skew3(v)
%SKEW3 [V,dV] = skew3(v)
% Takes a 3 components vector and calculates
% the corresponding skew-symmetric matrix.
% It is useful for implementing the vector
% product of 3-vectors: v x u = skew3(v) * u
%
% dV (optional) returns the 9x3 matrix which represents
% the 3x3x3 tensor of derivatives of V wrt v.
%
% Updated 8/30/93
V = zeros(3,3);
V = [[0,-v(3),v(2)]; [v(3),0,-v(1)]; [-v(2),v(1),0]];
if (nargout >=2),
dV = [0 0 0 ;
0 0 -1 ;
0 1 0 ;
0 0 1 ;
0 0 0 ;
-1 0 0 ;
0 -1 0 ;
1 0 0 ;
0 0 0 ];
end;
return;
%
%v = rand(3,1);
%eps = 1e-6;
%for j=1:3,
% vp = v;
% vp(j) = v(j)+eps;
% dVtest(:,j) = qtoQ(1/eps*(skew3(vp) - skew3(v)));
%end;
%
%return;
%
% difference test
%epsilon = 1e-6;
%csi = randn(3,1);
%rho = randn;
%for (k = 1:3),
% csip = csi;
% csip(k) = csip(k)+epsilon;
% diff = (skew3(csip)-skew3(csi))/epsilon;
% diff = diff';
% dFdcsi_test(:,k) = diff(:);
%end;
%[F,dFdcsi] = skew3(csi);