• Remix
  • Share
  • New Entry

on 29 Nov 2023
  • 5
  • 1
  • 1
  • 0
  • 1135
drawframe(1);
Write your drawframe function below
function drawframe(f)
D0 = 7.82;
a0 = 0.0518;
a1 = 2.0026;
a2 = -4.491;
noR = 15;
rMax = D0/2;
figure('Color', [0.89, 0.79, 0.34])
rng(1,'twister')
r = linspace(0, rMax, noR)';
fact = 0.8;
radd = (1 - fact) * r(end-1) + fact * r(end);
r = [r(1:end-1); radd; r(end)];
dr = r(2) - r(1);
Rs = [];
Phi = [];
for k = 1:noR
L = 2 * pi * r(k);
noPhi = round(L / dr);
phi = linspace(0, 2 * pi * (noPhi - 1)/noPhi, noPhi)';
Rs = [Rs; r(k) * ones(noPhi, 1)];
Phi = [Phi; phi];
end
[x, y] = pol2cart(Phi, Rs);
t = x.^2 + y.^2;
z = D0 * sqrt(1 - 4 * t / D0^2) .* (a0 + (a1 * t) / D0^2 + (a2 * t.^2) / D0^4);
L = 2 * pi * rMax;
noPhi = round(L / dr);
phi = linspace(0, 2 * pi * (noPhi - 1)/noPhi, noPhi)';
[xm, ym] = pol2cart(phi, rMax * ones(noPhi, 1));
zm = zeros(noPhi, 1);
x = [x; xm];
y = [y; ym];
z = [z; zm];
tri = delaunay(x, y);
for subplotIndex = 1:50
xPos = rand()*f/10;
yPos = rand()*f/10;
ax = axes('Position', [xPos, yPos, 0.1, 0.1]);
trisurf(tri, x, y, z, 'FaceColor', 'r', 'FaceLighting', 'Phong', 'EdgeColor', 'none', 'Parent', ax);
material shiny;
hold on;
trisurf(tri, x, y, -z, 'FaceColor', 'r', 'FaceLighting', 'Phong', 'EdgeColor', 'none', 'Parent', ax);
material shiny;
axis off;
camlight('headlight');
axis equal;
axis off
end
axis off
end
Animation
Remix Tree