Linear interpolation matrix of three neighbor point values according to distance from interpolation point W = vb_linear_interpolate3(dd) --- Input dd(n,1:3) : n-th distance from interpolation point to three neighbor points --- Output W(n,1:3) : n-th interpolation coefficient --- Interpolation using 'W' y(n,1:3) = Three data values corresponding to the distance dd(n,1:3) y_interp(n) = sum( W(n,1:3) .* y(n,1:3) , 2) y_interp = sum( W .* y , 2) --- Interpolation Linear interpolation of three channel points for one vertex Interpolation point is correspond to origin [0,0] Three data points with distance d(i) are mapped to [x,y] as [x(i),y(i)] = [ex(i) , ey(i)] * d(i) , i=1:3 Linear function in [x,y] space f(x,y) = a*x + b*y + c; D = [ex.*d ; ey.*d ; ones(1,3)] : transfer matrix of three points f(i) = [a, b, c] * D(:,i) , i=1:3 [a, b, c] = f * inv(D) f(0,0) = c = f * inv(D) * [0; 0; 1] = f * ( D \ [0; 0; 1]) M. Sato 2008-8-1 Copyright (C) 2011, ATR All Rights Reserved. License : New BSD License(see VBMEG_LICENSE.txt)
0001 function W = vb_linear_interpolate3(dd) 0002 % Linear interpolation matrix of three neighbor point values 0003 % according to distance from interpolation point 0004 % W = vb_linear_interpolate3(dd) 0005 % --- Input 0006 % dd(n,1:3) : n-th distance from interpolation point to three neighbor points 0007 % --- Output 0008 % W(n,1:3) : n-th interpolation coefficient 0009 % --- Interpolation using 'W' 0010 % y(n,1:3) = Three data values corresponding to the distance dd(n,1:3) 0011 % y_interp(n) = sum( W(n,1:3) .* y(n,1:3) , 2) 0012 % y_interp = sum( W .* y , 2) 0013 % 0014 % --- Interpolation 0015 % Linear interpolation of three channel points for one vertex 0016 % Interpolation point is correspond to origin [0,0] 0017 % Three data points with distance d(i) are mapped to [x,y] as 0018 % [x(i),y(i)] = [ex(i) , ey(i)] * d(i) , i=1:3 0019 % Linear function in [x,y] space 0020 % f(x,y) = a*x + b*y + c; 0021 % D = [ex.*d ; ey.*d ; ones(1,3)] : transfer matrix of three points 0022 % f(i) = [a, b, c] * D(:,i) , i=1:3 0023 % [a, b, c] = f * inv(D) 0024 % f(0,0) = c = f * inv(D) * [0; 0; 1] 0025 % = f * ( D \ [0; 0; 1]) 0026 % 0027 % M. Sato 2008-8-1 0028 % 0029 % Copyright (C) 2011, ATR All Rights Reserved. 0030 % License : New BSD License(see VBMEG_LICENSE.txt) 0031 0032 NP = size(dd,1); 0033 W = zeros(NP,3); 0034 0035 % Three unit vector for three points 0036 theta = [0, 2*pi/3, 4*pi/3]; 0037 ex = cos(theta); 0038 ey = sin(theta); 0039 ez = ones(1,3); 0040 0041 % Linear interpolation of three channel points for one vertex 0042 for n=1:NP 0043 d = dd(n,1:3); 0044 D = [ex.*d ; ey.*d ; ez]; 0045 C = D \ [0; 0; 1]; 0046 W(n,:) = C'; 0047 end