function [ x, y, r ] = triangulo_sierpinski( N )

x = zeros( N, 1 );
y = zeros( N, 1 );
r = zeros( N, 1 );

prob = [1 1 1]/3;
% x(1) = rand*2;
% y(1) = rand*2;
x(1) = 1;
y(1) = 1;
for n = 1 : N-1
    r(n+1) = gera_aleatorio( prob, 1 );
    switch( r(n+1) )
        case{ 1 }
            x(n+1) = x(n)/2;
            y(n+1) = y(n)/2;
        case{ 2 }
            x(n+1) = x(n)/2 + 1;
            y(n+1) = y(n)/2;
        case{ 3 }
            x(n+1) = x(n)/2 + 0.5;
            y(n+1) = y(n)/2 + 1;
    end
end
