如何在MatLab中使用良好的感觉来制作3D心脏?

时间:2022-10-29 01:33:27

I want to make a 3D heart,append at least two effects to the heart, such as materials, lights, and so on.And make an animation by using the heart,and the animation are supposed to make good sense. My Imagination is:the heart can move.Run up against walls,after several collisions the heart became larger.it means after hardships and dangers one man can be stronger.

我想做一个3D心脏,至少对心脏有两种效果,比如材料,灯光,等等。用心脏做一个动画,动画应该是有意义的。我的想象是:心可以移动。撞到墙上,几次碰撞后,心脏变得更大了。这意味着在经历了困难和危险之后,一个人可以变得更强大。

I'VE FINISHED A 3D HEART, BUT WITHOUT MATERIALS OR ANIMATION:

我已经完成了3D心脏,但是没有材料和动画:

  %(x^2 + (9/4)y^2 + z^2 - 1)^3 - x^2z^3 - (9/80)y^2z^3 = 0 -3<=x,y,z<=3
[x,y,z]=meshgrid(linspace(-3,3));                            %做出网格meshgrid                                     
p=(x.^2+(9/4)*y.^2+z.^2-1).^3-x.^2.*z.^3-(9/80)*y.^2.*z.^3;  %实现结果的表达
isosurface(x,y,z,p,0);                                       %使用函数做图mesh surf

axis equal;
axis off;
view(0,35);          %视角的控制
colormap([1 0 0]);   %绘图颜色红色
brighten(1.0);       %增亮
camlight left;      %光源位置
lighting p;      %光照模式

HERE IS WHAT I'VE SEARCHED IN THE INTERNET,ABOUT A BALL RUNNING UP AGAINST A WALL

这是我在互联网上搜索到的,一个球碰到墙上的情况。

figure(1);%定义函数
axis([-5.1,5,-0.05,1.05]);%绘制二维图形
hold on;%保持当前图形及轴系所有的特性
axis('off');%覆盖坐标刻度,并填充背景
%通过填充绘出台阶及两边的挡板
fill([4.12,4.22,4.22,4.12],[-0.05,-0.05,1.05,1.05],'y');
fill([-5,-3.2,-3.2,-5],[-0.05,-0.05,0,0],'g');
fill([-3.2,-2.8,-2.8,-3.2],[-0.05,-0.05,0.2,0.2],'g');
fill([-3.2,-1.4,-1.4,-3.2],[0.2,0.2,0.25,0.25],'g');
fill([-1.4,-1,-1,-1.4],[0.2,0.2,0.45,0.45],'g');
fill([-1.4,0.4,0.4,-1.4],[0.45,0.45,0.5,0.5],'g');
fill([0.4,0.8,0.8,0.4],[0.45,0.45,0.7,0.7],'g');
fill([0.4,2.0,2.0,0.4],[0.7,0.7,0.75,0.75],'g');
fill([2.0,2.3,2.3,2.0],[-0.05,-0.05,0.75,0.75],'g');
fill([2.3,4.12,4.12,2.3],[-0.05,-0.05,0,0],'g');
%x2=line([-5,5],[0.25,0.25],'color','g','linestyle','-', 'markersize',50)%设置台阶边框线,颜色,擦试方式
%line([-5,5],[0.5,0.5],'color','b','linestyle','-', 'markersize',50)%设置球与地面接触面的颜色,擦试方式
%line([-5,5],[0.75,0.75],'color','b','linestyle','-', 'markersize',50)%设置球与地面接触面的颜色,擦试方式
head=line(-5,1,'color','r','linestyle','.','erasemode','xor', 'markersize',60);%设置小球颜色,大小,线条和擦试方式
%body=line(-5,1,'color','b','linestyle','-','erasemode','none'); %描绘轨迹线
%设置初始条件
while 1
t=4;
dt=0.001;
w=0;
dw=0.001;
w=0;%设置球弹起的初始位置
%设置球弹起的高度
while t<=4.12
    t=dt+t;
