
function [Transform,coeffMass] = GradientTransformation(H,QuadTriangle,curve)

x = QuadTriangle.xnodes;
y = QuadTriangle.ynodes;

%% Gradient of the coordinate transformation: 

% 1s order derivative of psi w.r.t. x1

diff1_psi2 = (y - H).^3 .* ( curve.diffzetap_zeta(x) .* ( curve.zeta(x) - H ).^(-3) ...
       - 3 * curve.diffzeta(x) .* curve.zetap_zeta(x) .* ( curve.zeta(x) - H ).^(-4) ).* (y < H);
 
    
% 1s order derivative of psi w.r.t. x2

diff2_psi2 = 1 + 3 * (y - H).^2 .* curve.zetap_zeta(x) ...
                  .* ( curve.zeta(x) - H ).^(-3) .* (y < H);


%% Compute the determinant of the gradient of the transformation(psi) for ct: 

Det_gradient_psi = abs(diff2_psi2); % ct

%% Compute the inverse of the gradient of the transformation(psi) for At: 

Transform.inv_grad11 =  diff2_psi2 - 1;     

Transform.inv_grad12 = - diff1_psi2 ;

Transform.inv_grad22 = ( 1 + diff1_psi2.^2 )./Det_gradient_psi - 1;


coeffMass = Det_gradient_psi - 1; %ct-1


end
