1

This is my code:

\documentclass{standalone}
\usepackage{tikz}
\usepackage{xcolor} 
\usetikzlibrary{calc,patterns,decorations.pathmorphing}
\usetikzlibrary{decorations.markings,positioning}

\begin{document}
\tikzset{spring/.style={thick,decorate,decoration={zigzag,pre 
length=0.3cm,post
length=0.3cm,segment length=6}},
short spring/.style={thick,decorate,decoration={zigzag,pre 
length=0.05cm,post
length=0.05cm,segment length=6}},
damper/.style={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},
ground/.style={fill,pattern=north east lines,draw=none,minimum
width=0.75cm,minimum height=0.3cm},
ground_magenta/.style={fill,pattern=north east lines,pattern 
color=magenta,draw=none,minimum
width=0.75cm,minimum height=0.3cm}}

\begin{tikzpicture}[every node/.style={draw,outer 
sep=0pt,thick},font=\sffamily]
\node[minimum width=2cm,minimum height=0.3cm] (beam1) {};
\node[right of= beam1,node distance=2cm,minimum width=2cm,minimum 
height=0.3cm] (beam2) {};
\node[right of= beam2,node distance=2cm,minimum width=2cm,minimum 
height=0.3cm] (beam3) {};
\node[right of= beam3,node distance=2cm,minimum width=2cm,minimum 
height=0.3cm] (beam4) {};

\node (ground1) at (beam1.south west) [ground,yshift=-3cm,anchor=north] {};
\draw (ground1.north west) -- (ground1.north east);
\draw [thick,decorate,decoration={zigzag,pre
length=1cm,post length=1cm,segment length=6}] (ground1.north) -- 
 ($(beam1.south west)$) 
 node[midway,right=1mm,draw=none]{};

 \node (ground2) at (beam4.south east) [ground,yshift=-3cm,anchor=north] {};
 \draw (ground2.north west) -- (ground2.north east); 
 \draw [thick,decorate,decoration={zigzag,pre
 length=1cm,post length=1cm,segment length=6}] (ground2.north) -- 
 ($(beam4.south east)$) 
 node[midway,right=1mm,draw=none]{};

\node[below of= beam1,node distance=2cm,minimum 
 height=0.3cm,yshift=0.3cm,xshift=1cm] (m1) {$m_1$};
 \draw[spring] (beam2.south west) -- (m1.north) node[midway,right=1mm,draw=none]{};
 \node[below of= beam2,node distance=2cm,minimum height=0.3cm,yshift=0.3cm,xshift=1cm] (m2) {$m_2$};
 \draw[spring] (beam3.south west) -- (m2.north) node[midway,right=1mm,draw=none]{};
 \node[below of= beam3,node distance=2cm,minimum height=0.3cm,yshift=0.3cm,xshift=1cm] (m3) {$m_3$};
 \draw[spring] (beam4.south west) -- (m3.north) node[midway,right=1mm,draw=none]{};

\draw [-latex] (beam1.north west) ++(0,0.3cm) -- +(0,0.5cm) node[midway,right=0.3mm,draw=none]{$y_{1}$};
\draw [-latex] (beam2.north west) ++(0,0.3cm) -- +(0,0.5cm) node[midway,right=0.3mm,draw=none]{$y_{2}$};
\draw [-latex] (beam3.north west) ++(0,0.3cm) -- +(0,0.5cm) node[midway,right=0.3mm,draw=none]{$y_{3}$};
 \draw [-latex] (beam4.north west) ++(0,0.3cm) -- +(0,0.5cm) node[midway,right=0.3mm,draw=none]{$y_{4}$};
 \draw [-latex] (beam4.north east) ++(0,0.3cm) -- +(0,0.5cm) node[midway,right=0.3mm,draw=none]{$y_{5}$};

\end{tikzpicture}

\end{document}  

How to add the black curved arrow? It must be equal to the y1 arrow but curved since it represent a rotation. Thank you

enter image description here

  • Why are the definitions you are using so similar to what one finds in tex.stackexchange.com/a/13952/121799 ? Using other posts is fine, but IMHO one should give credit to the source of codes. – marmot Feb 22 at 17:04
  • I started using Tikz Mechanical from the link you gave and then this is the code i create, why should i give credits? I am just asking how to draw a curved arrow. – iacopo Feb 25 at 7:51
  • 1
    @iacopo That's because you copied code and published it here. The original code has been published with Creative Commons license with attribution required (to the post and to the author). So feel free to use and to modify and to re-publish it, but add a link to the source. – Stefan Kottwitz Feb 25 at 11:55
  • @StefanKottwitz which code did I copy? I just used his definitions and create my own code and picture. – iacopo Feb 26 at 13:27
  • 2
    Then it's his definitions. Whatever, consider my comment as an explanation why @marmot is right when he says one should add a link to a post if stuff from there is used because it's proper use and technically proper licensing. – Stefan Kottwitz Feb 26 at 15:17
4

You can influence the degree of bending using the optional parameter of bend left and bend right.

The following is your desired output:

