-2

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.

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

  %(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!

xuyohee
  • 1
  • 1
  • What does it mean "make good sense"? What do you want to do with your heart? The heart looks nice but you have to be more specific about what you want to achieve to get a useful answer. – NoDataDumpNoContribution Jun 24 '14 at 11:54

1 Answers1

0

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.

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

Community
  • 1
  • 1
CitizenInsane
  • 4,755
  • 1
  • 25
  • 56