Difference between revisions of "Robotnačka v Metaposte"

From RoboWiki
Jump to: navigation, search
 
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
 
Aby sme mohli kresliť pekné obrázky Robotnačky, použijeme Metapost.  
 
Aby sme mohli kresliť pekné obrázky Robotnačky, použijeme Metapost.  
Tu je príklad. A tento obrázok je výsledok. [[Image:RobotnackaMpost.png|frame|Robotnačka v Metaposte]]
+
Tu je príklad aj výsledným obrázkom. Preklad:
  
  % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
+
  mpost robotnacka.mp
%
+
% This is a simple example how to draw fine pictures of the  
+
[[Image:RobotnackaMpost.png|frame|Robotnačka v Metaposte]]
% Robotnacka robot for the kinematics modelling.
+
<PRE>
%  
+
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %
% (c) Richard Balogh, january 2007
+
%                                                            %
% http://www.robotika.sk/
+
% This is a simple example how to draw fine pictures of the %
%  
+
% Robotnacka robot for the kinematics modelling.             %
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
+
%                                                            %
%
+
% (c) Richard Balogh, january 2007                           %
% Uncomment this for use as a standalone picture,
+
% http://www.robotika.sk/                                   %  
% commented for use in LaTeX.
+
%                                                           %
prologues:=1;
+
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %
  
beginfig(1);
+
% Uncomment this for use as a standalone picture, comment for use in LaTeX.
 +
  prologues:=1;
  
% Declarations and definitions
+
  beginfig(1);
 +
 
 +
% Declarations and definitions
 
    
 
    
  u := 48;
+
   picture Robotnacka;  pair P;     % Variables
 
+
  u := 48;                        % Basic measurement unit
   picture Robotnacka;  pair P;  
 
 
 
  
% Body of the robot
+
% Body of the robot
  
   fill fullcircle scaled 210 withcolor (1,1,0);
+
   fill fullcircle scaled 210 withcolor (1,1,0); % (r,g,b) = Yellow
 
   draw fullcircle scaled 210 withcolor red;
 
   draw fullcircle scaled 210 withcolor red;
  
% Wheels
+
% Wheels
  
 
   linecap:=rounded;
 
   linecap:=rounded;
   pickup pencircle scaled 5;
+
   pickup pencircle scaled 5;       % Width of wheels
   draw (-25,90)--(25,90);
+
   draw (-25,90)--(25,90);           % Left wheel
   draw (-25,-90)--(25,-90);
+
   draw (-25,-90)--(25,-90);         % Right wheel
   pickup pencircle scaled 1; % Restore original fine point
+
   pickup pencircle scaled 1;       % Restore original fine point
  
% Castor wheel
+
% Castor wheel
 
    
 
    
 
   fill fullcircle scaled 30 shifted (-77,0) withcolor .3white;
 
   fill fullcircle scaled 30 shifted (-77,0) withcolor .3white;
  
% Help lines
+
% Help lines
  
 
   draw (0,90)--(0,-90);
 
   draw (0,90)--(0,-90);
 
   drawarrow (0,0)--(50,0) withcolor blue;
 
   drawarrow (0,0)--(50,0) withcolor blue;
  
% Center of the robot:
+
% Center of the robot:
 
    
 
    
 
   cu=10;
 
   cu=10;
Line 57: Line 58:
 
   draw (0,cu)--(0,-cu);
 
   draw (0,cu)--(0,-cu);
  
% Start to draw moving robot:
+
% Start to draw moving robot:
  
 
   Robotnacka = currentpicture;
 
   Robotnacka = currentpicture;
 
   clearit;
 
   clearit;
 
  
 
   Theta=45;      % Orientation of the robot
 
   Theta=45;      % Orientation of the robot
   P := (5u,7u);  % Final point of the robot
+
   P := (5u,7u);  % Final position of the robot
  
 
   addto currentpicture also Robotnacka rotated Theta shifted P;
 
   addto currentpicture also Robotnacka rotated Theta shifted P;
  
% Trajectory:  :-)
+
% Trajectory:  :-)
  
 
   pickup pencircle scaled 2;
 
   pickup pencircle scaled 2;
Line 78: Line 78:
 
  endfig;
 
  endfig;
  
end;
+
end;

Latest revision as of 11:40, 26 January 2007

Aby sme mohli kresliť pekné obrázky Robotnačky, použijeme Metapost. Tu je príklad aj výsledným obrázkom. Preklad:

mpost robotnacka.mp

Robotnačka v Metaposte
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %
%                                                            %
% This is a simple example how to draw fine pictures of the  %
% Robotnacka robot for the kinematics modelling.             %
%                                                            %
% (c) Richard Balogh, january 2007                           % 
% http://www.robotika.sk/                                    % 
%                                                            %
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %

% Uncomment this for use as a standalone picture, comment for use in LaTeX.
  prologues:=1;

  beginfig(1);

% Declarations and definitions
  
  picture Robotnacka;  pair P;     % Variables
  u := 48;                         % Basic measurement unit

% Body of the robot

  fill fullcircle scaled 210 withcolor (1,1,0);  % (r,g,b) = Yellow
  draw fullcircle scaled 210 withcolor red;

% Wheels

  linecap:=rounded;
  pickup pencircle scaled 5;        % Width of wheels 
  draw (-25,90)--(25,90);           % Left wheel
  draw (-25,-90)--(25,-90);         % Right wheel
  pickup pencircle scaled 1;        % Restore original fine point

% Castor wheel
  
  fill fullcircle scaled 30 shifted (-77,0) withcolor .3white;

% Help lines

  draw (0,90)--(0,-90);
  drawarrow (0,0)--(50,0) withcolor blue;

% Center of the robot:
  
  cu=10;
  draw fullcircle scaled cu withcolor red;
  path quarterdisk; quarterdisk := quartercircle--origin--cycle;
  fill quarterdisk scaled cu withcolor red;
  fill quarterdisk scaled cu rotated 180 withcolor red;
  draw (cu,0)--(-cu,0);
  draw (0,cu)--(0,-cu);

% Start to draw moving robot:

  Robotnacka = currentpicture;
  clearit;

  Theta=45;       % Orientation of the robot
  P := (5u,7u);   % Final position of the robot

  addto currentpicture also Robotnacka rotated Theta shifted P;

% Trajectory:   :-)

  pickup pencircle scaled 2;
  drawarrow origin..controls (0,3u) and (2u,0) ..(2u,2u)..{dir45}P withcolor green;

  dotlabel.lft("0",origin);


 endfig;

end;