Tikz: Copy segment length
Clash Royale CLAN TAG#URR8PPP
Is it possible to have a macro which uses the length between to points to calculate another calculate, as in the following example:
documentclass[tikz,border=10pt]standalone
usepackagetikz
usetikzlibrarycalc
begindocument
begintikzpicture
coordinate (A) at (0,0);
coordinate (B) at (2,5);
coordinate (C) at (7,0);
% Is this possible?
% From point C to the direction of point A with the length of
% from point A to point B
% coordinate (D) at ($(C)!(A)!(A)-(B)$);
% or
% From point C to the direction of 60 degrees with the length of
% from point A to point B
% coordinate (D) at ($(C)!(60)!(A)-(B)$);
draw (A)--(B)--(C)--cycle;
endtikzpicture
enddocument
tikz-pgf
add a comment |
Is it possible to have a macro which uses the length between to points to calculate another calculate, as in the following example:
documentclass[tikz,border=10pt]standalone
usepackagetikz
usetikzlibrarycalc
begindocument
begintikzpicture
coordinate (A) at (0,0);
coordinate (B) at (2,5);
coordinate (C) at (7,0);
% Is this possible?
% From point C to the direction of point A with the length of
% from point A to point B
% coordinate (D) at ($(C)!(A)!(A)-(B)$);
% or
% From point C to the direction of 60 degrees with the length of
% from point A to point B
% coordinate (D) at ($(C)!(60)!(A)-(B)$);
draw (A)--(B)--(C)--cycle;
endtikzpicture
enddocument
tikz-pgf
add a comment |
Is it possible to have a macro which uses the length between to points to calculate another calculate, as in the following example:
documentclass[tikz,border=10pt]standalone
usepackagetikz
usetikzlibrarycalc
begindocument
begintikzpicture
coordinate (A) at (0,0);
coordinate (B) at (2,5);
coordinate (C) at (7,0);
% Is this possible?
% From point C to the direction of point A with the length of
% from point A to point B
% coordinate (D) at ($(C)!(A)!(A)-(B)$);
% or
% From point C to the direction of 60 degrees with the length of
% from point A to point B
% coordinate (D) at ($(C)!(60)!(A)-(B)$);
draw (A)--(B)--(C)--cycle;
endtikzpicture
enddocument
tikz-pgf
Is it possible to have a macro which uses the length between to points to calculate another calculate, as in the following example:
documentclass[tikz,border=10pt]standalone
usepackagetikz
usetikzlibrarycalc
begindocument
begintikzpicture
coordinate (A) at (0,0);
coordinate (B) at (2,5);
coordinate (C) at (7,0);
% Is this possible?
% From point C to the direction of point A with the length of
% from point A to point B
% coordinate (D) at ($(C)!(A)!(A)-(B)$);
% or
% From point C to the direction of 60 degrees with the length of
% from point A to point B
% coordinate (D) at ($(C)!(60)!(A)-(B)$);
draw (A)--(B)--(C)--cycle;
endtikzpicture
enddocument
tikz-pgf
tikz-pgf
edited Mar 14 at 4:53
Doruk
asked Mar 14 at 4:26
DorukDoruk
285
285
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Something like this?
documentclass[tikz,border=10pt]standalone
usetikzlibrarycalc
begindocument
begintikzpicture
coordinate (A) at (0,0);
coordinate (B) at (2,5);
coordinate (C) at (7,0);
% Is this possible?
% From point C to the direction of point A with the length of
% from point A to point B
path let p1=($(B)-(A)$),n1=veclen(x1,y1) in ($(C)!n1!(A)$)
coordinate(D) ($(C)+(60:n1)$) coordinate (D');
% or
% From point C to the direction of 60 degrees with the length of
% from point A to point B
% coordinate (D) at ($(C)!(60)!(A)-(B)$);
draw (A)--(B)--(C)--cycle;
draw[blue,thick] (C) -- (D);
draw[red,thick] (C) -- (D');
endtikzpicture
enddocument
Or with styles:
documentclass[tikz,border=10pt]standalone
usetikzlibrarycalc
begindocument
begintikzpicture[towards/.style args=#1 from #2 with length from #3 to #4%
insert path=let p1=($(#3)-(#4)$),n1=veclen(x1,y1) in
($(#2)!n1!(#1)$),into direction/.style args=#1 from #2 with length from #3 to #4%
insert path=let p1=($(#3)-(#4)$),n1=veclen(x1,y1) in
($(#2)+(#1:n1)$)]
coordinate (A) at (0,0);
coordinate (B) at (2,5);
coordinate (C) at (7,0);
% Is this possible?
% From point C to the direction of point A with the length of
% from point A to point B
path[towards=A from C with length from A to B]
coordinate(D) ;
% or
% From point C to the direction of 60 degrees with the length of
% from point A to point B
% coordinate (D) at ($(C)!(60)!(A)-(B)$);
path[into direction=60 from C with length from A to B]
coordinate(D') ;
draw (A)--(B)--(C)--cycle;
draw[blue,thick] (C) -- (D);
draw[red,thick] (C) -- (D');
endtikzpicture
enddocument
Can I ask for an extension this beautiful solution (or does it have to be a separate question?) Say I want to go from point C to the direction of 60 degrees relative to line CD (similar to(A)!1!60:(B)
, etc. with length from x to y. How would I do that?
– blackened
Apr 9 at 8:57
1
@blackened You could dotikzsetinto rotated direction/.style args=of #1 from #2 by #3 with length from #4 to #5% insert path=let p1=($(#4)-(#5)$),n1=veclen(x1,y1),p2=($(#1)-(#2)$), n2=atan2(y2,x2) in ($(#2)+(n2+#3:n1)$)
. and then use it e.g. likepath[into rotated direction=of B from C by 60 with length from A to B] coordinate(D'') ; draw[orange,thick] (C) -- (D'');
in the above example. I am not sure, though, if there is a large demand for that, so I hesitate to edit the answer.
– marmot
Apr 9 at 13:56
add a comment |
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',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
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
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f479413%2ftikz-copy-segment-length%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Something like this?
documentclass[tikz,border=10pt]standalone
usetikzlibrarycalc
begindocument
begintikzpicture
coordinate (A) at (0,0);
coordinate (B) at (2,5);
coordinate (C) at (7,0);
% Is this possible?
% From point C to the direction of point A with the length of
% from point A to point B
path let p1=($(B)-(A)$),n1=veclen(x1,y1) in ($(C)!n1!(A)$)
coordinate(D) ($(C)+(60:n1)$) coordinate (D');
% or
% From point C to the direction of 60 degrees with the length of
% from point A to point B
% coordinate (D) at ($(C)!(60)!(A)-(B)$);
draw (A)--(B)--(C)--cycle;
draw[blue,thick] (C) -- (D);
draw[red,thick] (C) -- (D');
endtikzpicture
enddocument
Or with styles:
documentclass[tikz,border=10pt]standalone
usetikzlibrarycalc
begindocument
begintikzpicture[towards/.style args=#1 from #2 with length from #3 to #4%
insert path=let p1=($(#3)-(#4)$),n1=veclen(x1,y1) in
($(#2)!n1!(#1)$),into direction/.style args=#1 from #2 with length from #3 to #4%
insert path=let p1=($(#3)-(#4)$),n1=veclen(x1,y1) in
($(#2)+(#1:n1)$)]
coordinate (A) at (0,0);
coordinate (B) at (2,5);
coordinate (C) at (7,0);
% Is this possible?
% From point C to the direction of point A with the length of
% from point A to point B
path[towards=A from C with length from A to B]
coordinate(D) ;
% or
% From point C to the direction of 60 degrees with the length of
% from point A to point B
% coordinate (D) at ($(C)!(60)!(A)-(B)$);
path[into direction=60 from C with length from A to B]
coordinate(D') ;
draw (A)--(B)--(C)--cycle;
draw[blue,thick] (C) -- (D);
draw[red,thick] (C) -- (D');
endtikzpicture
enddocument
Can I ask for an extension this beautiful solution (or does it have to be a separate question?) Say I want to go from point C to the direction of 60 degrees relative to line CD (similar to(A)!1!60:(B)
, etc. with length from x to y. How would I do that?
– blackened
Apr 9 at 8:57
1
@blackened You could dotikzsetinto rotated direction/.style args=of #1 from #2 by #3 with length from #4 to #5% insert path=let p1=($(#4)-(#5)$),n1=veclen(x1,y1),p2=($(#1)-(#2)$), n2=atan2(y2,x2) in ($(#2)+(n2+#3:n1)$)
. and then use it e.g. likepath[into rotated direction=of B from C by 60 with length from A to B] coordinate(D'') ; draw[orange,thick] (C) -- (D'');
in the above example. I am not sure, though, if there is a large demand for that, so I hesitate to edit the answer.
– marmot
Apr 9 at 13:56
add a comment |
Something like this?
documentclass[tikz,border=10pt]standalone
usetikzlibrarycalc
begindocument
begintikzpicture
coordinate (A) at (0,0);
coordinate (B) at (2,5);
coordinate (C) at (7,0);
% Is this possible?
% From point C to the direction of point A with the length of
% from point A to point B
path let p1=($(B)-(A)$),n1=veclen(x1,y1) in ($(C)!n1!(A)$)
coordinate(D) ($(C)+(60:n1)$) coordinate (D');
% or
% From point C to the direction of 60 degrees with the length of
% from point A to point B
% coordinate (D) at ($(C)!(60)!(A)-(B)$);
draw (A)--(B)--(C)--cycle;
draw[blue,thick] (C) -- (D);
draw[red,thick] (C) -- (D');
endtikzpicture
enddocument
Or with styles:
documentclass[tikz,border=10pt]standalone
usetikzlibrarycalc
begindocument
begintikzpicture[towards/.style args=#1 from #2 with length from #3 to #4%
insert path=let p1=($(#3)-(#4)$),n1=veclen(x1,y1) in
($(#2)!n1!(#1)$),into direction/.style args=#1 from #2 with length from #3 to #4%
insert path=let p1=($(#3)-(#4)$),n1=veclen(x1,y1) in
($(#2)+(#1:n1)$)]
coordinate (A) at (0,0);
coordinate (B) at (2,5);
coordinate (C) at (7,0);
% Is this possible?
% From point C to the direction of point A with the length of
% from point A to point B
path[towards=A from C with length from A to B]
coordinate(D) ;
% or
% From point C to the direction of 60 degrees with the length of
% from point A to point B
% coordinate (D) at ($(C)!(60)!(A)-(B)$);
path[into direction=60 from C with length from A to B]
coordinate(D') ;
draw (A)--(B)--(C)--cycle;
draw[blue,thick] (C) -- (D);
draw[red,thick] (C) -- (D');
endtikzpicture
enddocument
Can I ask for an extension this beautiful solution (or does it have to be a separate question?) Say I want to go from point C to the direction of 60 degrees relative to line CD (similar to(A)!1!60:(B)
, etc. with length from x to y. How would I do that?
– blackened
Apr 9 at 8:57
1
@blackened You could dotikzsetinto rotated direction/.style args=of #1 from #2 by #3 with length from #4 to #5% insert path=let p1=($(#4)-(#5)$),n1=veclen(x1,y1),p2=($(#1)-(#2)$), n2=atan2(y2,x2) in ($(#2)+(n2+#3:n1)$)
. and then use it e.g. likepath[into rotated direction=of B from C by 60 with length from A to B] coordinate(D'') ; draw[orange,thick] (C) -- (D'');
in the above example. I am not sure, though, if there is a large demand for that, so I hesitate to edit the answer.
– marmot
Apr 9 at 13:56
add a comment |
Something like this?
documentclass[tikz,border=10pt]standalone
usetikzlibrarycalc
begindocument
begintikzpicture
coordinate (A) at (0,0);
coordinate (B) at (2,5);
coordinate (C) at (7,0);
% Is this possible?
% From point C to the direction of point A with the length of
% from point A to point B
path let p1=($(B)-(A)$),n1=veclen(x1,y1) in ($(C)!n1!(A)$)
coordinate(D) ($(C)+(60:n1)$) coordinate (D');
% or
% From point C to the direction of 60 degrees with the length of
% from point A to point B
% coordinate (D) at ($(C)!(60)!(A)-(B)$);
draw (A)--(B)--(C)--cycle;
draw[blue,thick] (C) -- (D);
draw[red,thick] (C) -- (D');
endtikzpicture
enddocument
Or with styles:
documentclass[tikz,border=10pt]standalone
usetikzlibrarycalc
begindocument
begintikzpicture[towards/.style args=#1 from #2 with length from #3 to #4%
insert path=let p1=($(#3)-(#4)$),n1=veclen(x1,y1) in
($(#2)!n1!(#1)$),into direction/.style args=#1 from #2 with length from #3 to #4%
insert path=let p1=($(#3)-(#4)$),n1=veclen(x1,y1) in
($(#2)+(#1:n1)$)]
coordinate (A) at (0,0);
coordinate (B) at (2,5);
coordinate (C) at (7,0);
% Is this possible?
% From point C to the direction of point A with the length of
% from point A to point B
path[towards=A from C with length from A to B]
coordinate(D) ;
% or
% From point C to the direction of 60 degrees with the length of
% from point A to point B
% coordinate (D) at ($(C)!(60)!(A)-(B)$);
path[into direction=60 from C with length from A to B]
coordinate(D') ;
draw (A)--(B)--(C)--cycle;
draw[blue,thick] (C) -- (D);
draw[red,thick] (C) -- (D');
endtikzpicture
enddocument
Something like this?
documentclass[tikz,border=10pt]standalone
usetikzlibrarycalc
begindocument
begintikzpicture
coordinate (A) at (0,0);
coordinate (B) at (2,5);
coordinate (C) at (7,0);
% Is this possible?
% From point C to the direction of point A with the length of
% from point A to point B
path let p1=($(B)-(A)$),n1=veclen(x1,y1) in ($(C)!n1!(A)$)
coordinate(D) ($(C)+(60:n1)$) coordinate (D');
% or
% From point C to the direction of 60 degrees with the length of
% from point A to point B
% coordinate (D) at ($(C)!(60)!(A)-(B)$);
draw (A)--(B)--(C)--cycle;
draw[blue,thick] (C) -- (D);
draw[red,thick] (C) -- (D');
endtikzpicture
enddocument
Or with styles:
documentclass[tikz,border=10pt]standalone
usetikzlibrarycalc
begindocument
begintikzpicture[towards/.style args=#1 from #2 with length from #3 to #4%
insert path=let p1=($(#3)-(#4)$),n1=veclen(x1,y1) in
($(#2)!n1!(#1)$),into direction/.style args=#1 from #2 with length from #3 to #4%
insert path=let p1=($(#3)-(#4)$),n1=veclen(x1,y1) in
($(#2)+(#1:n1)$)]
coordinate (A) at (0,0);
coordinate (B) at (2,5);
coordinate (C) at (7,0);
% Is this possible?
% From point C to the direction of point A with the length of
% from point A to point B
path[towards=A from C with length from A to B]
coordinate(D) ;
% or
% From point C to the direction of 60 degrees with the length of
% from point A to point B
% coordinate (D) at ($(C)!(60)!(A)-(B)$);
path[into direction=60 from C with length from A to B]
coordinate(D') ;
draw (A)--(B)--(C)--cycle;
draw[blue,thick] (C) -- (D);
draw[red,thick] (C) -- (D');
endtikzpicture
enddocument
edited Mar 14 at 5:31
answered Mar 14 at 4:56
marmotmarmot
117k5150283
117k5150283
Can I ask for an extension this beautiful solution (or does it have to be a separate question?) Say I want to go from point C to the direction of 60 degrees relative to line CD (similar to(A)!1!60:(B)
, etc. with length from x to y. How would I do that?
– blackened
Apr 9 at 8:57
1
@blackened You could dotikzsetinto rotated direction/.style args=of #1 from #2 by #3 with length from #4 to #5% insert path=let p1=($(#4)-(#5)$),n1=veclen(x1,y1),p2=($(#1)-(#2)$), n2=atan2(y2,x2) in ($(#2)+(n2+#3:n1)$)
. and then use it e.g. likepath[into rotated direction=of B from C by 60 with length from A to B] coordinate(D'') ; draw[orange,thick] (C) -- (D'');
in the above example. I am not sure, though, if there is a large demand for that, so I hesitate to edit the answer.
– marmot
Apr 9 at 13:56
add a comment |
Can I ask for an extension this beautiful solution (or does it have to be a separate question?) Say I want to go from point C to the direction of 60 degrees relative to line CD (similar to(A)!1!60:(B)
, etc. with length from x to y. How would I do that?
– blackened
Apr 9 at 8:57
1
@blackened You could dotikzsetinto rotated direction/.style args=of #1 from #2 by #3 with length from #4 to #5% insert path=let p1=($(#4)-(#5)$),n1=veclen(x1,y1),p2=($(#1)-(#2)$), n2=atan2(y2,x2) in ($(#2)+(n2+#3:n1)$)
. and then use it e.g. likepath[into rotated direction=of B from C by 60 with length from A to B] coordinate(D'') ; draw[orange,thick] (C) -- (D'');
in the above example. I am not sure, though, if there is a large demand for that, so I hesitate to edit the answer.
– marmot
Apr 9 at 13:56
Can I ask for an extension this beautiful solution (or does it have to be a separate question?) Say I want to go from point C to the direction of 60 degrees relative to line CD (similar to
(A)!1!60:(B)
, etc. with length from x to y. How would I do that?– blackened
Apr 9 at 8:57
Can I ask for an extension this beautiful solution (or does it have to be a separate question?) Say I want to go from point C to the direction of 60 degrees relative to line CD (similar to
(A)!1!60:(B)
, etc. with length from x to y. How would I do that?– blackened
Apr 9 at 8:57
1
1
@blackened You could do
tikzsetinto rotated direction/.style args=of #1 from #2 by #3 with length from #4 to #5% insert path=let p1=($(#4)-(#5)$),n1=veclen(x1,y1),p2=($(#1)-(#2)$), n2=atan2(y2,x2) in ($(#2)+(n2+#3:n1)$)
. and then use it e.g. like path[into rotated direction=of B from C by 60 with length from A to B] coordinate(D'') ; draw[orange,thick] (C) -- (D'');
in the above example. I am not sure, though, if there is a large demand for that, so I hesitate to edit the answer.– marmot
Apr 9 at 13:56
@blackened You could do
tikzsetinto rotated direction/.style args=of #1 from #2 by #3 with length from #4 to #5% insert path=let p1=($(#4)-(#5)$),n1=veclen(x1,y1),p2=($(#1)-(#2)$), n2=atan2(y2,x2) in ($(#2)+(n2+#3:n1)$)
. and then use it e.g. like path[into rotated direction=of B from C by 60 with length from A to B] coordinate(D'') ; draw[orange,thick] (C) -- (D'');
in the above example. I am not sure, though, if there is a large demand for that, so I hesitate to edit the answer.– marmot
Apr 9 at 13:56
add a comment |
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f479413%2ftikz-copy-segment-length%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
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
Required, but never shown
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
Required, but never shown
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
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown