function [LTransfo, Kgeom]=computeTransfoBasicToLocal(theGeoTransfo,l,u,qBar)
if theGeoTransfo=="linear"
        [LTransfo, Kgeom]=computeTransfoBasicToLocal_Linear(l);
elseif theGeoTransfo=="corotational"
        [LTransfo, Kgeom]=computeTransfoBasicToLocal_Corotational(l,u,qBar);
end
end

function [LTransfo, Kgeom]=computeTransfoBasicToLocal_Linear(l)
LTransfo = [
    -1, 0, 0, 1, 0, 0;
    0, 1/l, 1, 0, -1/l, 0;
    0, 1/l, 0, 0, -1/l, 1
];

Kgeom = zeros(6,6);
end


function [LTransfo, Kgeom]=computeTransfoBasicToLocal_Corotational(l,u,qBar)
DeltaUx = u(4) - u(1);
DeltaUy = u(5) - u(2);

ln = sqrt((l + DeltaUx)^2 + DeltaUy^2);
beta = atan(DeltaUy / (l + DeltaUx));

c = cos(beta);
s = sin(beta);

LTransfo = [
    -c, -s, 0, c, s, 0;
    -s / ln, c / ln, 1, s / ln, -c / ln, 0;
    -s / ln, c / ln, 0, s / ln, -c / ln, 1
];

term1 = (qBar(1) / ln) * [
    s^2, -c * s, 0, -s^2, c * s, 0;
    -c * s, c^2, 0, c * s, -c^2, 0;
    0, 0, 0, 0, 0, 0;
    -s^2, c * s, 0, s^2, -c * s, 0;
    c * s, -c^2, 0, -c * s, c^2, 0;
    0, 0, 0, 0, 0, 0
];

term2 = ((qBar(2) + qBar(3)) / ln^2) * [
    -2 * s * c, c^2 - s^2, 0, 2 * s * c, -c^2 + s^2, 0;
    c^2 - s^2, 2 * c * s, 0, -c^2 + s^2, -2 * c * s, 0;
    0, 0, 0, 0, 0, 0;
    2 * s * c, -c^2 + s^2, 0, -2 * s * c, c^2 - s^2, 0;
    -c^2 + s^2, -2 * c * s, 0, c^2 - s^2, 2 * c * s, 0;
    0, 0, 0, 0, 0, 0
];

Kgeom = term1 + term2;
end