Small Satellites

Home » Fractals » Dragon Fractal

Dragon Fractal

clc; clear all; close all;

a  = ones(1);
for i = 1:12
    sz = size(a);
    b  = a;
    ind = ceil(sz(2)/2);
    b(ind) = ~(b(ind));
    sz = size(a);
    a = [a,1,b];
end
st = 1; % Step
len = size(a);
x0 = 0; y0 = 0; %Initial
Lv = 0; % Looking along positive x axis
for i = 1:len(2)
     x1 = x0 - sin(Lv)*st;
     y1 = y0 + cos(Lv)*st;
    if a(i) == 1
        Lv = Lv + pi/2;
    else
        Lv = Lv - pi/2;
    end
    xv(i) = x1;
    yv(i) = y1;
    x0 = x1;
    y0 = y1;
end
fig = figure('Position',[0 0 800 800]);
set(fig, 'color', [0 0 0]);
plot(xv,yv,'clipping','off')
axis off;

Dragon Fractal

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Recent Post

%d bloggers like this: