“L shaped” springs in tikz

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
5
down vote

favorite












This is my code:



documentclassstandalone usepackagetikz
usetikzlibrarycalc,patterns,decorations.pathmorphing,decorations.markings,positioning

begindocument
tikzsetspring/.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

begintikzpicture[every node/.style=draw,outer
sep=0pt,thick,font=sffamily]

node (m_1) [minimum width=1cm,minimum
height=0.5cm]$m_1$; node (m_2)[right of= m_1,node
distance=2.5cm,minimum width=1cm,minimum height=0.5cm]$m_2$; draw
[spring] (m_1.east) -- (m_2.west)
node[midway,below=1mm,draw=none]$k_12$; node (ground1) at
(m_1.south west)
[ground,yshift=-0.8cm,xshift=-0.5cm,rotate=90,anchor=north] ; draw
(ground1.south west) -- (ground1.south east);


enddocument


How to draw the L Shaped spring in the picture below?



enter image description here










share|improve this question



























    up vote
    5
    down vote

    favorite












    This is my code:



    documentclassstandalone usepackagetikz
    usetikzlibrarycalc,patterns,decorations.pathmorphing,decorations.markings,positioning

    begindocument
    tikzsetspring/.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

    begintikzpicture[every node/.style=draw,outer
    sep=0pt,thick,font=sffamily]

    node (m_1) [minimum width=1cm,minimum
    height=0.5cm]$m_1$; node (m_2)[right of= m_1,node
    distance=2.5cm,minimum width=1cm,minimum height=0.5cm]$m_2$; draw
    [spring] (m_1.east) -- (m_2.west)
    node[midway,below=1mm,draw=none]$k_12$; node (ground1) at
    (m_1.south west)
    [ground,yshift=-0.8cm,xshift=-0.5cm,rotate=90,anchor=north] ; draw
    (ground1.south west) -- (ground1.south east);


    enddocument


    How to draw the L Shaped spring in the picture below?



    enter image description here










    share|improve this question

























      up vote
      5
      down vote

      favorite









      up vote
      5
      down vote

      favorite











      This is my code:



      documentclassstandalone usepackagetikz
      usetikzlibrarycalc,patterns,decorations.pathmorphing,decorations.markings,positioning

      begindocument
      tikzsetspring/.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

      begintikzpicture[every node/.style=draw,outer
      sep=0pt,thick,font=sffamily]

      node (m_1) [minimum width=1cm,minimum
      height=0.5cm]$m_1$; node (m_2)[right of= m_1,node
      distance=2.5cm,minimum width=1cm,minimum height=0.5cm]$m_2$; draw
      [spring] (m_1.east) -- (m_2.west)
      node[midway,below=1mm,draw=none]$k_12$; node (ground1) at
      (m_1.south west)
      [ground,yshift=-0.8cm,xshift=-0.5cm,rotate=90,anchor=north] ; draw
      (ground1.south west) -- (ground1.south east);


      enddocument


      How to draw the L Shaped spring in the picture below?



      enter image description here










      share|improve this question















      This is my code:



      documentclassstandalone usepackagetikz
      usetikzlibrarycalc,patterns,decorations.pathmorphing,decorations.markings,positioning

      begindocument
      tikzsetspring/.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

      begintikzpicture[every node/.style=draw,outer
      sep=0pt,thick,font=sffamily]

      node (m_1) [minimum width=1cm,minimum
      height=0.5cm]$m_1$; node (m_2)[right of= m_1,node
      distance=2.5cm,minimum width=1cm,minimum height=0.5cm]$m_2$; draw
      [spring] (m_1.east) -- (m_2.west)
      node[midway,below=1mm,draw=none]$k_12$; node (ground1) at
      (m_1.south west)
      [ground,yshift=-0.8cm,xshift=-0.5cm,rotate=90,anchor=north] ; draw
      (ground1.south west) -- (ground1.south east);


      enddocument


      How to draw the L Shaped spring in the picture below?



      enter image description here







      tikz-pgf






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 1 hour ago









      CarLaTeX

      26.4k444116




      26.4k444116










      asked 1 hour ago









      iacopo

      57319




      57319




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          4
          down vote













          Method 1



          Here is a way to do it using -| which draws a right angle between the two points (ground1.south) and (m_1.south).



          But, it requires you to manually adjust the pre length and post length of the spring so that it fits nicely in the horizontal segment of the line. Also some adjustment to the position of the label is required.



          enter image description here



          documentclass[margin=0.5mm]standalone 
          usepackagetikz
          usetikzlibrarycalc,patterns,decorations.pathmorphing,decorations.markings,positioning

          begindocument
          tikzsetspring/.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

          begintikzpicture[every node/.style=draw,outer
          sep=0pt,thick,font=sffamily]

          node (m_1) [minimum width=1cm,minimum height=0.5cm]$m_1$;
          node (m_2)[right of= m_1,node distance=2.5cm,minimum width=1cm,minimum height=0.5cm]$m_2$;
          draw [spring] (m_1.east) -- (m_2.west) node[midway,below=1mm,draw=none]$k_12$;
          node (ground1) at (m_1.south west) [ground,yshift=-0.8cm,xshift=-0.5cm,rotate=90,anchor=north] ;
          draw (ground1.south west) -- (ground1.south east);
          draw [thick,decorate,decoration=zigzag,pre
          length=0.1cm,post length=0.85cm,segment length=6] (ground1.south) -| (m_1.south) node[midway,below=1mm,xshift=-3mm,draw=none]$k_g1$ ;

          endtikzpicture
          enddocument


          Method 2



          Another method could be to draw the two lines separately. This potentially allows you better control over the spring, as it is just specified for the horizontal segment (therefore you can set the same post and pre lengths). And the label is nicely centred underneath it.



          But, there is a small break between the two lines at the intersection point. I'm not sure how you fix this, perhaps there is an easy solution? (I welcome any comments)



          enter image description here



          documentclass[margin=0.5mm]standalone 
          usepackagetikz
          usetikzlibrarycalc,patterns,decorations.pathmorphing,decorations.markings,positioning

          begindocument
          tikzsetspring/.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.07cm,post length=0.07cm,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

          begintikzpicture[every node/.style=draw,outer
          sep=0pt,thick,font=sffamily]

          node (m_1) [minimum width=1cm,minimum height=0.5cm]$m_1$;
          node (m_2)[right of= m_1,node distance=2.5cm,minimum width=1cm,minimum height=0.5cm]$m_2$;
          draw [spring] (m_1.east) -- (m_2.west) node[midway,below=1mm,draw=none]$k_12$;
          node (ground1) at (m_1.south west) [ground,yshift=-0.8cm,xshift=-0.5cm,rotate=90,anchor=north] ;
          draw (ground1.south west) -- (ground1.south east);

          path (ground1.south) -| coordinate (midpoint) (m_1.south);
          draw [short spring] (ground1.south) -- (midpoint) node [midway, below=1mm,draw=none] $k_g1$;
          draw [thick] (midpoint)--(m_1.south);

          endtikzpicture
          enddocument





          share|improve this answer






















            Your Answer







            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "85"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            convertImagesToLinks: false,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













             

            draft saved


            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f457322%2fl-shaped-springs-in-tikz%23new-answer', 'question_page');

            );

            Post as a guest






























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            4
            down vote













            Method 1



            Here is a way to do it using -| which draws a right angle between the two points (ground1.south) and (m_1.south).



            But, it requires you to manually adjust the pre length and post length of the spring so that it fits nicely in the horizontal segment of the line. Also some adjustment to the position of the label is required.



            enter image description here



            documentclass[margin=0.5mm]standalone 
            usepackagetikz
            usetikzlibrarycalc,patterns,decorations.pathmorphing,decorations.markings,positioning

            begindocument
            tikzsetspring/.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

            begintikzpicture[every node/.style=draw,outer
            sep=0pt,thick,font=sffamily]

            node (m_1) [minimum width=1cm,minimum height=0.5cm]$m_1$;
            node (m_2)[right of= m_1,node distance=2.5cm,minimum width=1cm,minimum height=0.5cm]$m_2$;
            draw [spring] (m_1.east) -- (m_2.west) node[midway,below=1mm,draw=none]$k_12$;
            node (ground1) at (m_1.south west) [ground,yshift=-0.8cm,xshift=-0.5cm,rotate=90,anchor=north] ;
            draw (ground1.south west) -- (ground1.south east);
            draw [thick,decorate,decoration=zigzag,pre
            length=0.1cm,post length=0.85cm,segment length=6] (ground1.south) -| (m_1.south) node[midway,below=1mm,xshift=-3mm,draw=none]$k_g1$ ;

            endtikzpicture
            enddocument


            Method 2



            Another method could be to draw the two lines separately. This potentially allows you better control over the spring, as it is just specified for the horizontal segment (therefore you can set the same post and pre lengths). And the label is nicely centred underneath it.



            But, there is a small break between the two lines at the intersection point. I'm not sure how you fix this, perhaps there is an easy solution? (I welcome any comments)



            enter image description here



            documentclass[margin=0.5mm]standalone 
            usepackagetikz
            usetikzlibrarycalc,patterns,decorations.pathmorphing,decorations.markings,positioning

            begindocument
            tikzsetspring/.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.07cm,post length=0.07cm,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

            begintikzpicture[every node/.style=draw,outer
            sep=0pt,thick,font=sffamily]

            node (m_1) [minimum width=1cm,minimum height=0.5cm]$m_1$;
            node (m_2)[right of= m_1,node distance=2.5cm,minimum width=1cm,minimum height=0.5cm]$m_2$;
            draw [spring] (m_1.east) -- (m_2.west) node[midway,below=1mm,draw=none]$k_12$;
            node (ground1) at (m_1.south west) [ground,yshift=-0.8cm,xshift=-0.5cm,rotate=90,anchor=north] ;
            draw (ground1.south west) -- (ground1.south east);

            path (ground1.south) -| coordinate (midpoint) (m_1.south);
            draw [short spring] (ground1.south) -- (midpoint) node [midway, below=1mm,draw=none] $k_g1$;
            draw [thick] (midpoint)--(m_1.south);

            endtikzpicture
            enddocument





            share|improve this answer


























              up vote
              4
              down vote













              Method 1



              Here is a way to do it using -| which draws a right angle between the two points (ground1.south) and (m_1.south).



              But, it requires you to manually adjust the pre length and post length of the spring so that it fits nicely in the horizontal segment of the line. Also some adjustment to the position of the label is required.



              enter image description here



              documentclass[margin=0.5mm]standalone 
              usepackagetikz
              usetikzlibrarycalc,patterns,decorations.pathmorphing,decorations.markings,positioning

              begindocument
              tikzsetspring/.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

              begintikzpicture[every node/.style=draw,outer
              sep=0pt,thick,font=sffamily]

              node (m_1) [minimum width=1cm,minimum height=0.5cm]$m_1$;
              node (m_2)[right of= m_1,node distance=2.5cm,minimum width=1cm,minimum height=0.5cm]$m_2$;
              draw [spring] (m_1.east) -- (m_2.west) node[midway,below=1mm,draw=none]$k_12$;
              node (ground1) at (m_1.south west) [ground,yshift=-0.8cm,xshift=-0.5cm,rotate=90,anchor=north] ;
              draw (ground1.south west) -- (ground1.south east);
              draw [thick,decorate,decoration=zigzag,pre
              length=0.1cm,post length=0.85cm,segment length=6] (ground1.south) -| (m_1.south) node[midway,below=1mm,xshift=-3mm,draw=none]$k_g1$ ;

              endtikzpicture
              enddocument


              Method 2



              Another method could be to draw the two lines separately. This potentially allows you better control over the spring, as it is just specified for the horizontal segment (therefore you can set the same post and pre lengths). And the label is nicely centred underneath it.



              But, there is a small break between the two lines at the intersection point. I'm not sure how you fix this, perhaps there is an easy solution? (I welcome any comments)



              enter image description here



              documentclass[margin=0.5mm]standalone 
              usepackagetikz
              usetikzlibrarycalc,patterns,decorations.pathmorphing,decorations.markings,positioning

              begindocument
              tikzsetspring/.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.07cm,post length=0.07cm,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

              begintikzpicture[every node/.style=draw,outer
              sep=0pt,thick,font=sffamily]

              node (m_1) [minimum width=1cm,minimum height=0.5cm]$m_1$;
              node (m_2)[right of= m_1,node distance=2.5cm,minimum width=1cm,minimum height=0.5cm]$m_2$;
              draw [spring] (m_1.east) -- (m_2.west) node[midway,below=1mm,draw=none]$k_12$;
              node (ground1) at (m_1.south west) [ground,yshift=-0.8cm,xshift=-0.5cm,rotate=90,anchor=north] ;
              draw (ground1.south west) -- (ground1.south east);

              path (ground1.south) -| coordinate (midpoint) (m_1.south);
              draw [short spring] (ground1.south) -- (midpoint) node [midway, below=1mm,draw=none] $k_g1$;
              draw [thick] (midpoint)--(m_1.south);

              endtikzpicture
              enddocument





              share|improve this answer
























                up vote
                4
                down vote










                up vote
                4
                down vote









                Method 1



                Here is a way to do it using -| which draws a right angle between the two points (ground1.south) and (m_1.south).



                But, it requires you to manually adjust the pre length and post length of the spring so that it fits nicely in the horizontal segment of the line. Also some adjustment to the position of the label is required.



                enter image description here



                documentclass[margin=0.5mm]standalone 
                usepackagetikz
                usetikzlibrarycalc,patterns,decorations.pathmorphing,decorations.markings,positioning

                begindocument
                tikzsetspring/.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

                begintikzpicture[every node/.style=draw,outer
                sep=0pt,thick,font=sffamily]

                node (m_1) [minimum width=1cm,minimum height=0.5cm]$m_1$;
                node (m_2)[right of= m_1,node distance=2.5cm,minimum width=1cm,minimum height=0.5cm]$m_2$;
                draw [spring] (m_1.east) -- (m_2.west) node[midway,below=1mm,draw=none]$k_12$;
                node (ground1) at (m_1.south west) [ground,yshift=-0.8cm,xshift=-0.5cm,rotate=90,anchor=north] ;
                draw (ground1.south west) -- (ground1.south east);
                draw [thick,decorate,decoration=zigzag,pre
                length=0.1cm,post length=0.85cm,segment length=6] (ground1.south) -| (m_1.south) node[midway,below=1mm,xshift=-3mm,draw=none]$k_g1$ ;

                endtikzpicture
                enddocument


                Method 2



                Another method could be to draw the two lines separately. This potentially allows you better control over the spring, as it is just specified for the horizontal segment (therefore you can set the same post and pre lengths). And the label is nicely centred underneath it.



                But, there is a small break between the two lines at the intersection point. I'm not sure how you fix this, perhaps there is an easy solution? (I welcome any comments)



                enter image description here



                documentclass[margin=0.5mm]standalone 
                usepackagetikz
                usetikzlibrarycalc,patterns,decorations.pathmorphing,decorations.markings,positioning

                begindocument
                tikzsetspring/.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.07cm,post length=0.07cm,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

                begintikzpicture[every node/.style=draw,outer
                sep=0pt,thick,font=sffamily]

                node (m_1) [minimum width=1cm,minimum height=0.5cm]$m_1$;
                node (m_2)[right of= m_1,node distance=2.5cm,minimum width=1cm,minimum height=0.5cm]$m_2$;
                draw [spring] (m_1.east) -- (m_2.west) node[midway,below=1mm,draw=none]$k_12$;
                node (ground1) at (m_1.south west) [ground,yshift=-0.8cm,xshift=-0.5cm,rotate=90,anchor=north] ;
                draw (ground1.south west) -- (ground1.south east);

                path (ground1.south) -| coordinate (midpoint) (m_1.south);
                draw [short spring] (ground1.south) -- (midpoint) node [midway, below=1mm,draw=none] $k_g1$;
                draw [thick] (midpoint)--(m_1.south);

                endtikzpicture
                enddocument





                share|improve this answer














                Method 1



                Here is a way to do it using -| which draws a right angle between the two points (ground1.south) and (m_1.south).



                But, it requires you to manually adjust the pre length and post length of the spring so that it fits nicely in the horizontal segment of the line. Also some adjustment to the position of the label is required.



                enter image description here



                documentclass[margin=0.5mm]standalone 
                usepackagetikz
                usetikzlibrarycalc,patterns,decorations.pathmorphing,decorations.markings,positioning

                begindocument
                tikzsetspring/.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

                begintikzpicture[every node/.style=draw,outer
                sep=0pt,thick,font=sffamily]

                node (m_1) [minimum width=1cm,minimum height=0.5cm]$m_1$;
                node (m_2)[right of= m_1,node distance=2.5cm,minimum width=1cm,minimum height=0.5cm]$m_2$;
                draw [spring] (m_1.east) -- (m_2.west) node[midway,below=1mm,draw=none]$k_12$;
                node (ground1) at (m_1.south west) [ground,yshift=-0.8cm,xshift=-0.5cm,rotate=90,anchor=north] ;
                draw (ground1.south west) -- (ground1.south east);
                draw [thick,decorate,decoration=zigzag,pre
                length=0.1cm,post length=0.85cm,segment length=6] (ground1.south) -| (m_1.south) node[midway,below=1mm,xshift=-3mm,draw=none]$k_g1$ ;

                endtikzpicture
                enddocument


                Method 2



                Another method could be to draw the two lines separately. This potentially allows you better control over the spring, as it is just specified for the horizontal segment (therefore you can set the same post and pre lengths). And the label is nicely centred underneath it.



                But, there is a small break between the two lines at the intersection point. I'm not sure how you fix this, perhaps there is an easy solution? (I welcome any comments)



                enter image description here



                documentclass[margin=0.5mm]standalone 
                usepackagetikz
                usetikzlibrarycalc,patterns,decorations.pathmorphing,decorations.markings,positioning

                begindocument
                tikzsetspring/.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.07cm,post length=0.07cm,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

                begintikzpicture[every node/.style=draw,outer
                sep=0pt,thick,font=sffamily]

                node (m_1) [minimum width=1cm,minimum height=0.5cm]$m_1$;
                node (m_2)[right of= m_1,node distance=2.5cm,minimum width=1cm,minimum height=0.5cm]$m_2$;
                draw [spring] (m_1.east) -- (m_2.west) node[midway,below=1mm,draw=none]$k_12$;
                node (ground1) at (m_1.south west) [ground,yshift=-0.8cm,xshift=-0.5cm,rotate=90,anchor=north] ;
                draw (ground1.south west) -- (ground1.south east);

                path (ground1.south) -| coordinate (midpoint) (m_1.south);
                draw [short spring] (ground1.south) -- (midpoint) node [midway, below=1mm,draw=none] $k_g1$;
                draw [thick] (midpoint)--(m_1.south);

                endtikzpicture
                enddocument






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited 8 mins ago

























                answered 23 mins ago









                Milo

                5,63821345




                5,63821345



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f457322%2fl-shaped-springs-in-tikz%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Comments

                    Popular posts from this blog

                    What does second last employer means? [closed]

                    List of Gilmore Girls characters

                    Confectionery