-
Notifications
You must be signed in to change notification settings - Fork 92
/
pseudoRotation.m
64 lines (52 loc) · 2 KB
/
pseudoRotation.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
57
58
59
60
61
62
63
64
function matrix = pseudoRotation(skel, channels, ind2Compute)
% PSEUDOGRADIENT ths position function of a node is composed with 2
% terms. The first one is the position of the parent node, the second is an
% additional term to get the real position. This function computes the
% derivative of the second term for the node 'ind2Compute' in respect with
% the channels 'rotInd2' given a set of channels.
%
% Description:
%
% [gradient matrix] = PSEUDOGRADIENT(skel, channels,gradientDirection, ind,rotInd2, ind2Compute)
%
% Returns:
% GRADIENT - the coponents of the gradient (x,y,z)
% MATRIX - the rotation matrix
% Arguments:
% SKEL - a skeleton structure
% CHANNELS - the channels where the gradient has to be computes
% GRADIENTDIRECTION - the direction of the gradient
% IND - a recursive paremeter... start with 0 in general
% ROTIND2 - the gradient has to be computed in respect with this
% channel
% IND2COMPUTE - the node ID where the gradient has to be computed
skelTmp = skel.tree(ind2Compute);
parent = skelTmp.parent;
skelParent = skel.tree(parent);
matrix = eye(3);
while (parent~=0)
skelParent = skel.tree(parent);
rotVal = zeros(1, 3);
for j = 1:length(skelParent.rotInd)
rind = skelParent.rotInd(j);
if rind
rotVal(j) = channels(rind);
else
rotVal(j) = 0;
end
end
tdof = rotationMatrix(deg2rad(rotVal(1)), ...
deg2rad(rotVal(2)), ...
deg2rad(rotVal(3)), ...
skelParent.order);
torient = rotationMatrix(deg2rad(skelParent.axis(1)), ...
deg2rad(skelParent.axis(2)), ...
deg2rad(skelParent.axis(3)), ...
skelParent.axisOrder);
torientInv = rotationMatrix(deg2rad(-skelParent.axis(1)), ...
deg2rad(-skelParent.axis(2)), ...
deg2rad(-skelParent.axis(3)), ...
skelParent.axisOrder(end:-1:1));
matrix = matrix*torientInv*tdof*torient;
parent = skelParent.parent;
end