智能车制作

 找回密码
 注册

扫一扫,访问微社区

查看: 1525|回复: 1
打印 上一主题 下一主题

【求高手翻译】

[复制链接]

16

主题

211

帖子

0

精华

常驻嘉宾

Rank: 8Rank: 8

积分
5525
威望
2875
贡献
1932
兑换币
1894
注册时间
2013-7-23
在线时间
359 小时
毕业学校
华中科技大学
跳转到指定楼层
1#
发表于 2013-7-23 18:53:52 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
在MATLAB当中输入type xpquad后出现的源程序,表示看不懂。。久闻此处高手如云,望高手们能予以指点,加以翻译。小弟感激不尽!
if nargin<1,
    action='initialize';
end;

if strcmp(action,'initialize'),
    figNumber=figure( ...
        'Name',getString得到的字符串(message('MATLAB:demos:xpquad:fig_Superquadrics')), ...
        'NumberTitle','off', ...
        'Visible','off', ...
        'Color',0.8*[1 1 1], ...
        'BackingStore','off');
    colordef(figNumber,'white')
    axes( ...
        'Units','normalized', ...
        'Position',[0.05 0.05 0.70 0.90], ...
        'Visible','off');

    %===================================
    % Information for all buttons(所有按钮的信息)
    labelColor=[0.8 0.8 0.8];
    top=0.95;
    bottom=0.05;
    btnWid=0.15;
    btnHt=0.10;
    right=0.95;
    left=right-btnWid;
    % Spacing between the button and the next command's label和下一个命令按键标记的间距

    spacing=0.02;
   
    %====================================
    % The CONSOLE frame 控制台框架
    frmBorder=0.02;
    yPos=bottom-frmBorder;
    frmPos=[left-frmBorder yPos btnWid+2*frmBorder 0.9+2*frmBorder];
    h=uicontrol( ...
        'Style','frame', ...
        'Units','normalized', ...
        'Position',frmPos, ...
        'BackgroundColor',[0.50 0.50 0.50]);

    %====================================
    % The first slider 第一个滑块(大概是xpquad右侧的那两个能滑动的第一个)
    btnNumber=1;
    yPos=top-(btnNumber-1)*(btnHt+spacing);
    callbackStr='xpquad(''build'');';

    % Generic button information 通用按钮信息
    sldPos=[left yPos-2*btnHt btnWid btnHt];
    labelPos1=[left yPos-btnHt/2 btnWid btnHt/2];
    labelPos2=[left yPos-btnHt btnWid btnHt/2];
    sld1Hndl=uicontrol( ...
        'Style','slider', ...
        'Tag','vertical', ...
        'Units','normalized', ...
        'Position',sldPos, ...
        'Callback',callbackStr);

    uicontrol( ...
        'Style','text', ...
        'String',getString(message('MATLAB:demos:xpquad:uicontrol_Vertical')), ...
        'Units','normalized', ...
        'Position',labelPos1);
    uicontrol( ...
        'Style','text', ...
        'String',getString(message('MATLAB:demos:xpquad:uicontrol_Roundness')), ...
        'Units','normalized', ...
        'Position',labelPos2);

    %====================================
    % The second slider 第二个滑块
    btnNumber=3;
    yPos=top-(btnNumber-1)*(btnHt+spacing);
    callbackStr='xpquad(''build'');';

    % Generic button information  通用按钮信息
    sldPos=[left yPos-2*btnHt btnWid btnHt];
    labelPos1=[left yPos-btnHt/2 btnWid btnHt/2];
    labelPos2=[left yPos-btnHt btnWid btnHt/2];
    sld2Hndl=uicontrol( ...
        'Style','slider', ...
        'Tag','horizontal', ...
        'Units','normalized', ...
        'Position',sldPos, ...
        'Callback',callbackStr);

    uicontrol( ...
        'Style','text', ...
        'String',getString(message('MATLAB:demos:xpquad:uicontrol_Horizontal')), ...
        'Units','normalized', ...
        'Position',labelPos1);
    uicontrol( ...
        'Style','text', ...
        'String',getString(message('MATLAB:demos:xpquad:uicontrol_Roundness')), ...
        'Units','normalized', ...
        'Position',labelPos2);

    %====================================
    % The HELP button  帮助按钮
    labelStr=getString(message('MATLAB:demos:sharedabelHelp'));
    callbackStr=['helpwin ' mfilename];
    uicontrol( ...
        'Style','pushbutton', ...
        'Units','normalized', ...
        'Position',[left bottom+btnHt+spacing btnWid btnHt], ...
        'String',labelStr, ...
        'Callback',callbackStr);

    %====================================
    % The CLOSE button 关闭按钮
    labelStr=getString(message('MATLAB:demos:shared:LabelClose'));
    callbackStr='close(gcf)';
    uicontrol( ...
        'Style','push', ...
        'Units','normalized', ...
        'Position',[left bottom btnWid btnHt], ...
        'String',labelStr, ...
        'Callback',callbackStr);

    % Uncover the figure 揭示图形
    set(figNumber, ...
        'Visible','on');

    % Make the sliders 16 pixels tall so it looks good on a Mac
    set([sld1Hndl sld2Hndl],'Units','pixel')
    sld1Pos=get(sld1Hndl,'Position');
    sld2Pos=get(sld2Hndl,'Position');
    set(sld1Hndl,'Position',[sld1Pos(1) sld1Pos(2)+sld1Pos(4)-16 sld1Pos(3) 16])
    set(sld2Hndl,'Position',[sld2Pos(1) sld2Pos(2)+sld2Pos(4)-16 sld2Pos(3) 16])
    set([sld1Hndl sld2Hndl],'Units','normalized')

    % Draw the initial superquadric  
    n=5*get(sld1Hndl,'Value');
    e=5*get(sld2Hndl,'Value');
    [x,y,z]=superquad(n,e,20);
    surfHndl=surf(x,y,z);
    set(surfHndl,'Tag','surface');
    light('Position',[2 -1 10]);
    light('Position',[-3 -1 -5]);
    lighting phong
    axis off;
    shading interp;
    colormap([0 0 1])
    drawnow

elseif strcmp(action,'build'),
    %====================================
    axHndl=gca;
    figNumber=gcf;
    sld1Hndl=findobj(gcf,'Tag','horizontal');
    sld2Hndl=findobj(gcf,'Tag','vertical');

    % Xpquad problem Xpquad
    n=5*get(sld1Hndl,'Value');
    e=5*get(sld2Hndl,'Value');
    [x,y,z]=superquad(n,e,20);
    surfaceHndl=findobj(gcf,'Tag','surface');
    set(surfaceHndl,'XData',x,'YData',y,'ZData',z)
    drawnow

end;    % if strcmp(action, ...  

11

主题

390

帖子

0

精华

金牌会员

Rank: 6Rank: 6

积分
1698
QQ
威望
835
贡献
433
兑换币
324
注册时间
2011-8-20
在线时间
215 小时
2#
发表于 2013-7-23 20:04:11 | 只看该作者
回复 支持 反对

使用道具 举报

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

本版积分规则

关于我们|联系我们|小黑屋|亿加合和智能车制作 ( 黑ICP备2022002344号

GMT+8, 2024-5-8 06:19 , Processed in 0.071109 second(s), 26 queries , Gzip On.

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表