if w<=1
    w=dw+w;
else
    w=-1;
end
y=(-w*w)+1;
set(head,'xdata',t,'ydata',y);%设置球的运动
%set(body,'xdata',t,'ydata',y);%描绘轨迹线
drawnow;
end %结束程序
w=0;%设置球弹起的初始位置
%设置球弹起的高度
while t>=2.11
    t=t-dt;
if w<=1
    w=dw+w;
else
    w=-1;
end
y=(-w*w)+1;
set(head,'xdata',t,'ydata',y);%设置球的运动
%set(body,'xdata',t,'ydata',y);%描绘轨迹线
drawnow;
end %结束程序
w=0;%设置球弹起的初始位置
  %设置球弹起的高度
while t>=1.11
    t=t-dt;
if w<=1
    w=dw+w;
else
    w=-1;
end
y=(-w*w)/4+1;
set(head,'xdata',t,'ydata',y);%设置球的运动
%set(body,'xdata',t,'ydata',y);%描绘轨迹线
drawnow;
end %结束程序
w=-0.71;%设置球弹起的初始位置
  %设置球弹起的高度
while t>=-0.62
    t=t-dt;
if w<=1
    w=dw+w;
else
    w=-1;
end
y=(-w*w)/2+1;
set(head,'xdata',t,'ydata',y);%设置球的运动
%set(body,'xdata',t,'ydata',y);%描绘轨迹线
drawnow;
end %结束程序
w=-0.71;%设置球弹起的初始位置
  %设置球弹起的高度
while t>=-2.31
    t=t-dt;
if w<=1
    w=dw+w;
else
    w=-1;
end
y=(-w*w)/2+0.75;
set(head,'xdata',t,'ydata',y);%设置球的运动
%set(body,'xdata',t,'ydata',y);%描绘轨迹线
drawnow;
end %结束程序
w=-0.71;%设置球弹起的初始位置
  %设置球弹起的高度
while t>=-4
    t=t-dt;
if w<=1
    w=dw+w;
else
    w=-1;
end
y=(-w*w)/2+0.5;
set(head,'xdata',t,'ydata',y);%设置球的运动
%set(body,'xdata',t,'ydata',y);%描绘轨迹线
drawnow;
end %结束程序
for i=0:0.01:200%设置延时
    y=i+2;
    if(y>199)
    end
end
end

How can I come achieve my imagination?If it is impossible,similarity is OK I start studying matlab for only a short time.THANX for your help!

我怎样才能达到我的想象?如果这是不可能的,相似度是可以的,我开始学习matlab只需要很短的时间。谢谢你的帮助!

1 个解决方案

#1


0  

http://www.mathworks.com/matlabcentral/fileexchange/18754-heart-model-for-valentine-s-day

http://www.mathworks.com/matlabcentral/fileexchange/18754-heart-model-for-valentine-s-day

It generates a heart shape and with the Maltab core functions, you can re-shape it, move it and even generate a bouncing effect.

它产生一个心脏形状和Maltab的核心功能,你可以重新塑造它,移动它甚至产生一个跳跃的效果。

See also: How do I reproduce this heart-shaped mesh in MATLAB?

请参见:如何在MATLAB中复制这个心形网格?

#1


0  

http://www.mathworks.com/matlabcentral/fileexchange/18754-heart-model-for-valentine-s-day

http://www.mathworks.com/matlabcentral/fileexchange/18754-heart-model-for-valentine-s-day

It generates a heart shape and with the Maltab core functions, you can re-shape it, move it and even generate a bouncing effect.

它产生一个心脏形状和Maltab的核心功能,你可以重新塑造它,移动它甚至产生一个跳跃的效果。

See also: How do I reproduce this heart-shaped mesh in MATLAB?

请参见:如何在MATLAB中复制这个心形网格?