function N = shpNmatrix2D(r,s)
% Evaluates 2D shape function matrix.
% Evaluates shape functions (in parametric coordinates) at point (r,s)
% for 2D elements.
% Input arguments:
%  r:    first parametric coordinate value
%  s:    second parametric coordinate value
% Output arguments:
%  N:    shape function matrix evaluated at given position

 include_gblrefs;

 N = zeros(1,nen);

 if(element_type == TRIA3)         % linear triangle element
 % 
 %                           s
 %                           ^
 %                           |
 %     
 %                         3 +
 %                           |\
 %                           | \
 %                           |  \
 %                           |   \ TRIA3
 %                           |    \
 %                         1 +-----+ 2  ----> r
 %
  N(1) = 1.0 - r - s;
  N(2) = r;
  N(3) = s;

 elseif(element_type == QUAD4)     % bilinear quadrilateral element
 % 
 %                         4 +---------------+ 3
 %                           |       s       |
 %                           |       ^       |
 %                           |       |       |
 %                           |       ----> r |
 %                           |               |
 %                           |     QUAD4     |
 %                           |               |
 %                         1 +---------------+ 2
 %
 %
  %%% COMPLETE HERE 03 %%%

 elseif(element_type == TRIA6)     % quadratic triangle element
 % 
 %                           s
 %                           ^
 %                           |
 %     
 %                         3 +
 %                           |\
 %                           | \
 %                         6 +  + 5
 %                           |   \ TRIA6
 %                           |    \
 %                         1 +--+--+ 2  ----> r
 %                              4
 %
  %%% COMPLETE HERE 04 %%%

 elseif(element_type == QUAD8)     % serendipity quadratic quadrilateral element
 % 
 %                                   7
 %                         4 +-------+-------+ 3
 %                           |       s       |
 %                           |       ^       |
 %                           |       |       |
 %                         8 +       ----> r + 6
 %                           |               |
 %                           |     QUAD8     |
 %                           |               |
 %                         1 +-------+-------+ 2
 %                                   5
 %
  %%% COMPLETE HERE 05 %%%

 end

end
