用matlab实现多小球的多轨道的3围圆周运动,哪位高手帮忙下
2个回答
展开全部
三个小球在不同圆周轨道上绕中心旋转。放5遍。
clear;clc;
t=linspace(0,2*pi);T={};o={};hold on;[x,y,z]=sphere;k=0;
theta=[pi/3 -pi/6 pi/2];r=[10 15 20];w=[3 2 1];
for j=t
k=k+1;cla;
plot3(0,0,0,'k.');
for i=1:3
T=[sin(theta(i)),0,cos(theta(i));0,1,0;-cos(theta(i)) 0 sin(theta(i))];
O=r(i)*T*[cos(t);sin(t);zeros(1,100)];
o=r(i)*T*[cos(j*w(i));sin(j*w(i));0];
surf(x+o(1),y+o(2),z+o(3),'FaceLighting','phong','AmbientStrength',.5);
plot3(O(1,:),O(2,:),O(3,:),':');
end
axis equal;shading interp;light('position',[0 0 0],'style','local');
axis([-20 20 -20 20 -10 10]);view(-37.5,30);
F(k) = getframe;
end
movie(F,5,20)
clear;clc;
t=linspace(0,2*pi);T={};o={};hold on;[x,y,z]=sphere;k=0;
theta=[pi/3 -pi/6 pi/2];r=[10 15 20];w=[3 2 1];
for j=t
k=k+1;cla;
plot3(0,0,0,'k.');
for i=1:3
T=[sin(theta(i)),0,cos(theta(i));0,1,0;-cos(theta(i)) 0 sin(theta(i))];
O=r(i)*T*[cos(t);sin(t);zeros(1,100)];
o=r(i)*T*[cos(j*w(i));sin(j*w(i));0];
surf(x+o(1),y+o(2),z+o(3),'FaceLighting','phong','AmbientStrength',.5);
plot3(O(1,:),O(2,:),O(3,:),':');
end
axis equal;shading interp;light('position',[0 0 0],'style','local');
axis([-20 20 -20 20 -10 10]);view(-37.5,30);
F(k) = getframe;
end
movie(F,5,20)
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询