\documentclass{standalone}
\usepackage{tikz}
\usepackage{xcolor} 
\usetikzlibrary{calc,patterns,decorations.pathmorphing}
\usetikzlibrary{decorations.markings,positioning}

\begin{document}
\tikzset{spring/.style={thick,decorate,decoration={zigzag,pre 
length=0.3cm,post
length=0.3cm,segment length=6}},
short spring/.style={thick,decorate,decoration={zigzag,pre 
length=0.05cm,post
length=0.05cm,segment length=6}},
damper/.style={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},
ground/.style={fill,pattern=north east lines,draw=none,minimum
width=0.75cm,minimum height=0.3cm},
ground_magenta/.style={fill,pattern=north east lines,pattern 
color=magenta,draw=none,minimum
width=0.75cm,minimum height=0.3cm}}

\begin{tikzpicture}[every node/.style={draw,outer 
sep=0pt,thick},font=\sffamily]
\node[minimum width=2cm,minimum height=0.3cm] (beam1) {};
\node[right of= beam1,node distance=2cm,minimum width=2cm,minimum 
height=0.3cm] (beam2) {};
\node[right of= beam2,node distance=2cm,minimum width=2cm,minimum 
height=0.3cm] (beam3) {};
\node[right of= beam3,node distance=2cm,minimum width=2cm,minimum 
height=0.3cm] (beam4) {};

\node (ground1) at (beam1.south west) [ground,yshift=-3cm,anchor=north] {};
\draw (ground1.north west) -- (ground1.north east);
\draw [thick,decorate,decoration={zigzag,pre
length=1cm,post length=1cm,segment length=6}] (ground1.north) -- 
 ($(beam1.south west)$) 
 node[midway,right=1mm,draw=none]{};

 \node (ground2) at (beam4.south east) [ground,yshift=-3cm,anchor=north] {};
 \draw (ground2.north west) -- (ground2.north east); 
 \draw [thick,decorate,decoration={zigzag,pre
 length=1cm,post length=1cm,segment length=6}] (ground2.north) -- 
 ($(beam4.south east)$) 
 node[midway,right=1mm,draw=none]{};

\node[below of= beam1,node distance=2cm,minimum 
 height=0.3cm,yshift=0.3cm,xshift=1cm] (m1) {$m_1$};
 \draw[spring] (beam2.south west) -- (m1.north) node[midway,right=1mm,draw=none]{};
 \node[below of= beam2,node distance=2cm,minimum height=0.3cm,yshift=0.3cm,xshift=1cm] (m2) {$m_2$};
 \draw[spring] (beam3.south west) -- (m2.north) node[midway,right=1mm,draw=none]{};
 \node[below of= beam3,node distance=2cm,minimum height=0.3cm,yshift=0.3cm,xshift=1cm] (m3) {$m_3$};
 \draw[spring] (beam4.south west) -- (m3.north) node[midway,right=1mm,draw=none]{};

\draw [-latex] (beam1.north west) ++(0,0.3cm) -- +(0,0.5cm) node[midway,left=0.3mm,draw=none]{$y_{1}$};
\draw [-latex] (beam2.north west) ++(0,0.3cm) -- +(0,0.5cm) node[midway,left=0.3mm,draw=none]{$y_{2}$};
\draw [-latex] (beam3.north west) ++(0,0.3cm) -- +(0,0.5cm) node[midway,left=0.3mm,draw=none]{$y_{3}$};
 \draw [-latex] (beam4.north west) ++(0,0.3cm) -- +(0,0.5cm) node[midway,left=0.3mm,draw=none]{$y_{4}$};
 \draw [-latex] (beam4.north east) ++(0,0.3cm) -- +(0,0.5cm) node[midway,left=0.3mm,draw=none]{$y_{5}$};

\draw [-latex] (beam1.north west) ++(0,0.3cm) to [bend right] +(0.3cm,0.5cm) node[below right, draw=none] {$x_{1}$};
\draw [-latex] (beam2.north west) ++(0,0.3cm) to [bend right] +(0.3cm,0.5cm) node[below right, draw=none] {$x_{2}$};
\draw [-latex] (beam3.north west) ++(0,0.3cm) to [bend right] +(0.3cm,0.5cm) node[below right, draw=none] {$x_{3}$};
\draw [-latex] (beam4.north west) ++(0,0.3cm) to [bend right] +(0.3cm,0.5cm) node[below right, draw=none] {$x_{4}$};
\draw [-latex] (beam4.north east) ++(0,0.3cm) to [bend right] +(0.3cm,0.5cm) node[below right, draw=none] {$x_{5}$};

\end{tikzpicture}

\end{document} 

I have placed the nodes to the left of the arrows as well. Here you can find more details regarding the arrow options in tikz.

enter image description here

  • As your photo was not that clear, in the case that you want the two arrows overlap, you can set the x coordination of your x variable same as your y: \draw [-latex] (beam1.north west) ++(0,0.3cm) to [bend right=45] +(0.0cm,0.5cm) node[below right, draw=none] {$x_{1}$}; – Sina Ahmadi Feb 22 at 12:23

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.