set(p1,'backfacelighting','unlit');
colormap(topomap1); alpha('direct');
alphamap([.1;1])
campos([2 13 10]);
camlight;
lighting gouraud;
warning('off');
s1=0:.01:2*pi;
axis([-8 8 -8 8 -8 8]);
axis off;
r1=4;%月亮到地球的平均距离
r2=1.2;%嫦娥一号到月亮的平均距离
w1=1;%设置月亮公转角速度
w2=12;%设置嫦娥一号绕月亮公转角速度
t=0;%初始时刻为0
pausetime=.02;%设置暂停时间
sita1=0;sita2=0;%设置开始它们都在水平线上
set(gcf,'doublebuffer','on') %消除抖动
plot3(r1*cos(s1),r1*sin(s1),0*s1,'r');%画月亮公转轨道
p1=plot3(r1*cos(sita1),r1*sin(sita1),0*s1,'color','b','marker','.','markersize',30);%画月亮初始位置
l1=plot3(r1*cos(sita1)+r2*cos(s1),r1*sin(sita1)+r2*sin(s1),0*s1);%画嫦娥一号绕月亮公转轨道
p2x=r1*cos(sita1)+r2*cos(sita2);p2y=r1*sin(sita1)+r2*sin(sita2);
p2=plot3(p2x,p2y,0*s1,'k','marker','.','markersize',20);%画嫦娥一号的初始位置
orbit=line('xdata',p2x,'ydata',p2y,'zdata',0,'color','r');%画嫦娥一号的运动轨迹
tic;
while 1
set(p1,'xdata',r1*cos(sita1),'ydata',r1*sin(sita1),'zdata',0);%设置月亮的运动过程
set(l1,'xdata',r1*cos(sita1)+r2*cos(s1),'ydata',r1*sin(sita1)+r2*sin(s1),'zdata',0*s1);%设置嫦娥一 号绕月亮的公转轨道的运动过程
ptempx=r1*cos(sita1)+r2*cos(sita2);
ptempy=r1*sin(sita1)+r2*sin(sita2);
set(p2,'xdata',ptempx,'ydata',ptempy);%设置嫦娥一号的运动过程
p2x=[p2x ptempx];p2y=[p2y ptempy];
set(orbit,'xdata',p2x,'ydata',p2y);%设置嫦娥一号运动轨迹的显示过程
sita1=sita1+w1*pausetime;%月亮相对地球转过的角度
sita2=sita2+w2*pausetime;%嫦娥一号相对月亮转过的角度
pause(pausetime); %暂停一会 drawnow if toc>10 break;
end
end % --- Executes on button press in stop.
function stop_Callback(hObject, eventdata, handles)
% hObject handle to stop (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in close.
function close_Callback(hObject, eventdata, handles)
% hObject handle to close (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA) close(gcf);
% --- Executes on button press in moon_speed_decreace.
function moon_speed_decreace_Callback(hObject, eventdata, handles)
% hObject handle to moon_speed_decreace (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in satellite_speed_increace.
function satellite_speed_increace_Callback(hObject, eventdata, handles)
% hObject handle to satellite_speed_increace (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)