Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 3d79df48 authored by DIB Elian's avatar DIB Elian
Browse files

Added function to compute coordinates with respect to a scattered grid

parent adb045d1
Branches
No related tags found
No related merge requests found
function [Xq,Yq,X,Y,varargout] = gridCoords(X,Y,Xq,Yq,varargin)
%GRIDCOORDS Summary of this function goes here
% Detailed explanation goes here
sz = size(Xq);
[t,I] = utils.triangulation(X,Y,varargin{:});
[ind,b] = t.pointLocation(Xq(:),Yq(:));
ind = reshape(ind,sz);
u = reshape(b(:,2),sz);
v = reshape(b(:,3),sz);
nanind = isnan(ind);
ind(nanind) = 1;
ind = I(ind);
ut = ~mod(ind,2);
ind(nanind) = nan;
[x,y] = ind2sub(size(X)-1,ceil(ind/2));
u(ut) = 1-u(ut);
v(ut) = 1-v(ut);
Xq = x+u;
Yq = y+v;
[X,Y] = ndgrid(1:size(X,1),1:size(X,2));
if nargout>0; varargout{1} = u; end
if nargout>1; varargout{2} = v; end
if nargout>2; varargout{3} = x; end
if nargout>3; varargout{4} = y; end
if nargout>4; varargout{5} = ind; end
if nargout>5; varargout{6} = t; end
if nargout>6; varargout{7} = I; end
end
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment