Skip to content

Instantly share code, notes, and snippets.

@cslarsen
Created January 7, 2012 10:40
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cslarsen/1574390 to your computer and use it in GitHub Desktop.
Save cslarsen/1574390 to your computer and use it in GitHub Desktop.
Free body diagram with frictional forces made in MetaPost
% MetaPost free body diagram with frictional forces
%
% Placed in the public domain by the author; Christian Stigen Larsen
% 2011-10-07
%
% To render:
% $ mptopdf free-body.mp
%
beginfig(1)
u := 0.35cm;
% boks A
a := -20;
w := 2u;
draw dir(45+a)*w -- dir(180-45+a)*w -- dir(270-45+a)*w -- dir(360-45+a)*w -- cycle;
%label.ulft(btex A etex, origin+(0,0.2u));
dotlabel(btex etex, origin); % dot
u:=0.32cm;
% gravity: vertical component
g := 8;
drawarrow origin -- (0, -g*u);
label.lrt(btex $W=m_a\vec{g}$ etex, (0, -g*u));
% normal n (push upwards from under
drawarrow origin -- dir(90-20)*g*cosd(20)*u;
label.urt(btex $N = W\cos\theta$ etex, dir(90-20)*g*cosd(20)*u);
% skråplan
L := 13;
draw origin + dir(270-20)*w*0.09u - dir(180-20)*L*0.5*u --
origin + dir(270-20)*w*0.09u - dir(-20)*L*0.5*u withpen pencircle scaled 2bp;
% dotted vertical
draw origin -- dir(270-20)*8u dashed evenly;
% degree
p := 0.75;
draw origin + dir(270-20)*g*p*u .. origin + dir(270-10)*g*p*u .. origin + dir(270)*g*p*u;
label.bot(btex $\theta$ etex, origin + dir(270-10)*g*p*u);
% friction; always _against_ movement
drawarrow origin -- dir(180-20)*g*sind(20)*u;
label.ulft(btex $\mu_{kA} N$ etex, dir(180-20)*g*sind(20)*u);
% gravity: horizontal component
drawarrow origin -- dir(-20)*g*sind(20)*u;
label.urt(btex $W\sin\theta$ etex, dir(-20)*g*sind(20)*u);
% kraft fra B
drawarrow dir(-20)*g*sind(20)*u -- dir(-20)*g*sind(20)*u*2 dashed evenly;
label.lrt(btex $F_B$ etex, dir(-20)*g*sind(20)*u*2);
% horizontal dotted
pair P;
P := origin+dir(270-20)*w*0.09u-dir(180-20)*L*0.5*u;
draw P -- P-(L*u,0) dashed evenly;
% degrees
l := p;
draw P+dir(180)*l*L*u .. P+dir(180-10)*l*L*u .. P+dir(180-20)*l*L*u;
label.lft(btex $\theta$ etex, P+dir(180-10)*l*L*u);
endfig;
end
@cslarsen
Copy link
Author

cslarsen commented Jan 7, 2012

This is just a simple MetaPost for file rendering a free body diagram with frictional forces.

A rendition of the file can be found at http://csl.sublevel3.org/free-body.png

Free body diagram with frictional forces, rendered with MetaPost

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment