皮肤变换skinning_transformation函数,输出T,R、S,这里单独对输出S的部分举例检验下。
clear all
C=[1,0;1,1]
P=[1,2]
BE=[1 2;2 1]
new_C=[1,0.5;2,2]
RP=zeros(2,2,2)
RP(:,:,1)=[1 0 ;0 1];
RP(:,:,2)=[0 1 ;-1 0];
dim = size(C,2);
np = numel§;
nb = size(BE,1);
if(~exist(‘RP’,‘var’) || isempty(RP) || all(RP(:)==0))
RP = repmat(eye(dim,dim),[1,1,np])
elseif(numel(RP) == np)
RP = zeros([dim dim np]);
RP(1,1,:) = cos(ANp);
RP(1,2,:) = -sin(ANp);
RP(2,1,:) = sin(ANp);
RP(2,2,:) = cos(ANp);
end
R = repmat(eye(dim,dim),[1,1,np+nb]);
S = repmat(eye(dim,dim),[1,1,np+nb]);
R(1:dim,1:dim,1:np) = RP
if(nb > 0)
rest = C(BE(:,2),:) - C(BE(:,1),:)
rest_norms = normrow(rest);
pose = new_C(BE(:,2),:) - new_C(BE(:,1),:)
pose_norms = normrow(pose)
XR = zeros([dim dim nb]);
phi = -atan2(rest(:,2),rest(:,1))
if(dim == 2)
XR(1,1,:) = cos(phi)
XR(1,2,:) = -sin(phi);
XR(2,1,:) = sin(phi);
XR(2,2,:) = cos(phi);
else
phi_axis = [0*rest(:,1) -rest(:,3) rest(:,2)]
end
S(:,:,(np+1):(np+nb)) = XR;
S(1,:,(np+1):(np+nb)) =XR(1,:,:) .* permute(repmat((pose_norms./rest_norms),[1 dim 1]),[3 2 1])
for( ii = 1:nb)
S(:,:,np+ii) = XR(:,:,ii) \ S(:,:,np+ii)
end
end
C =
1 0
1 1
P =
1 2
BE =
1 2
2 1
new_C =
1 0.5
2 2
RP(:,:,1) =
0 0
0 0
RP(:,:,2) =
0 0
0 0
R(:,:,1) =
1 0
0 1
R(:,:,2) =
0 1
-1 0
R(:,:,3) =
1 0
0 1
R(:,:,4) =
1 0
0 1
rest =
0 1
0 -1
pose =
1 1.5
-1 -1.5
pose_norms =
1.8028
1.8028
phi =
-1.5708
1.5708
XR(:,:,1) =
6.1232e-17 0
0 0
XR(:,:,2) =
6.1232e-17 0
0 0
S(:,:,1) =
1 0
0 1
S(:,:,2) =
1 0
0 1
S(:,:,3) =
1.1039e-16 1.8028
-1 6.1232e-17
S(:,:,4) =
1.1039e-16 -1.8028
1 6.1232e-17
S(:,:,1) =
1 0
0 1
S(:,:,2) =
1 0
0 1
S(:,:,3) =
1 4.9156e-17
4.9156e-17 1.8028
S(:,:,4) =
1.1039e-16 -1.8028
1 6.1232e-17
S(:,:,1) =
1 0
0 1
S(:,:,2) =
1 0
0 1
S(:,:,3) =
1 4.9156e-17
4.9156e-17 1.8028
S(:,:,4) =
1 -4.9156e-17
-4.9156e-17 1.8028