Difference between revisions of "Robotnačka v Metaposte"

From RoboWiki
Jump to: navigation, search
 
Line 2: Line 2:
 
Tu je príklad. A tento obrázok je výsledok. [[Image:RobotnackaMpost.png|frame|Robotnačka v Metaposte]]
 
Tu je príklad. A tento obrázok je výsledok. [[Image:RobotnackaMpost.png|frame|Robotnačka v Metaposte]]
  
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
+
<PRE>
%
+
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
% This is a simple example how to draw fine pictures of the  
+
%
% Robotnacka robot for the kinematics modelling.
+
% 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/
+
% (c) Richard Balogh, january 2007
%  
+
% http://www.robotika.sk/
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
+
%  
%
+
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
% Uncomment this for use as a standalone picture,  
+
%
% commented for use in LaTeX.
+
% Uncomment this for use as a standalone picture,  
 +
% commented for use in LaTeX.
 
  prologues:=1;
 
  prologues:=1;
  
 
  beginfig(1);
 
  beginfig(1);
  
% Declarations and definitions
+
% Declarations and definitions
 
    
 
    
 
   u := 48;
 
   u := 48;
Line 25: Line 26:
  
  
% Body of the robot
+
% Body of the robot
  
 
   fill fullcircle scaled 210 withcolor (1,1,0);
 
   fill fullcircle scaled 210 withcolor (1,1,0);
 
   draw fullcircle scaled 210 withcolor red;
 
   draw fullcircle scaled 210 withcolor red;
  
% Wheels
+
% Wheels
  
 
   linecap:=rounded;
 
   linecap:=rounded;
Line 38: Line 39:
 
   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;
Line 68: Line 69:
 
   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 79:
 
  endfig;
 
  endfig;
  
end;
+
end;

Revision as of 12:35, 26 January 2007

Aby sme mohli kresliť pekné obrázky Robotnačky, použijeme Metapost.

Tu je príklad. A tento obrázok je výsledok.
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, 
% commented for use in LaTeX.
 prologues:=1;

 beginfig(1);

% Declarations and definitions
  
  u := 48;

  picture Robotnacka;  pair P; 


% Body of the robot

  fill fullcircle scaled 210 withcolor (1,1,0);
  draw fullcircle scaled 210 withcolor red;

% Wheels

  linecap:=rounded;
  pickup pencircle scaled 5;
  draw (-25,90)--(25,90);
  draw (-25,-90)--(25,-90);
  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 point 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;