1 | function Y = vgg_contreps(X)
|
---|
2 |
|
---|
3 | % vgg_contreps Contraction with epsilon tensor.
|
---|
4 | %
|
---|
5 | % B = vgg_contreps(A) is tensor obtained by contraction of A with epsilon tensor.
|
---|
6 | % However, it works only if the argument and result fit to matrices, in particular:
|
---|
7 | %
|
---|
8 | % - if A is row or column 3-vector ... B = [A]_x
|
---|
9 | % - if A is skew-symmetric 3-by-3 matrix ... B is row 3-vector such that A = [B]_x
|
---|
10 | % - if A is skew-symmetric 4-by-4 matrix ... then A can be interpreted as a 3D line Pluecker matrix
|
---|
11 | % skew-symmetric 4-by-4 B as its dual Pluecker matrix.
|
---|
12 | % - if A is row 2-vector ... B = [0 1; -1 0]*A', i.e., A*B=eye(2)
|
---|
13 | % - if A is column 2-vector ... B = A'*[0 1; -1 0], i.e., B*A=eye(2)
|
---|
14 | %
|
---|
15 | % It is vgg_contreps(vgg_contreps(A)) = A.
|
---|
16 |
|
---|
17 | % werner@robots.ox.ac.uk, Oct 2001
|
---|
18 |
|
---|
19 | if prod(size(X)) == 3 % get [X]_\times
|
---|
20 | Y = [0 X(3) -X(2)
|
---|
21 | -X(3) 0 X(1)
|
---|
22 | X(2) -X(1) 0];
|
---|
23 | elseif all(size(X) == [1 2])
|
---|
24 | Y = [0 1; -1 0]*X';
|
---|
25 | elseif all(size(X) == [2 1])
|
---|
26 | Y = X'*[0 1; -1 0];
|
---|
27 | elseif all(size(X) == [3 3]) % get X from [X]_\times
|
---|
28 | Y = [X(2,3) X(3,1) X(1,2)];
|
---|
29 | elseif all(size(X) == [4 4]) % pluecker matrix dual
|
---|
30 | Y = [0 X(3,4) X(4,2) X(2,3)
|
---|
31 | X(4,3) 0 X(1,4) X(3,1)
|
---|
32 | X(2,4) X(4,1) 0 X(1,2)
|
---|
33 | X(3,2) X(1,3) X(2,1) 0 ];
|
---|
34 | else
|
---|
35 | error('Wrong matrix size.')
|
---|
36 | end |
---|