⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rckplot.m

📁 航天工程工具箱
💻 M
字号:
function rckplot(comp,cp,cg)
%RCKPLOT  Plot rocket components.
%   RCKPLOT(COMP[,CP[,CG]])  plots the rocket part(s)/component(s)
%   COMP. If nose is included the current CP location will be marked
%   out in the figure. If COMP contains all parts for the rocket, then the figure
%   will resemble the rocket design. If CP = 0 then the CP point
%   will not be marked out, likewise if CG = 0 then the CG point
%   will not be marked out.
%
%   See also RCKCAD, EVALCP, EVALCG, SMARG.

% Copyright (c) 2003-06-25, B. Rasmus Anthin.
% Revisited 2003-06-25, 2003-07-19, 2003-07-23.

error(nargchk(1,4,nargin))
clf
hold on
if isempty(comp), comp=nan*ones(1,11);end
if nargin<2, cp=1;end
if nargin<3, cg=1;end
dL=0;
for i=1:size(comp,1)
   if comp(i,1)==1, dL=comp(i,3);end
end
iscp=any(comp(:,1)==1) & cp;
iscg=any(comp(:,1)==1) & cg;
xlbl=[];
if iscp
   cp=evalcp(comp);
   plot(cp,0,'.')
   plot(cp,0,'o','markersize',8)
   if iscg, xlbl=' ,  ';end
   xlbl=[xlbl 'CP=' num2str(cp)];
end
if iscg
   [cg,m]=evalcg(comp);
   load cgico;
   %plot(cg,0,'+','markersize',8)
   %plot(cg,0,'o','markersize',8)
   marker(cg,0,double(cdata),[0 0 1;1 1 1],7)
   xlbl=['m=' num2str(m) ' ,  ' 'CG=' num2str(cg) xlbl];
end
xlabel(xlbl)
tstr=[];
if iscp & iscg
   [marg,state,msg]=smarg(comp);
   tstr=[msg ' with ' num2str(marg) ' calibers.'];
end
title(tstr)
%sort the components, nose first...
comp=sortrows(comp,1);
comp=[comp(1,:); sortrows(comp(2:end,:),3)];

for i=1:size(comp,1)
   x=nan;y=nan;
   pos=comp(i,3);
   L=comp(i,4);
   d=comp(i,6);
   switch(comp(i,1))
   case 1                 %Nose
      x=linspace(-dL,L-dL);
      switch(comp(i,2))
      case 1              % Conical
         y=linspace(0,d/2);
      case 2              % Ogive
         xx=x+dL;
         R=d/4+L^2/d;
         t=4*L^2+d^2;
         x1=(4*L^4+d^2*L^2-d*sqrt(L^4*t^2/d^2))/(2*t*L);
         y1=(d^3+4*d*L^2-4*sqrt(L^4*t^2/d^2))/(4*t);
         y=sqrt(R^2-(xx-x1).^2)+y1;
         y=fliplr(y);
      case 3              % Parabolic
         phi=linspace(pi,pi/2);
         x=L*cos(phi)+L-dL;
         y=d/2*sin(phi);
      end
%      xc(i,:)=[nan x(end)];
%      yc(i,:)=[nan y(end)];
      x=[x x(end)];
      y=[y 0];
   case 2                 %Body tube
      x=linspace(0,L)+pos;
      y=repmat(d/2,1,100);
      x=[x(1) x x(end)];
      y=[0 y 0];
   case 3                 %Coupler
      d1=comp(i,5);
      d2=d;
      x=linspace(0,L)+pos;
      y=linspace(d1/2,d2/2);
%      xc(i,:)=x([1 end]);
%      yc(i,:)=y([1 end]);
      x=[x(1) x x(end)];
      y=[0 y 0];
   case 4                 %Fins
      a=L;
      b=comp(i,5);
      R=d;
      S=comp(i,7);
      m=comp(i,8);
      n=comp(i,9);
      x1=linspace(0,m)+pos;
      x2=linspace(m+b,a)+pos;
      x=[x1 x2];
      y1=linspace(R,R+S);
      y2=linspace(R+S,R);
      y=[y1 y2];
%      xc(i,:)=x([1 end]);
%      yc(i,:)=y([1 end]);
%      x=[x x(1) nan x([end end])];
%      y=[y y(1) nan y(end) 0];
      x=[x x(1)];
      y=[y y(1)];
      text(pos+m+b/2,R+S*1.2,num2str(n))
   case 5
      n=comp(i,9);
      x=[0 linspace(0,L) L]+pos;
      y=[0 linspace(d,d) 0]/2;
      h=patch([x fliplr(x)],[y -y],-ones(1,2*length(x)),[.9 .9 .9]);
      userdata(h,comp(i,:),1)
      text(pos+L/2,0,num2str(n))
   end
   h=plot(x,y);
   userdata(h,comp(i,:),1)
   h=plot(x,-y);
   userdata(h,comp(i,:),1)
%   if i>1
%      plot([xc(i-1,2) xc(i,1)],[yc(i-1,2) yc(i,1)])
%      plot([xc(i-1,2) xc(i,1)],-[yc(i-1,2) yc(i,1)])
%   end
end
axis equal
grid on
eval(get(gcf,'resizefcn'))    %in order to update the CG marker.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -