function IntrpDisp = interpolateDisplacement(obj,varargin)
%interpolateDisplacement - Interpolate displacement at specified spatial locations
% IntrpDisp = interpolateDisplacement(R,QP) interpolates all components of
% displacements in a StaticStructuralResults object R at the query point
% locations QP. The points QP are represented as an Ndim-by-Numq matrix,
% where Ndim is the number of spatial dimensions, and Numq is the number of
% query points. The output IntrpDisp is an FEStruct object with the properties that
% represent the spatial components of displacement at the query points QP.
%
% IntrpDisp = interpolateDisplacement(R,xq,yq) and 
% IntrpDisp = interpolateDisplacement(R,xq,yq,zq) interpolates the displacements
% to the query points specified as vectors of coordinates or an N-D grid.
%
% % Example: Solve the following static structural model representing a %
% % bimetallic cable under tension and interpolate displacement on a
% % cross-section.
% 
%   structuralmodel = createpde('structural','static-solid');
%   structuralmodel.Geometry = multicylinder([0.01,0.015],0.05);
%   pdegplot(structuralmodel,'FaceLabels','on')
%   structuralProperties(structuralmodel,'Cell',1,'YoungsModulus',110E9, ...
%                                              'PoissonsRatio',0.28);
%   structuralProperties(structuralmodel,'Cell',2,'YoungsModulus',210E9, ...
%                                              'PoissonsRatio',0.3);
% 
%   structuralBC(structuralmodel,'Face',[1,4],'Constraint','fixed');
%   structuralBoundaryLoad(structuralmodel,'Face',[2,5],'SurfaceTraction',[0,0,100]);
%   generateMesh(structuralmodel);
%   R = solve(structuralmodel)
% 
%   % Define coordinates of mid-span cross-section and interpolate displacement.
%   [X,Y] = meshgrid(linspace(-0.015,0.015,50));
%   Z = ones(size(X))*0.025;
%   IntrpDisp = interpolateDisplacement(R,X,Y,Z);
%   surf(X,Y,reshape(IntrpDisp.uz,size(X)))
%
%
% See also pde.StructuralModel/solve,
% pde.StaticStructuralResults/interpolateStress, 
% pde.StaticStructuralResults/interpolateStrain,
% pde.StaticStructuralResults/evaluateReaction

% Copyright 2017-2022 The MathWorks, Inc.

dim = pde.StructuralResults.spatialDimension(obj);
uinterp = pde.StructuralResults.interpolateSolutionInternal(obj,obj.Interpolant,varargin{:},1:dim);
IntrpDisp = FEStruct('Displacement',obj.ElasticityType,uinterp);
end

