Ignore:
Timestamp:
Apr 29, 2011, 6:44:35 PM (13 years ago)
Author:
sommeria
Message:

thin plate shell corrected for spatial derivatives

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/tps_eval_dxy.m

    r246 r247  
    1111%            N centres, with s=space dimension, DMXY(:,:,k) gives the derivatives
    1212%            along dimension k (=x, y,z) after multiplication by the N+1+s tps sources.
    13   function DMXY = tps_eval_dxy(dsites,ctrs)
     13  function [DMX,DMY] = tps_eval_dxy(dsites,ctrs)
    1414  %%  matrix declarations
    1515  [M,s] = size(dsites); [N,s] = size(ctrs);
    16   Dsites=zeros(M,N,s);
     16  Dsites=zeros(M,N);
    1717  DM = zeros(M,N);
    18   DMXY = zeros(M,N+1+s,s);
     18 % DMXY = zeros(M,N+1+s);
    1919 
    2020  %% Accumulate sum of squares of coordinate differences
     
    2424  %  Ctrs, consisting of M identical rows (each containing
    2525  %       the d-th coordinate of the N centers)
    26   for d=1:s
    27      [Dsites(:,:,d),Ctrs] = ndgrid(dsites(:,d),ctrs(:,d));%d coordinates of interpolation points (Dsites) and initial points (Ctrs)
    28      DM = DM + (Dsites(:,:,d)-Ctrs).^2;% add d component squared
    29   end
    3026 
    31   %% calculate mtrix of tps derivatives
    32   DM(DM~=0) = log(DM)+1; %=2 log(r)+1 derivative of the tps r^2 log(r)
    33   for d=1:s
    34     DMXY(:,1:N,d)=Dsites(:,:,d).*DM;
    35     DMXY(:,N+1+d,d)=1;% effect of mean gradient
    36   end
     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 TracChangeset for help on using the changeset viewer.