我能够在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
是否有可能让它反弹?可能会采取什么方法?
答案 0 :(得分:1)
试试这个
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