Robotnačka v Metaposte

From RoboWiki
Revision as of 12:32, 26 January 2007 by Balogh (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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;