QQ登录

只需要一步,快速开始

 注册地址  找回密码
查看: 1351|回复: 1
打印 上一主题 下一主题

嫦娥奔月代码

[复制链接]
字体大小: 正常 放大
李秋锐        

14

主题

14

听众

76

积分

升级  74.74%

  • TA的每日心情
    奋斗
    2015-3-29 18:44
  • 签到天数: 17 天

    [LV.4]偶尔看看III

    社区QQ达人

    跳转到指定楼层
    1#
    发表于 2015-2-4 18:25 |只看该作者 |倒序浏览
    |招呼Ta 关注Ta
    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)


    zan
    转播转播0 分享淘帖0 分享分享0 收藏收藏0 支持支持0 反对反对0 微信微信
    kdwwolf        

    2

    主题

    13

    听众

    47

    积分

    升级  44.21%

  • TA的每日心情
    开心
    2015-2-7 13:50
  • 签到天数: 6 天

    [LV.2]偶尔看看I

    邮箱绑定达人 社区QQ达人

    此帖仅作者可见

    使用道具 举报

    您需要登录后才可以回帖 登录 | 注册地址

    qq
    收缩
    • 电话咨询

    • 04714969085
    fastpost

    关于我们| 联系我们| 诚征英才| 对外合作| 产品服务| QQ

    手机版|Archiver| |繁體中文 手机客户端  

    蒙公网安备 15010502000194号

    Powered by Discuz! X2.5   © 2001-2013 数学建模网-数学中国 ( 蒙ICP备14002410号-3 蒙BBS备-0002号 )     论坛法律顾问:王兆丰

    GMT+8, 2024-5-28 20:26 , Processed in 0.300036 second(s), 60 queries .

    回顶部