# source:trunk/src/tps_eval_dxy.m@247

Last change on this file since 247 was 247, checked in by sommeria, 10 years ago

thin plate shell corrected for spatial derivatives

File size: 1.6 KB
RevLine
1% 'DXYMatrix': calculate the matrix of thin-plate shell derivatives
2%
3% function DMXY = DXYMatrix(dsites,ctrs)
4%
5% INPUT:
6%   dsites: M x s matrix of interpolation site coordinates (s=space dimension)
7%   ctrs: N x s matrix of centre coordinates (initial data)
8%
9% OUTPUT:
10%     DMXY: Mx(N+1+s)xs matrix corresponding to M interpolation sites and
11%            N centres, with s=space dimension, DMXY(:,:,k) gives the derivatives
12%            along dimension k (=x, y,z) after multiplication by the N+1+s tps sources.
13  function [DMX,DMY] = tps_eval_dxy(dsites,ctrs)
14  %%  matrix declarations
15  [M,s] = size(dsites); [N,s] = size(ctrs);
16  Dsites=zeros(M,N);
17  DM = zeros(M,N);
18 % DMXY = zeros(M,N+1+s);
19
20  %% Accumulate sum of squares of coordinate differences
21  % The ndgrid command produces two MxN matrices:
22  %   Dsites, consisting of N identical columns (each containing
23  %       the d-th coordinate of the M interpolation sites)
24  %  Ctrs, consisting of M identical rows (each containing
25  %       the d-th coordinate of the N centers)
26
27[Dsites,Ctrs] = ndgrid(dsites(:,1),ctrs(:,1));%d coordinates of interpolation points (Dsites) and initial points (Ctrs)
28DX=Dsites-Ctrs;
29[Dsites,Ctrs] = ndgrid(dsites(:,2),ctrs(:,2));%d coordinates of interpolation points (Dsites) and initial points (Ctrs)
30DY=Dsites-Ctrs;
31DM = DX.*DX + DY.*DY;% add d component squared
32
33 %% calculate matrix of tps derivatives
34DM(DM~=0) = log(DM(DM~=0))+1; %=2 log(r)+1 derivative of the tps r^2 log(r)
35
36DMX=[DX.*DM zeros(M,1)  ones(M,1) zeros(M,1)];% effect of mean gradient
37DMY=[DY.*DM zeros(M,1)  ones(M,1) zeros(M,1)];% effect of mean gradient
38
Note: See TracBrowser for help on using the repository browser.