让心跳进跳出
Make the heart bounce in and out
我能够在 matlab 中制作一颗心:
n=100;
x=linspace(-3,3,n);
y=linspace(-3,3,n);
z=linspace(-3,3,n);
[X,Y,Z]=ndgrid(x,y,z);
F=((-(X.^2) .* (Z.^3) -(9/80).*(Y.^2).*(Z.^3)) + ((X.^2) + (9/4).* (Y.^2) + (Z.^2)-1).^3);
isosurface(F,0)
lighting phong
axis equal
能不能让它弹进弹出?可以采取什么方法?
试试这个
step = 0.05;
x = -1.5 : step : 1.5;
y = -1 : step : 1;
z = -1.5 : step : 1.5;
[X,Y,Z] = meshgrid(x, y, z);
f = (X.^2 + 9/4 .* Y.^2 + Z.^2 - 1).^3 - X.^2 .* Z.^3 - 9/80 .* Y.^2 .* Z.^3;
isosurface(X,Y,Z,f,0)
axis tight
axis equal
colormap flag
axis manual
ax = gca;
k=1.25;
ax.XLim = ax.XLim*k;
ax.YLim = ax.YLim*k;
ax.ZLim = ax.ZLim*k;
tempLims.XLim = ax.XLim;
tempLims.YLim = ax.YLim;
tempLims.ZLim = ax.ZLim;
t=0;
heartData = sin((1:250)/100*2*pi)/6.*hamming(250)';
heartData(251:400) = 0;
while 1
t=t+1;
t=mod(t, length(heartData))+1;
k = 1 + heartData(t);
ax.XLim = tempLims.XLim * k;
ax.YLim = tempLims.YLim * k;
ax.ZLim = tempLims.XLim * k;
pause(0.01);
end
我能够在 matlab 中制作一颗心:
n=100;
x=linspace(-3,3,n);
y=linspace(-3,3,n);
z=linspace(-3,3,n);
[X,Y,Z]=ndgrid(x,y,z);
F=((-(X.^2) .* (Z.^3) -(9/80).*(Y.^2).*(Z.^3)) + ((X.^2) + (9/4).* (Y.^2) + (Z.^2)-1).^3);
isosurface(F,0)
lighting phong
axis equal
能不能让它弹进弹出?可以采取什么方法?
试试这个
step = 0.05;
x = -1.5 : step : 1.5;
y = -1 : step : 1;
z = -1.5 : step : 1.5;
[X,Y,Z] = meshgrid(x, y, z);
f = (X.^2 + 9/4 .* Y.^2 + Z.^2 - 1).^3 - X.^2 .* Z.^3 - 9/80 .* Y.^2 .* Z.^3;
isosurface(X,Y,Z,f,0)
axis tight
axis equal
colormap flag
axis manual
ax = gca;
k=1.25;
ax.XLim = ax.XLim*k;
ax.YLim = ax.YLim*k;
ax.ZLim = ax.ZLim*k;
tempLims.XLim = ax.XLim;
tempLims.YLim = ax.YLim;
tempLims.ZLim = ax.ZLim;
t=0;
heartData = sin((1:250)/100*2*pi)/6.*hamming(250)';
heartData(251:400) = 0;
while 1
t=t+1;
t=mod(t, length(heartData))+1;
k = 1 + heartData(t);
ax.XLim = tempLims.XLim * k;
ax.YLim = tempLims.YLim * k;
ax.ZLim = tempLims.XLim * k;
pause(0.01);
end