I got help from enter link description here but I was wondering how can I re-purpose the code to get the diagram as in the attachment.

\usepackage{graphicx} % to add figure environment that comes with caption
\usepackage{caption} %if you don't want to float your figure for using \captionof
Using \verb|graphicx| package:
     \begin{tikzpicture}[every node/.style={draw,outer sep=0pt,thick}]
     \tikzstyle{spring}=[thick,decorate,decoration={zigzag,pre length=0.3cm,post length=0.3cm,segment length=6}]
     \tikzstyle{dampener}=[thick,decoration={markings, mark connection node=dmp,mark=at position 0.5 with {
     \node (dmp) [thick,inner sep=0pt,transform shape,rotate=-90,minimum width=15pt,minimum height=3pt,draw=none] {};
     \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]
     \tikzstyle{ground}=[fill,pattern=north east lines,draw=none,minimum width=4cm,minimum height=0.3cm]

     \node at (0,0) [draw,rectangle, minimum width=2cm,minimum height=1cm,anchor=south,,transform shape](m1) {$m1$};
      \draw [very thick, -latex](m1.north) -- +(0,1);
     \node at (0,-2) [rectangle, minimum width=2cm,minimum height=1cm,anchor=north,,transform shape](m2) {$m2$};
     \draw [very thick, -latex](m2.north) -- +(0,1);
     \draw [spring] (-0.5,-2) -- (-0.5,0) node[midway,left=0.3cm] {k1};
      \draw [dampener,label=D1,] (0.5,-2) -- (0.5,0)node[midway,right=0.4cm] {d1};
      \node (ground1) at (0,-5)  [ground, anchor=north] {};
%        \draw [ground] (-1,-5) -- (1,-5);
      \draw [spring] (-0.5,-5) -- (-0.5,-3)node[midway,left=0.3cm] {k2};
 %     \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]
       \draw [dampener] (0.5,-5) -- (0.5,-3)node[midway,right=0.4cm] {d2};

        \caption{My figure}\label{fig:myfigure1}

I need the base slightly wiggly to represent irregular road and a small circle as the tip of the system at the point of contact between the suspension system and the road. I don't have the logic to create wiggly line.

The code is for the picture on the left and I want the diagram on the right.

enter image description here enter image description here

  • 3
    {whisper) Please do not use \tikzstyle. Please note that tikz loads graphicx. Please note that the purpose of this site is not to convert screen shots into code but to help you with general problems. So if you ask how to replace the fat horizontal line by the wiggly line, that's fine, if you expect us to adjust all the dimensions and symbols to reproduce your screen shot, less so. – user121799 Apr 24 '19 at 0:10

your image is low quality, so some details are not clear and probably i misinterpreted them. after redesign styles of the image elements, i obtain the following image:

enter image description here

\documentclass[tikz, margin=3mm]{standalone}
                decorations.pathmorphing, decorations.markings,
                patterns, positioning,

  node distance = 24mm and 4mm,
     box/.style = {draw, semithick, fill=white,
                   minimum width=22mm,minimum height=11mm},
     dot/.style = {circle, fill, minimum size=3mm,
                   node contents={}},
pics/dmp/.style = {code={\node (dmp) [minimum width=4mm, minimum height=1mm,
                                      fill=white, inner sep=0mm] {};,
                         \draw[semithick, shorten >=-0.5mm, shorten <=-0.5mm]
                         (dmp.south west) |- (dmp.north east) -- (dmp.south east);
                         \draw[ultra thick, shorten >=1mm, shorten <=1mm]
                                    (dmp.south west) -- (dmp.south east);}
 damper/.style = {decoration={markings,
                             mark=at position 0.5 with \pic{dmp} {};
 spring/.style = {thick,decorate,
                  decoration={zigzag, pre length=8mm, post length=8mm, segment length=4}},
     sx/.style = {xshift=#1mm},
    fup/.style = {very thick, -latex},
  fdown/.style = {very thick, latex-},
every path/.append style = {thick, line cap=rect}
\node (m1)  [box]               {$M_{s}$};
    \draw[fdown]   (m1.north) to ["$F_b$"] ++(0,1);
    \draw[fup]     (m1.east) -| ++(1,-0.5) node[below] {$z_s$};
\node (m2)  [box, below=of m1]  {$M_{us}$};
    \draw           ([sx=-6] m2.west) -- (m2.west);
    \draw[fdown]      ([sx=-4] m2.west) to ["$F_w$" '] +(0,-1);
    \draw[fup]    (m2.east)  -| ++(1,-0.5) node[below] {$z_{us}$};;
    \draw[spring]   (m1.225) to ["$K_s$" '] (m2.135);
    \draw[damper]   (m1.315) to [sx=4,pos=0.4,"$C_s$"  ] (m2.45);
\node (c)   [dot,below=of m2];
    \draw[spring]   (m2.225) to ["$K_t$" '] (m2.225 |- c);
    \draw[damper]   (m2.315) to [sx=4,pos=0.4,"$C_t$"  ] (m2.315 |- c);
    \draw           (m2.225 |- c) -- (c)
                    (m2.315 |- c) -- (c);
    \draw[very thick, -latex]   (c.south) -| ++ (0.75,-0.5) 
        node[below, rounded corners, inner sep=2pt, fill=white] {$z_f$};
% ground
\scoped[on background layer]
\draw[gray, pattern=north east lines] 
        let \p1 = ($(0,0)-(c.south)$),
            \n1 = {veclen(\x1,\y1)} in
        plot[domain=-6.243184:6.243184,samples=30] (\x/3, {-\n1-4*sin(\x r)}) |- ++ (-3.141592,-1) -| cycle;

edit: encouraged by @KJO comment i add missed ground, \end{document} and correct arrow direction. i'm still not sure of arrows presenting force are correct drawn (to my knowledge of physics are unusual).

  • you seem to have interpreted all the requirements perfectly and the sinusoidal ground can be found at the similar answer tex.stackexchange.com/questions/338127/sinusoidal-ground thus selecting parts between the two combined I think this is a perfectly acceptable solution – user170109 Apr 24 '19 at 19:57
  • @KJO, thank you for nice words. now i see that i forgot on ground. i have problem with force z_f and what is black circle on the bottom. ii actually wait on OP response that i correct/finish image. thank you for link to similar answer. i wasn't aware on it . – Zarko Apr 24 '19 at 20:06
  • I think there is enough of each element for Op to change $z_f$ to $Z_r$ etc. – user170109 Apr 24 '19 at 20:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.