% Copyright (C) 2023 Alberto Bucci
% MATLAB code that generates the PYSANUM logo
%
%% basement
t = 0:pi/10:2*pi;
r = 0.5+0.002*cos(6*t);
[X,Y,Z] = cylinder(r);
surf(X+0.4*Z,Y,3*Z,'FaceAlpha',0.8)
hold on
%% top
u = 0:pi/10:2*pi;
r = 0.32;
[X,Y,Z] = cylinder(r);
surf(X+0.14*(0.15*Z+3),Y,0.15*Z+3)
surf(X+0.14*(0.15*Z+3.15),Y,0.15*Z+3.15)
surf(X+0.14*(0.15*Z+3.3),Y,0.15*Z+3.3)
axis equal
axis off
%% level rings
for i = 1:7
[theta,phi] = meshgrid(linspace(0,2*pi,20));
r = 0.05;
R = 0.5;
x = (R + r*cos(theta)).*cos(phi);
y = (R + r*cos(theta)).*sin(phi);
z = (r*sin(theta)+6*i/14);
x = x+0.14*z;
surf(x,y,z)
end
%shading interp
%colormap hot
%% top ring
[theta,phi] = meshgrid(linspace(0,2*pi,20));
r = 0.05;
R = 0.32;
x = (R + r*cos(theta)).*cos(phi);
y = (R + r*cos(theta)).*sin(phi);
z = (r*sin(theta))+3.4;
x = x+0.14*z;
surf(x,y,z)
%% floor
[theta,r] = meshgrid(linspace(0,2*pi,20));
x = r.*cos(theta)/(4*pi);
y = r.*sin(theta)/(4*pi);
s = size(x);
z = zeros(s);
surf(x,y,z)
%% ceiling
[theta,r] = meshgrid(linspace(0,2*pi,10));
x = (r.*cos(theta)/(4*pi));
y = r.*sin(theta)/(4*pi);
s = size(x);
z = zeros(s)+3;
x = x + 0.14*z;
surf(x,y,z)
%% top ceiling
[theta,r] = meshgrid(linspace(0,2*pi,10));
x = (r.*cos(theta)/(7*pi));
y = r.*sin(theta)/(7*pi);
s = size(x);
z = zeros(s)+3.4;
x = x + 0.14*z;
surf(x,y,z)
%% lateral columns
for i = 0:pi/10:2*pi %20 columns
t = 0:pi/2:2*pi;
r = 0.08+0.0002*cos(1/2*t);
[X,Y,Z] = cylinder(r);
X = 0.49*(X+cos(i));
Y = 0.49*(Y+sin(i));
surf(X+0.41*Z,Y,3*Z)
end
%% top columns
for i = 0:pi/5:2*pi %20 columns
t = 0:pi/2:2*pi;
r = 0.08+0.0002*cos(1/2*t);
[X,Y,Z] = cylinder(r);
X = 0.35*(X+cos(i));
Y = 0.35*(Y+sin(i));
surf(X+0.141*(Z*0.4+3),Y,Z*0.4+3)
end