Small Satellites

Home » 2014 (Page 3)

Yearly Archives: 2014

Ulam spiral,Prime factors spiral

 

Ulam spiral,prime spiral

clc; clear all; close all;
sz  = 201;
mat = spiral(sz);
pm  = ~isprime(mat);
figure('Position',[0 0 800 800]);
imagesc(pm);
colormap bone;
caxis([0, 1]);axis off;

PrimeSquare

Prime factor colormap

Black dots are prime numbers. As lighter is the dot as higher is the number of prime factors of that number in the Ulam spiral.

sz  = 201;
mat  = spiral(sz);
matf = zeros(sz);
for i = 1:sz
    for j = 1:sz
         fac = factor(mat(i,j));
         fm = size(fac);
         matf(i,j) = fm(2);
    end
end
figure('Position',[0 0 800 800]);
imagesc(matf);
colormap hot;
caxis([1, max(matf(:))]);axis off;

Prime Factor Color-map

Ulam spiral of prime number of prime factors

Black dots corespondend to the numbers in Ulam spiral which has a prime number of prime factors.

sz  = 201;
mat  = spiral(sz);
matf = zeros(sz);
for i = 1:sz
    for j = 1:sz
         fac = factor(mat(i,j));
         fm = size(fac);
         matf(i,j) = fm(2);
    end
end
figure('Position',[0 0 800 800]);
pm  = ~isprime(matf);
%sum(pm(:));
imagesc(pm);
colormap bone;
caxis([0, 1]);axis off;

PrimeFactror


Henneberg surface, Matlab code

close all; clc;clear all;

[u v] = meshgrid(0:0.1:1);
%v = meshgrid(1:0.01:2);
i = 1;
for u =-pi/2: 0.1:pi/2
    j =1;
    for v = -pi/2:0.1:pi/2
        x(i,j) = 2*sinh(u)*cos(v) - 2/3*sinh(3*u)*cos(3*v);
        y(i,j) = 2*sinh(u)*sin(v) - 2/3*sinh(3*u)*sin(3*v);
        z(i,j) = 2*cosh(2*u)* cos(2*v);
        j = j+1;
    end
    i = i+1;
end
surf(y,x,z);
axis off;

Hennebergsurface

 

Ford Circles

clc; close all; fi = 0:0.01:2*pi;

figure('Position',[0 0 500 500])
hold on;
for h =1:15
    for k = 1:15
        R  = 1/(2*k^2);
        x  = h/k + R*sin(fi);
        y  = 1/(2*k^2) + R*cos(fi);
        plot(x,y,'k');
        % Symmetric
        y  = -(1/(2*k^2) + R*cos(fi));
        plot(x,y,'k');
    end
end
axis([0, 2.2,-1.1, 1.1 ]);axis off;

 

FordCircles


 

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

Box Fractals

clc; clear all; close all;

a = 1;
figure('Position',[0 0 800 800])
for i = 1 :5
   [n m] = size(a);
    Z = zeros(n,m);
    a = [a,Z,a;
         a,a,a;
         a,Z,a
         ];
end
imagesc(a);
colormap bone;axis off;
caxis([0, 1]);

CubeFractals

clc; clear all;
a = 1;
figure('Position',[0 0 800 800])
for i = 1 :5
   [n m] = size(a);
    Z= zeros(n,m);
    a = [Z,a,Z;
         a,a,a;
         Z,a,Z
         ];
end
imagesc(a);
colormap bone;axis off;
caxis([0, 1]);

CubeFractals_02

clc; clear all;
a = 1;
figure('Position',[0 0 800 800])
for i = 1 :5
   [n m] = size(a);
    Z= zeros(n,m);
    a = [a,a,a;
         a,Z,a;
         a,a,a
         ];
end
imagesc(a);
colormap bone;axis off;
caxis([0, 1]);

CubeFractals

clc; clear all;
a = 1;
figure('Position',[0 0 800 800])
for i = 1 :5
   [n m] = size(a);
    Z= zeros(n,m);
    a = [a,Z,a;
         Z,a,Z;
         a,Z,a
         ];
end
imagesc(a);
colormap bone;axis off;
caxis([0, 1]);

CubeFractals_04
clc; clear all;
a = 1;
figure('Position',[0 0 800 800])
for i = 1 :5
   [n m] = size(a);
    Z= zeros(n,m);
    if mod(i,2) == 0
    a = [Z,a,a;
         a,a,a;
         a,a,a
         ];
    else
          a = [a,a,a;
               a,Z,a;
               a,a,a
             ];
    end
end
imagesc(a);
colormap bone;axis off;
caxis([0, 1]);

 

 

%d bloggers like this: