function heighwaydragon(rez, iter)
% rez - broj tacaka
% iter - broj iteracija
% heighwaydragon(10000, 5000)

pts = zeros(rez,2);
x = rand(1);
y = rand(1);
for j = 1:rez+iter
        p = rand(1);
        if p < 1/2
            xn = 1/2*x-1/2*y;
            yn = 1/2*x+1/2*y;
            x = xn;
            y = yn;
        elseif p < 1
            xn = -1/2*x-1/2*y+1;
            yn = 1/2*x-1/2*y;
            x = xn;
            y = yn;
        end
    pts(j,1) = x;
    pts(j,2) = y;
end%j

xs = pts(iter:end,1);
ys = pts(iter:end,2);
plot(xs,ys,'.g')
axis equal
