Difference between revisions of "Robotnačka v Metaposte"

From RoboWiki
Jump to: navigation, search
 
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
 +
 +
[[Image:RobotnackaMpost.png|frame|Robotnačka v Metaposte]]
 
<PRE>
 
<PRE>
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
+
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %
%
+
%                                                            %
% This is a simple example how to draw fine pictures of the  
+
% This is a simple example how to draw fine pictures of the %
% Robotnacka robot for the kinematics modelling.
+
% Robotnacka robot for the kinematics modelling.             %
%  
+
%                                                            %
% (c) Richard Balogh, january 2007
+
% (c) Richard Balogh, january 2007                           %
% http://www.robotika.sk/
+
% http://www.robotika.sk/                                   %  
%  
+
%                                                           %
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
+
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %
%
 
% Uncomment this for use as a standalone picture,
 
% commented for use in LaTeX.
 
prologues:=1;
 
  
beginfig(1);
+
% Uncomment this for use as a standalone picture, comment for use in LaTeX.
 +
  prologues:=1;
 +
 
 +
  beginfig(1);
  
 
% Declarations and definitions
 
% 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;
  
Line 34: Line 34:
  
 
   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
Line 62: Line 62:
 
   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;

Latest revision as of 12: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;