直接带入数据运算就是最好的注解。V,T,W输入,输出一个U
% LBS Compute linear blend skinning deformation of vertices V, using
% transformations at some control points T, propogated to the mesh using
% weights W.
%
% [U] = lbs(V,T,W)
%
% Inputs:
% V list of vertex positions
% T list of transformations for each controls point, for 2D:
% 2 by 3 by #controls, for 3D: 3 x 4 by # controls
% W weights, # vertices by # handles matrix of weights
% Output:
% U list of new vertex positions
%
% Copyright 2011, Alec Jacobson (jacobson@inf.ethz.ch)
%
% See also: dualquatlbs
V=[1,1;1,1.5]
T=zeros(2,3,2)
T(:,:,1)=[0 1 1;-1 0 2]
T(:,:,2)=[0 1 1;1 0 0]
W=[0.1 0.9;0.2 0.8]
dim = size(V,2);
m = size(T,3)
TT = reshape(permute(T,[2,1,3]),[dim+1,dim*m])’
VV = [V(:,1:dim)’; ones(1,size(V,1))]
VVV = reshape((TT*VV)’,[size(V,1),dim,m])
WW = permute(repmat(W,[1,1,dim]),[1,3,2])
U = sum(WW.*VVV,3)
运行结果:
V =
1 1
1 1.5
T(:,:,1) =
0 0 0
0 0 0
T(:,:,2) =
0 0 0
0 0 0
T(:,:,1) =
0 1 1
-1 0 2
T(:,:,2) =
0 0 0
0 0 0
T(:,:,1) =
0 1 1
-1 0 2
T(:,:,2) =
0 1 1
1 0 0
W =
0.1 0.9
0.2 0.8
m =
2
TT =
0 1 1
-1 0 2
0 1 1
1 0 0
VV =
1 1
1 1.5
1 1
VVV(:,:,1) =
2 1
2.5 1
VVV(:,:,2) =
2 1
2.5 1
WW(:,:,1) =
0.1 0.1
0.2 0.2
WW(:,:,2) =
0.9 0.9
0.8 0.8
U =
2 1
2.5 1