Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1. documentclass{article}
  2. usepackage{graphicx} % to add figure environment that comes with caption
  3. usepackage{caption} %if you don't want to float your figure for using captionof
  4. usepackage{tikz}
  5. usetikzlibrary{calc,patterns,decorations.pathmorphing,decorations.markings,circuits}
  6. begin{document}
  7. Using verb|graphicx| package:
  8. begin{figure}[htbp]
  9. centering
  10. begin{tikzpicture}[every node/.style={draw,outer sep=0pt,thick}]
  11. tikzstyle{spring}=[thick,decorate,decoration={zigzag,pre length=0.3cm,post length=0.3cm,segment length=6}]
  12. tikzstyle{dampener}=[thick,decoration={markings, mark connection node=dmp,mark=at position 0.5 with {
  13. node (dmp) [thick,inner sep=0pt,transform shape,rotate=-90,minimum width=15pt,minimum height=3pt,draw=none] {};
  14. draw [thick] ($(dmp.north east)+(2pt,0)$) -- (dmp.south east) -- (dmp.south west) -- ($(dmp.north west)+(2pt,0)$); draw [thick] ($(dmp.north)+(0,-5pt)$) -- ($(dmp.north)+(0,5pt)$);}}, decorate]
  15. tikzstyle{ground}=[fill,pattern=north east lines,draw=none,minimum width=4cm,minimum height=0.3cm]
  16.  
  17. begin{scope}
  18. node at (0,0) [draw,rectangle, minimum width=2cm,minimum height=1cm,anchor=south,,transform shape](m1) {$m1$};
  19. draw [very thick, -latex](m1.north) -- +(0,1);
  20. node at (0,-2) [rectangle, minimum width=2cm,minimum height=1cm,anchor=north,,transform shape](m2) {$m2$};
  21. draw [very thick, -latex](m2.north) -- +(0,1);
  22. draw [spring] (-0.5,-2) -- (-0.5,0) node[midway,left=0.3cm] {k1};
  23. draw [dampener,label=D1,] (0.5,-2) -- (0.5,0)node[midway,right=0.4cm] {d1};
  24. node (ground1) at (0,-5) [ground, anchor=north] {};
  25. % draw [ground] (-1,-5) -- (1,-5);
  26. draw [spring] (-0.5,-5) -- (-0.5,-3)node[midway,left=0.3cm] {k2};
  27. % draw [spring] (-0.5,-5) -- (-0.5,-3)node[draw=none,midway,left=0.3cm] {k2}; % If you don't want borders around lables use [draw=none]
  28. draw [dampener] (0.5,-5) -- (0.5,-3)node[midway,right=0.4cm] {d2};
  29.  
  30. end{scope}
  31. end{tikzpicture}
  32. caption{My figure}label{fig:myfigure1}
  33. end{figure}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement