clear all;     
clc; 
r = linspace(-1,1,100);
s = linspace(-1,1,100);

daugh = [1 3 3.5 1.5 2 3.25 2.5 1.25; 1 1.5 4 2.5 1.35 2.25 3.5 1.75];  %coordinates of nodes of daughter element

for i =1:100
    %from node 1 to node 2 (s = -1)
    z = daugh*[-0.5*(1-r(i))*r(i); 0.5*(1+r(i))*r(i); 0; 0; 1-r(i)^2; 0; 0; 0];
    x1_2(i) = z(1);
    y1_2(i)= z(2);
    
    %from node 2 to node 3 (r = 1)
    z = daugh*[0; -0.5*(1-s(i))*s(i); 0.5*(1+s(i))*s(i); 0; 0; 1-s(i)^2; 0; 0];
    x2_3(i) = z(1);
    y2_3(i)= z(2);
    
    %from node 3 to node 4 (s = 1)
    z = daugh*[0; 0; 0.5*(1+r(i))*r(i); -0.5*(1-r(i))*r(i); 0; 0; 1-r(i)^2; 0];
    x3_4(i) = z(1);
    y3_4(i)= z(2);
    
    %from node 4 to node 1 (r = -1)
    z = daugh*[-0.5*(1-s(i))*s(i); 0; 0; 0.5*(1+s(i))*s(i); 0; 0; 0; 1-s(i)^2];
    x4_1(i) = z(1);
    y4_1(i)= z(2);
end

plot(x1_2,y1_2,'r', x2_3,y2_3,'b',x3_4, y3_4, 'g', x4_1, y4_1, 'k');