- /
-
A pair of green apple
on 18 Oct 2024
- 29
- 98
- 0
- 0
- 1100
PPAP by Pikotaro
drawframe(1);
Write your drawframe function below
% An Apple a day keep The Doctor away
% Graph of Equation created by Dhimas Mahardika S.Si., M.Mat.
% from Sanggung Utara, Jatingaleh, Candisari
% Universitas Diponegoro
% Universitas Nasional Karangturi
% function drawframe(f)
% h = linspace(0,2*pi,100);
% syms x y z
% m=y*sin(h(f))+x*cos(h(f))
% n=x*sin(h(f))-y*cos(h(f))
% p=x^2+y^2-(x^2+y^2+0.5*z^2).^2
% q=abs(2.2*sqrt(x^2+y^2)+0.2*z-0.08)+abs(2.2*sqrt(x^2+y^2)-0.2*z+0.08)-0.25
% eqn = q.*p.*(abs((2.2*n+0.836).^2+abs(1.54*n+3.3*z-2.7148)+11*m) + abs((2.2*n+0.836).^2+abs(1.54*n+3.3*z-2.7148)-11*m)-1.25) == 0;
% fimplicit3(eqn,[-1.5,1.5,-1.5,1.5,-1.5,1.5],'EdgeColor','none','FaceAlpha',1);
% colormap(autumn)
% axis equal
% axis off
% end
function drawframe(f)
h = linspace(0, 2 * pi, 100);
syms x y z
% First apple
m = y * sin(h(f)) + x * cos(h(f));
n = x * sin(h(f)) - y * cos(h(f));
p = x^2 + y^2 - (x^2 + y^2 + 0.5 * z^2).^2;
q = abs(2.2 * sqrt(x^2 + y^2) + 0.2 * z - 0.08) + abs(2.2 * sqrt(x^2 + y^2) - 0.2 * z + 0.08) - 0.25;
eqn1 = q .* p .* (abs((2.2 * n + 0.836).^2 + abs(1.54 * n + 3.3 * z - 2.7148) + 11 * m) ...
+ abs((2.2 * n + 0.836).^2 + abs(1.54 * n + 3.3 * z - 2.7148) - 11 * m) - 1.25) == 0;
% Second apple (translated along x-axis by distance d)
d = 2; % Distance of translation along x-axis
m2 = (y * sin(h(f)) + (x - d) * cos(h(f)));
n2 = ((x - d) * sin(h(f)) - y * cos(h(f)));
p2 = (x - d)^2 + y^2 - ((x - d)^2 + y^2 + 0.5 * z^2).^2;
q2 = abs(2.2 * sqrt((x - d)^2 + y^2) + 0.2 * z - 0.08) + abs(2.2 * sqrt((x - d)^2 + y^2) - 0.2 * z + 0.08) - 0.25;
eqn2 = q2 .* p2 .* (abs((2.2 * n2 + 0.836).^2 + abs(1.54 * n2 + 3.3 * z - 2.7148) + 11 * m2) ...
+ abs((2.2 * n2 + 0.836).^2 + abs(1.54 * n2 + 3.3 * z - 2.7148) - 11 * m2) - 1.25) == 0;
% Create figure
figure;
% Plot the first apple with colormap "autumn"
fimplicit3(eqn1, [-1.5, 1.5, -1.5, 1.5, -1.5, 1.5], 'EdgeColor', 'none', 'FaceAlpha', 1);
hold on;
% Plot the second apple (translated) with colormap "winter"
fimplicit3(eqn2, [-1.5 + d, 1.5 + d, -1.5, 1.5, -1.5, 1.5], 'EdgeColor', 'none', 'FaceAlpha', 1);
colormap(summer); % Apply different colormap to the second apple
% Adjust properties
axis equal;
axis off;
hold off;
end