Rotating in TikZ
Clash 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
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
add a comment |Â
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
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
add a comment |Â
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
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
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
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
tikz-pgf
asked 2 hours ago
Denis
1,894520
1,894520
add a comment |Â
add a comment |Â
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
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
+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 thepgfmanual
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
 |Â
show 1 more comment
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
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
+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 thepgfmanual
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
 |Â
show 1 more comment
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
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
+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 thepgfmanual
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
 |Â
show 1 more comment
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
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
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
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
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 thepgfmanual
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
 |Â
show 1 more comment
+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 thepgfmanual
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
 |Â
show 1 more comment
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password