Rotating in TikZ

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











up vote
2
down vote

favorite












I have the following code



documentclassarticle
usepackagegraphicx,tikz
begindocument
begintikzpicture
draw[ultra thick] (-1,0) -- (1,0);
draw[ultra thick] (0,0) -- (0,2);
endtikzpicture
rotatebox115begintikzpicture
draw[ultra thick] (-1,0) -- (1,0);
draw[ultra thick] (0,0) -- (0,2);
endtikzpicture
enddocument


giving



enter image description here



The picture is supposed to represent the two possible states after throwing a (stylized) nail. The angle in the rotatebox was obtained by trial and error. I was wondering if I could use tikz to do the same job without guessing.










share|improve this question

























    up vote
    2
    down vote

    favorite












    I have the following code



    documentclassarticle
    usepackagegraphicx,tikz
    begindocument
    begintikzpicture
    draw[ultra thick] (-1,0) -- (1,0);
    draw[ultra thick] (0,0) -- (0,2);
    endtikzpicture
    rotatebox115begintikzpicture
    draw[ultra thick] (-1,0) -- (1,0);
    draw[ultra thick] (0,0) -- (0,2);
    endtikzpicture
    enddocument


    giving



    enter image description here



    The picture is supposed to represent the two possible states after throwing a (stylized) nail. The angle in the rotatebox was obtained by trial and error. I was wondering if I could use tikz to do the same job without guessing.










    share|improve this question























      up vote
      2
      down vote

      favorite









      up vote
      2
      down vote

      favorite











      I have the following code



      documentclassarticle
      usepackagegraphicx,tikz
      begindocument
      begintikzpicture
      draw[ultra thick] (-1,0) -- (1,0);
      draw[ultra thick] (0,0) -- (0,2);
      endtikzpicture
      rotatebox115begintikzpicture
      draw[ultra thick] (-1,0) -- (1,0);
      draw[ultra thick] (0,0) -- (0,2);
      endtikzpicture
      enddocument


      giving



      enter image description here



      The picture is supposed to represent the two possible states after throwing a (stylized) nail. The angle in the rotatebox was obtained by trial and error. I was wondering if I could use tikz to do the same job without guessing.










      share|improve this question













      I have the following code



      documentclassarticle
      usepackagegraphicx,tikz
      begindocument
      begintikzpicture
      draw[ultra thick] (-1,0) -- (1,0);
      draw[ultra thick] (0,0) -- (0,2);
      endtikzpicture
      rotatebox115begintikzpicture
      draw[ultra thick] (-1,0) -- (1,0);
      draw[ultra thick] (0,0) -- (0,2);
      endtikzpicture
      enddocument


      giving



      enter image description here



      The picture is supposed to represent the two possible states after throwing a (stylized) nail. The angle in the rotatebox was obtained by trial and error. I was wondering if I could use tikz to do the same job without guessing.







      tikz-pgf






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 2 hours ago









      Denis

      1,894520




      1,894520




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          4
          down vote



          accepted










          Yes, TikZ can do that.



          documentclassarticle
          usepackagetikz
          begindocument
          begintikzpicture
          draw[ultra thick] (-1,0) -- (1,0);
          draw[ultra thick] (0,0) -- (0,2);
          endtikzpicture
          begintikzpicture[rotate=atan2(1,2)+90]
          draw[ultra thick] (-1,0) -- (1,0);
          draw[ultra thick] (0,0) -- (0,2);
          endtikzpicture
          enddocument


          enter image description here



          OK, let's let TikZ do the calculation.



          documentclassarticle
          usepackagetikz
          usetikzlibrarycalc
          begindocument
          begintikzpicture
          draw[ultra thick] (-1,0) -- (1,0);
          draw[ultra thick] (0,0) -- (0,2);
          endtikzpicture
          begintikzpicture[globalize angle/.code=xdef#1n1]
          % the points (0,2) and (-1,0) are the ones you want to be horizontal
          path let p1=($(0,2)-(-1,0)$),n1=180-atan2(y1,x1) in
          [globalize angle=myangle];
          beginscope[rotate=myangle]
          draw[ultra thick] (-1,0) -- (1,0);
          draw[ultra thick] (0,0) -- (0,2) coordinate(aux);
          endscope
          endtikzpicture
          enddocument





          share|improve this answer






















          • +1, but instead of "tikz can do that", it should be "marmots know trigonometry" :)
            – samcarter
            2 hours ago










          • @marmot Quite nice/ Will accept it when I can. Never looked at page 933 of the pgfmanual before!
            – Denis
            2 hours ago










          • @samcarter OK OK, I added a second possibility in which calc does the computation. ;-) And of course marmots need to know trigonometry, otherwise they'd get lost in their burrows. ;-)
            – marmot
            2 hours ago











          • Wow! That is an interesting approach!
            – samcarter
            2 hours ago










          • @samcarter Both options are basically the same except that I subtracted the vectors by hand in the first proposal (and there is an exchange of x and y, which is however conceptually irrelevant).
            – marmot
            2 hours ago










          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%2f456249%2frotating-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



          accepted










          Yes, TikZ can do that.



          documentclassarticle
          usepackagetikz
          begindocument
          begintikzpicture
          draw[ultra thick] (-1,0) -- (1,0);
          draw[ultra thick] (0,0) -- (0,2);
          endtikzpicture
          begintikzpicture[rotate=atan2(1,2)+90]
          draw[ultra thick] (-1,0) -- (1,0);
          draw[ultra thick] (0,0) -- (0,2);
          endtikzpicture
          enddocument


          enter image description here



          OK, let's let TikZ do the calculation.



          documentclassarticle
          usepackagetikz
          usetikzlibrarycalc
          begindocument
          begintikzpicture
          draw[ultra thick] (-1,0) -- (1,0);
          draw[ultra thick] (0,0) -- (0,2);
          endtikzpicture
          begintikzpicture[globalize angle/.code=xdef#1n1]
          % the points (0,2) and (-1,0) are the ones you want to be horizontal
          path let p1=($(0,2)-(-1,0)$),n1=180-atan2(y1,x1) in
          [globalize angle=myangle];
          beginscope[rotate=myangle]
          draw[ultra thick] (-1,0) -- (1,0);
          draw[ultra thick] (0,0) -- (0,2) coordinate(aux);
          endscope
          endtikzpicture
          enddocument





          share|improve this answer






















          • +1, but instead of "tikz can do that", it should be "marmots know trigonometry" :)
            – samcarter
            2 hours ago










          • @marmot Quite nice/ Will accept it when I can. Never looked at page 933 of the pgfmanual before!
            – Denis
            2 hours ago










          • @samcarter OK OK, I added a second possibility in which calc does the computation. ;-) And of course marmots need to know trigonometry, otherwise they'd get lost in their burrows. ;-)
            – marmot
            2 hours ago











          • Wow! That is an interesting approach!
            – samcarter
            2 hours ago










          • @samcarter Both options are basically the same except that I subtracted the vectors by hand in the first proposal (and there is an exchange of x and y, which is however conceptually irrelevant).
            – marmot
            2 hours ago














          up vote
          4
          down vote



          accepted










          Yes, TikZ can do that.



          documentclassarticle
          usepackagetikz
          begindocument
          begintikzpicture
          draw[ultra thick] (-1,0) -- (1,0);
          draw[ultra thick] (0,0) -- (0,2);
          endtikzpicture
          begintikzpicture[rotate=atan2(1,2)+90]
          draw[ultra thick] (-1,0) -- (1,0);
          draw[ultra thick] (0,0) -- (0,2);
          endtikzpicture
          enddocument


          enter image description here



          OK, let's let TikZ do the calculation.



          documentclassarticle
          usepackagetikz
          usetikzlibrarycalc
          begindocument
          begintikzpicture
          draw[ultra thick] (-1,0) -- (1,0);
          draw[ultra thick] (0,0) -- (0,2);
          endtikzpicture
          begintikzpicture[globalize angle/.code=xdef#1n1]
          % the points (0,2) and (-1,0) are the ones you want to be horizontal
          path let p1=($(0,2)-(-1,0)$),n1=180-atan2(y1,x1) in
          [globalize angle=myangle];
          beginscope[rotate=myangle]
          draw[ultra thick] (-1,0) -- (1,0);
          draw[ultra thick] (0,0) -- (0,2) coordinate(aux);
          endscope
          endtikzpicture
          enddocument





          share|improve this answer






















          • +1, but instead of "tikz can do that", it should be "marmots know trigonometry" :)
            – samcarter
            2 hours ago










          • @marmot Quite nice/ Will accept it when I can. Never looked at page 933 of the pgfmanual before!
            – Denis
            2 hours ago










          • @samcarter OK OK, I added a second possibility in which calc does the computation. ;-) And of course marmots need to know trigonometry, otherwise they'd get lost in their burrows. ;-)
            – marmot
            2 hours ago











          • Wow! That is an interesting approach!
            – samcarter
            2 hours ago










          • @samcarter Both options are basically the same except that I subtracted the vectors by hand in the first proposal (and there is an exchange of x and y, which is however conceptually irrelevant).
            – marmot
            2 hours ago












          up vote
          4
          down vote



          accepted







          up vote
          4
          down vote



          accepted






          Yes, TikZ can do that.



          documentclassarticle
          usepackagetikz
          begindocument
          begintikzpicture
          draw[ultra thick] (-1,0) -- (1,0);
          draw[ultra thick] (0,0) -- (0,2);
          endtikzpicture
          begintikzpicture[rotate=atan2(1,2)+90]
          draw[ultra thick] (-1,0) -- (1,0);
          draw[ultra thick] (0,0) -- (0,2);
          endtikzpicture
          enddocument


          enter image description here



          OK, let's let TikZ do the calculation.



          documentclassarticle
          usepackagetikz
          usetikzlibrarycalc
          begindocument
          begintikzpicture
          draw[ultra thick] (-1,0) -- (1,0);
          draw[ultra thick] (0,0) -- (0,2);
          endtikzpicture
          begintikzpicture[globalize angle/.code=xdef#1n1]
          % the points (0,2) and (-1,0) are the ones you want to be horizontal
          path let p1=($(0,2)-(-1,0)$),n1=180-atan2(y1,x1) in
          [globalize angle=myangle];
          beginscope[rotate=myangle]
          draw[ultra thick] (-1,0) -- (1,0);
          draw[ultra thick] (0,0) -- (0,2) coordinate(aux);
          endscope
          endtikzpicture
          enddocument





          share|improve this answer














          Yes, TikZ can do that.



          documentclassarticle
          usepackagetikz
          begindocument
          begintikzpicture
          draw[ultra thick] (-1,0) -- (1,0);
          draw[ultra thick] (0,0) -- (0,2);
          endtikzpicture
          begintikzpicture[rotate=atan2(1,2)+90]
          draw[ultra thick] (-1,0) -- (1,0);
          draw[ultra thick] (0,0) -- (0,2);
          endtikzpicture
          enddocument


          enter image description here



          OK, let's let TikZ do the calculation.



          documentclassarticle
          usepackagetikz
          usetikzlibrarycalc
          begindocument
          begintikzpicture
          draw[ultra thick] (-1,0) -- (1,0);
          draw[ultra thick] (0,0) -- (0,2);
          endtikzpicture
          begintikzpicture[globalize angle/.code=xdef#1n1]
          % the points (0,2) and (-1,0) are the ones you want to be horizontal
          path let p1=($(0,2)-(-1,0)$),n1=180-atan2(y1,x1) in
          [globalize angle=myangle];
          beginscope[rotate=myangle]
          draw[ultra thick] (-1,0) -- (1,0);
          draw[ultra thick] (0,0) -- (0,2) coordinate(aux);
          endscope
          endtikzpicture
          enddocument






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 2 hours ago

























          answered 2 hours ago









          marmot

          67.4k473144




          67.4k473144











          • +1, but instead of "tikz can do that", it should be "marmots know trigonometry" :)
            – samcarter
            2 hours ago










          • @marmot Quite nice/ Will accept it when I can. Never looked at page 933 of the pgfmanual before!
            – Denis
            2 hours ago










          • @samcarter OK OK, I added a second possibility in which calc does the computation. ;-) And of course marmots need to know trigonometry, otherwise they'd get lost in their burrows. ;-)
            – marmot
            2 hours ago











          • Wow! That is an interesting approach!
            – samcarter
            2 hours ago










          • @samcarter Both options are basically the same except that I subtracted the vectors by hand in the first proposal (and there is an exchange of x and y, which is however conceptually irrelevant).
            – marmot
            2 hours ago
















          • +1, but instead of "tikz can do that", it should be "marmots know trigonometry" :)
            – samcarter
            2 hours ago










          • @marmot Quite nice/ Will accept it when I can. Never looked at page 933 of the pgfmanual before!
            – Denis
            2 hours ago










          • @samcarter OK OK, I added a second possibility in which calc does the computation. ;-) And of course marmots need to know trigonometry, otherwise they'd get lost in their burrows. ;-)
            – marmot
            2 hours ago











          • Wow! That is an interesting approach!
            – samcarter
            2 hours ago










          • @samcarter Both options are basically the same except that I subtracted the vectors by hand in the first proposal (and there is an exchange of x and y, which is however conceptually irrelevant).
            – marmot
            2 hours ago















          +1, but instead of "tikz can do that", it should be "marmots know trigonometry" :)
          – samcarter
          2 hours ago




          +1, but instead of "tikz can do that", it should be "marmots know trigonometry" :)
          – samcarter
          2 hours ago












          @marmot Quite nice/ Will accept it when I can. Never looked at page 933 of the pgfmanual before!
          – Denis
          2 hours ago




          @marmot Quite nice/ Will accept it when I can. Never looked at page 933 of the pgfmanual before!
          – Denis
          2 hours ago












          @samcarter OK OK, I added a second possibility in which calc does the computation. ;-) And of course marmots need to know trigonometry, otherwise they'd get lost in their burrows. ;-)
          – marmot
          2 hours ago





          @samcarter OK OK, I added a second possibility in which calc does the computation. ;-) And of course marmots need to know trigonometry, otherwise they'd get lost in their burrows. ;-)
          – marmot
          2 hours ago













          Wow! That is an interesting approach!
          – samcarter
          2 hours ago




          Wow! That is an interesting approach!
          – samcarter
          2 hours ago












          @samcarter Both options are basically the same except that I subtracted the vectors by hand in the first proposal (and there is an exchange of x and y, which is however conceptually irrelevant).
          – marmot
          2 hours ago




          @samcarter Both options are basically the same except that I subtracted the vectors by hand in the first proposal (and there is an exchange of x and y, which is however conceptually irrelevant).
          – marmot
          2 hours ago

















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f456249%2frotating-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