%This function calculates the attractor of a specific IFS of R^2, 
%using the Deterministic Algorithm.
%Input: A0, W, N, K
%A0 is the initial set represented by a Mx2 matrix
%N is the number of the mappings 
%K is the number of iterations
%W is the matrix Nx6 containing the parameters of the mappings 
%Each row (i) contains the 6 coefficients of the map w_i. a,b,c,s,d,e
%  /      \   /   \
%  |a    b|   | d |
%w=|      | + |   |
%  |c    s|   | e |
%  \      /   \  /
%Output: B
%The function returns the matrix B N^K x 2!!!


function B=MYDIA_R2(A0,W,N,K)

A=A0;
[M,l]=size(A0);
points=M;
for (i=1:K)
    for j=1:points %for every point
        x=A(j,1);
        y=A(j,2);
        for r=1:N %map the point through each map
            B(points*(r-1)+j,1)=W(r,1)*x+W(r,2)*y+W(r,5);
            B(points*(r-1)+j,2)=W(r,3)*x+W(r,4)*y+W(r,6);
        end;
    end;
    points=M*N^i;
    A=B;
end;
end;
