function [N,DNX,DNY,DJ] = gp2dlf(X,Y,XI,ETA)
% GAUSS POINT 2 DIMENSIONAL LINEAR FINITE
% THIS PROGRAM WAS LAST UPDATED ON 10-27-83
% BY JOHN M. SULLIVAN, JR.   THE PROGRAM PERFORMS
% GAUSS QUADRATURE. LINEAR IN (XI) AND (ETA) DIRECTIONS
%
%      *----------*
%      %4        3%
%      %          %   NODE ORDERING IS CCW, 
%      %1        2%    FIRST NODE LOCATION
%      *----------*     IS NOT CRITICAL.
%
% STANDARD SERINDEPITY FINITE FORMULATIONS
N = zeros(4,1);    DJA = zeros(4,1);
DNX = zeros(4,1);  DNY = zeros(4,1);
DNE = zeros(4,1);  DNXI = zeros(4,1);
%
% BASIS FUNCTIONS FOR UNKNOWNS (I.E. TEMPERATURE)
N(1) = 0.25*(1.-XI)*(1.-ETA);  N(2) = 0.25*(1.+XI)*(1.-ETA);
N(3) = 0.25*(1.+XI)*(1.+ETA);  N(4) = 0.25*(1.-XI)*(1.+ETA);
%
% DERIVATIVES OF BASIS FUNCTIONS W.R.T. XI DIRECTION
DNXI(1) = -0.25*(1.-ETA);
DNXI(2) = 0.25*(1.-ETA);
DNXI(3) = 0.25*(1+ETA);
DNXI(4) = -0.25*(1.+ETA);
%
% DERIVATIVES OF BASIS FUNCTIONS W.R.T. ETA DIRECTION
DNE(1) = -0.25*(1.-XI);
DNE(2) = -0.25*(1.+XI);
DNE(3) = 0.25*(1+XI);
DNE(4) = 0.25*(1-XI);
%
% JACOBIAN
for I=1:4
    DJA(1)=X(I)*DNXI(I) + DJA(1);
    DJA(2)=Y(I)*DNXI(I) + DJA(2);
    DJA(3)=X(I)*DNE(I)  + DJA(3);
    DJA(4)=Y(I)*DNE(I)  + DJA(4);
end
DJ = DJA(1)*DJA(4) - DJA(2)*DJA(3);
%
% DERIVATIVES W.R.T. X AND Y
for I=1:4
    DNX(I) = (DJA(4)*DNXI(I)-DJA(2)*DNE(I))/DJ;
    DNY(I) = (-DJA(3)*DNXI(I) + DJA(1)*DNE(I))/DJ;
end
end
