How can I use pgf from within TikZTransforming coordinates, so (0,0) from tikzpicture is put in the desired...
For Loop and Sum
Wanted: 5.25 floppy to usb adapter
Can a hotel cancel a confirmed reservation?
Do commercial flights continue with an engine out?
Proof by Induction - New to proofs
Using AWS Fargate as web server
ip vs ifconfig commands pros and cons
How do we edit a novel that's written by several people?
What happens if a wizard reaches level 20 but has no 3rd-level spells that they can use with the Signature Spells feature?
A Wacky, Wacky Chessboard (That Makes No Sense)
Predict mars robot position
How can I improve my fireworks photography?
Is the theory of the category of topological spaces computable?
Why is this code uniquely decodable?
What is the purpose of easy combat scenarios that don't need resource expenditure?
Eww, those bytes are gross
Quenching swords in dragon blood; why?
c++ How can I make an algorithm for finding variations of a set without repetition (i.e. n elements, choose k)?
Why can I easily sing or whistle a tune I've just heard, but not as easily reproduce it on an instrument?
Why do members of Congress in committee hearings ask witnesses the same question multiple times?
Avoiding morning and evening handshakes
What is the meaning of "pick up" in this sentence?
How to avoid being sexist when trying to employ someone to function in a very sexist environment?
Why zero tolerance on nudity in space?
How can I use pgf from within TikZ
Transforming coordinates, so (0,0) from tikzpicture is put in the desired place of the pageTikZ and PGF — Design considerations and approach to sizing pictures?How to calculate intersections of a line defined by a segment and an ellipse in tikzSpherical triangles and great circlesTikZ: Drawing an arc from an intersection to an intersectionDrawing rectilinear curves in Tikz, aka an Etch-a-Sketch drawingLine up nested tikz enviroments or how to get rid of themTikZ: “Clipping problem”Difference between an option's default and its initial valueuse of pgf intersections package for paths
Background: I understand that TikZ is built on top of pgf. Both are described in the pgf manual. However, I have been unable to find the section (if it exists at all) of the manual describing how the two are connected. This is a problem to me, as I enjoy the high level constructs of TikZ, yet I notice a number of useful primitives in pgf that I don't know how to access.
As an example, consider this simple picture:
There are two short, non-intersecting line segments. The circle marks the point where the extended lines meet. The line segments and node labels were created with TikZ, the intersection with pgf.
Here is the code, lifted from the manual and adapted slightly:
documentclass[tikz]{standalone}
begin{document}
begin{tikzpicture}[x=20mm,y=20mm]
draw
(.5,0) node[left](A){$A$} -- (1,.8) node[left]{B}
(2,0) node[left](C){$C$} -- (1.5,1) node[right](D){D};
pgfpathcircle{%
pgfpointintersectionoflines
{pgfpointxy{.5}{0}}{pgfpointxy{1}{.8}}
{pgfpointxy{2}{0}}{pgfpointxy{1.5}{1}}}
{2pt}
pgfusepath{stroke}
end{tikzpicture}
end{document}
Clearly, the code is not DRY: The coordinates are repeated in the pgf section. But if the points A–D were them selves the result of calculations, this is not a viable option. Also, I can draw the intersection point, but I cannot use it in further work at the TikZ level. Hence my questions:
- How do I represent the points A–D in terms that
pgfpointintersectionoflines
and other pgf constructs can use?
- And how do I extract the result from the pgf world, for further use in the TikZ world?
Note that I am looking for answers that can be generalised, not a hack applying only to the present problem.
tikz-pgf
add a comment |
Background: I understand that TikZ is built on top of pgf. Both are described in the pgf manual. However, I have been unable to find the section (if it exists at all) of the manual describing how the two are connected. This is a problem to me, as I enjoy the high level constructs of TikZ, yet I notice a number of useful primitives in pgf that I don't know how to access.
As an example, consider this simple picture:
There are two short, non-intersecting line segments. The circle marks the point where the extended lines meet. The line segments and node labels were created with TikZ, the intersection with pgf.
Here is the code, lifted from the manual and adapted slightly:
documentclass[tikz]{standalone}
begin{document}
begin{tikzpicture}[x=20mm,y=20mm]
draw
(.5,0) node[left](A){$A$} -- (1,.8) node[left]{B}
(2,0) node[left](C){$C$} -- (1.5,1) node[right](D){D};
pgfpathcircle{%
pgfpointintersectionoflines
{pgfpointxy{.5}{0}}{pgfpointxy{1}{.8}}
{pgfpointxy{2}{0}}{pgfpointxy{1.5}{1}}}
{2pt}
pgfusepath{stroke}
end{tikzpicture}
end{document}
Clearly, the code is not DRY: The coordinates are repeated in the pgf section. But if the points A–D were them selves the result of calculations, this is not a viable option. Also, I can draw the intersection point, but I cannot use it in further work at the TikZ level. Hence my questions:
- How do I represent the points A–D in terms that
pgfpointintersectionoflines
and other pgf constructs can use?
- And how do I extract the result from the pgf world, for further use in the TikZ world?
Note that I am looking for answers that can be generalised, not a hack applying only to the present problem.
tikz-pgf
1
For the second part, seems you can do e.g.pgfcoordinate{foo}{ pgfpointintersectionoflines {pgfpointxy{.5}{0}}{pgfpointxy{1}{.8}} {pgfpointxy{2}{0}}{pgfpointxy{1.5}{1}}}
to get a coordinate namedfoo
at the intersection.
– Torbjørn T.
12 hours ago
@TorbjørnT. Indeed, that works. Thanks! (To be clear, it can then be referred to as(foo)
later on.)
– Harald Hanche-Olsen
12 hours ago
add a comment |
Background: I understand that TikZ is built on top of pgf. Both are described in the pgf manual. However, I have been unable to find the section (if it exists at all) of the manual describing how the two are connected. This is a problem to me, as I enjoy the high level constructs of TikZ, yet I notice a number of useful primitives in pgf that I don't know how to access.
As an example, consider this simple picture:
There are two short, non-intersecting line segments. The circle marks the point where the extended lines meet. The line segments and node labels were created with TikZ, the intersection with pgf.
Here is the code, lifted from the manual and adapted slightly:
documentclass[tikz]{standalone}
begin{document}
begin{tikzpicture}[x=20mm,y=20mm]
draw
(.5,0) node[left](A){$A$} -- (1,.8) node[left]{B}
(2,0) node[left](C){$C$} -- (1.5,1) node[right](D){D};
pgfpathcircle{%
pgfpointintersectionoflines
{pgfpointxy{.5}{0}}{pgfpointxy{1}{.8}}
{pgfpointxy{2}{0}}{pgfpointxy{1.5}{1}}}
{2pt}
pgfusepath{stroke}
end{tikzpicture}
end{document}
Clearly, the code is not DRY: The coordinates are repeated in the pgf section. But if the points A–D were them selves the result of calculations, this is not a viable option. Also, I can draw the intersection point, but I cannot use it in further work at the TikZ level. Hence my questions:
- How do I represent the points A–D in terms that
pgfpointintersectionoflines
and other pgf constructs can use?
- And how do I extract the result from the pgf world, for further use in the TikZ world?
Note that I am looking for answers that can be generalised, not a hack applying only to the present problem.
tikz-pgf
Background: I understand that TikZ is built on top of pgf. Both are described in the pgf manual. However, I have been unable to find the section (if it exists at all) of the manual describing how the two are connected. This is a problem to me, as I enjoy the high level constructs of TikZ, yet I notice a number of useful primitives in pgf that I don't know how to access.
As an example, consider this simple picture:
There are two short, non-intersecting line segments. The circle marks the point where the extended lines meet. The line segments and node labels were created with TikZ, the intersection with pgf.
Here is the code, lifted from the manual and adapted slightly:
documentclass[tikz]{standalone}
begin{document}
begin{tikzpicture}[x=20mm,y=20mm]
draw
(.5,0) node[left](A){$A$} -- (1,.8) node[left]{B}
(2,0) node[left](C){$C$} -- (1.5,1) node[right](D){D};
pgfpathcircle{%
pgfpointintersectionoflines
{pgfpointxy{.5}{0}}{pgfpointxy{1}{.8}}
{pgfpointxy{2}{0}}{pgfpointxy{1.5}{1}}}
{2pt}
pgfusepath{stroke}
end{tikzpicture}
end{document}
Clearly, the code is not DRY: The coordinates are repeated in the pgf section. But if the points A–D were them selves the result of calculations, this is not a viable option. Also, I can draw the intersection point, but I cannot use it in further work at the TikZ level. Hence my questions:
- How do I represent the points A–D in terms that
pgfpointintersectionoflines
and other pgf constructs can use?
- And how do I extract the result from the pgf world, for further use in the TikZ world?
Note that I am looking for answers that can be generalised, not a hack applying only to the present problem.
tikz-pgf
tikz-pgf
asked 14 hours ago
Harald Hanche-OlsenHarald Hanche-Olsen
13.1k24762
13.1k24762
1
For the second part, seems you can do e.g.pgfcoordinate{foo}{ pgfpointintersectionoflines {pgfpointxy{.5}{0}}{pgfpointxy{1}{.8}} {pgfpointxy{2}{0}}{pgfpointxy{1.5}{1}}}
to get a coordinate namedfoo
at the intersection.
– Torbjørn T.
12 hours ago
@TorbjørnT. Indeed, that works. Thanks! (To be clear, it can then be referred to as(foo)
later on.)
– Harald Hanche-Olsen
12 hours ago
add a comment |
1
For the second part, seems you can do e.g.pgfcoordinate{foo}{ pgfpointintersectionoflines {pgfpointxy{.5}{0}}{pgfpointxy{1}{.8}} {pgfpointxy{2}{0}}{pgfpointxy{1.5}{1}}}
to get a coordinate namedfoo
at the intersection.
– Torbjørn T.
12 hours ago
@TorbjørnT. Indeed, that works. Thanks! (To be clear, it can then be referred to as(foo)
later on.)
– Harald Hanche-Olsen
12 hours ago
1
1
For the second part, seems you can do e.g.
pgfcoordinate{foo}{ pgfpointintersectionoflines {pgfpointxy{.5}{0}}{pgfpointxy{1}{.8}} {pgfpointxy{2}{0}}{pgfpointxy{1.5}{1}}}
to get a coordinate named foo
at the intersection.– Torbjørn T.
12 hours ago
For the second part, seems you can do e.g.
pgfcoordinate{foo}{ pgfpointintersectionoflines {pgfpointxy{.5}{0}}{pgfpointxy{1}{.8}} {pgfpointxy{2}{0}}{pgfpointxy{1.5}{1}}}
to get a coordinate named foo
at the intersection.– Torbjørn T.
12 hours ago
@TorbjørnT. Indeed, that works. Thanks! (To be clear, it can then be referred to as
(foo)
later on.)– Harald Hanche-Olsen
12 hours ago
@TorbjørnT. Indeed, that works. Thanks! (To be clear, it can then be referred to as
(foo)
later on.)– Harald Hanche-Olsen
12 hours ago
add a comment |
2 Answers
2
active
oldest
votes
In addition to what Torbjørn T. says you can use existing nodes/coordinates with pgfpointanchor{<name>}{<anchor>}
.
documentclass[tikz]{standalone}
begin{document}
begin{tikzpicture}[x=20mm,y=20mm]
draw
(.5,0) node[left](A){$A$} -- (1,.8) node[left](B){B}
(2,0) node[left](C){$C$} -- (1.5,1) node[right](D){D};
pgfcoordinate{aux}{pgfpointintersectionoflines
{pgfpointanchor{A}{east}}{pgfpointanchor{B}{east}}
{pgfpointanchor{C}{east}}{pgfpointanchor{D}{west}}}
pgfpathcircle{pgfpointanchor{aux}{center}}{2pt}
pgfusepath{stroke}
draw (aux) -- (aux|-A.south);
end{tikzpicture}
end{document}
Thanks, that is useful. But I had just realised, before seeing your answer, that I messed up a little: I should have let(A)
refer to coordinates, not anchors. I.e., I should have used(.5,0) coordinate(A) node{$A$}
and similarly for the other points. And then, all thepgfpointanchor
macros can be given{center}
as their second argument.
– Harald Hanche-Olsen
9 hours ago
@HaraldHanche-Olsen You haven't "messed up" I think.;-)
– marmot
9 hours ago
add a comment |
I did come up with another solution myself. It is not as nice as marmot's answer, but as it is a different approach to the same problem, possibly enabling a different set of options, I offer it here, for the record:
documentclass[tikz]{standalone}
usetikzlibrary{math}
begin{document}
begin{tikzpicture}[x=20mm,y=20mm]
draw
(.5,0) coordinate(A) node[left]{$A$} -- (1,.8) coordinate(B) node[left]{B}
(2,0) coordinate(C) node[left]{$C$} -- (1.5,1) coordinate(D) node[right]{D};
tikzmath{
coordinate A; A = (A);
coordinate B; B = (B);
coordinate C; C = (C);
coordinate D; D = (D); }
pgfcoordinate{E}{
pgfpointintersectionoflines
{pgfpoint{Ax}{Ay}}{pgfpoint{Bx}{By}}
{pgfpoint{Cx}{Cy}}{pgfpoint{Dx}{Dy}}}
draw (E) circle[radius=2pt];
end{tikzpicture}
end{document}
In the process of getting there, I learned the difference between pgfpoint
(canvas coordinates?) and pgfpointxy
(user coordinates).
I knew you would go fortikzmath
;-)
– marmot
9 hours ago
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%2f477542%2fhow-can-i-use-pgf-from-within-tikz%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
In addition to what Torbjørn T. says you can use existing nodes/coordinates with pgfpointanchor{<name>}{<anchor>}
.
documentclass[tikz]{standalone}
begin{document}
begin{tikzpicture}[x=20mm,y=20mm]
draw
(.5,0) node[left](A){$A$} -- (1,.8) node[left](B){B}
(2,0) node[left](C){$C$} -- (1.5,1) node[right](D){D};
pgfcoordinate{aux}{pgfpointintersectionoflines
{pgfpointanchor{A}{east}}{pgfpointanchor{B}{east}}
{pgfpointanchor{C}{east}}{pgfpointanchor{D}{west}}}
pgfpathcircle{pgfpointanchor{aux}{center}}{2pt}
pgfusepath{stroke}
draw (aux) -- (aux|-A.south);
end{tikzpicture}
end{document}
Thanks, that is useful. But I had just realised, before seeing your answer, that I messed up a little: I should have let(A)
refer to coordinates, not anchors. I.e., I should have used(.5,0) coordinate(A) node{$A$}
and similarly for the other points. And then, all thepgfpointanchor
macros can be given{center}
as their second argument.
– Harald Hanche-Olsen
9 hours ago
@HaraldHanche-Olsen You haven't "messed up" I think.;-)
– marmot
9 hours ago
add a comment |
In addition to what Torbjørn T. says you can use existing nodes/coordinates with pgfpointanchor{<name>}{<anchor>}
.
documentclass[tikz]{standalone}
begin{document}
begin{tikzpicture}[x=20mm,y=20mm]
draw
(.5,0) node[left](A){$A$} -- (1,.8) node[left](B){B}
(2,0) node[left](C){$C$} -- (1.5,1) node[right](D){D};
pgfcoordinate{aux}{pgfpointintersectionoflines
{pgfpointanchor{A}{east}}{pgfpointanchor{B}{east}}
{pgfpointanchor{C}{east}}{pgfpointanchor{D}{west}}}
pgfpathcircle{pgfpointanchor{aux}{center}}{2pt}
pgfusepath{stroke}
draw (aux) -- (aux|-A.south);
end{tikzpicture}
end{document}
Thanks, that is useful. But I had just realised, before seeing your answer, that I messed up a little: I should have let(A)
refer to coordinates, not anchors. I.e., I should have used(.5,0) coordinate(A) node{$A$}
and similarly for the other points. And then, all thepgfpointanchor
macros can be given{center}
as their second argument.
– Harald Hanche-Olsen
9 hours ago
@HaraldHanche-Olsen You haven't "messed up" I think.;-)
– marmot
9 hours ago
add a comment |
In addition to what Torbjørn T. says you can use existing nodes/coordinates with pgfpointanchor{<name>}{<anchor>}
.
documentclass[tikz]{standalone}
begin{document}
begin{tikzpicture}[x=20mm,y=20mm]
draw
(.5,0) node[left](A){$A$} -- (1,.8) node[left](B){B}
(2,0) node[left](C){$C$} -- (1.5,1) node[right](D){D};
pgfcoordinate{aux}{pgfpointintersectionoflines
{pgfpointanchor{A}{east}}{pgfpointanchor{B}{east}}
{pgfpointanchor{C}{east}}{pgfpointanchor{D}{west}}}
pgfpathcircle{pgfpointanchor{aux}{center}}{2pt}
pgfusepath{stroke}
draw (aux) -- (aux|-A.south);
end{tikzpicture}
end{document}
In addition to what Torbjørn T. says you can use existing nodes/coordinates with pgfpointanchor{<name>}{<anchor>}
.
documentclass[tikz]{standalone}
begin{document}
begin{tikzpicture}[x=20mm,y=20mm]
draw
(.5,0) node[left](A){$A$} -- (1,.8) node[left](B){B}
(2,0) node[left](C){$C$} -- (1.5,1) node[right](D){D};
pgfcoordinate{aux}{pgfpointintersectionoflines
{pgfpointanchor{A}{east}}{pgfpointanchor{B}{east}}
{pgfpointanchor{C}{east}}{pgfpointanchor{D}{west}}}
pgfpathcircle{pgfpointanchor{aux}{center}}{2pt}
pgfusepath{stroke}
draw (aux) -- (aux|-A.south);
end{tikzpicture}
end{document}
answered 11 hours ago
marmotmarmot
105k4126241
105k4126241
Thanks, that is useful. But I had just realised, before seeing your answer, that I messed up a little: I should have let(A)
refer to coordinates, not anchors. I.e., I should have used(.5,0) coordinate(A) node{$A$}
and similarly for the other points. And then, all thepgfpointanchor
macros can be given{center}
as their second argument.
– Harald Hanche-Olsen
9 hours ago
@HaraldHanche-Olsen You haven't "messed up" I think.;-)
– marmot
9 hours ago
add a comment |
Thanks, that is useful. But I had just realised, before seeing your answer, that I messed up a little: I should have let(A)
refer to coordinates, not anchors. I.e., I should have used(.5,0) coordinate(A) node{$A$}
and similarly for the other points. And then, all thepgfpointanchor
macros can be given{center}
as their second argument.
– Harald Hanche-Olsen
9 hours ago
@HaraldHanche-Olsen You haven't "messed up" I think.;-)
– marmot
9 hours ago
Thanks, that is useful. But I had just realised, before seeing your answer, that I messed up a little: I should have let
(A)
refer to coordinates, not anchors. I.e., I should have used (.5,0) coordinate(A) node{$A$}
and similarly for the other points. And then, all the pgfpointanchor
macros can be given {center}
as their second argument.– Harald Hanche-Olsen
9 hours ago
Thanks, that is useful. But I had just realised, before seeing your answer, that I messed up a little: I should have let
(A)
refer to coordinates, not anchors. I.e., I should have used (.5,0) coordinate(A) node{$A$}
and similarly for the other points. And then, all the pgfpointanchor
macros can be given {center}
as their second argument.– Harald Hanche-Olsen
9 hours ago
@HaraldHanche-Olsen You haven't "messed up" I think.;-)
– marmot
9 hours ago
@HaraldHanche-Olsen You haven't "messed up" I think.;-)
– marmot
9 hours ago
add a comment |
I did come up with another solution myself. It is not as nice as marmot's answer, but as it is a different approach to the same problem, possibly enabling a different set of options, I offer it here, for the record:
documentclass[tikz]{standalone}
usetikzlibrary{math}
begin{document}
begin{tikzpicture}[x=20mm,y=20mm]
draw
(.5,0) coordinate(A) node[left]{$A$} -- (1,.8) coordinate(B) node[left]{B}
(2,0) coordinate(C) node[left]{$C$} -- (1.5,1) coordinate(D) node[right]{D};
tikzmath{
coordinate A; A = (A);
coordinate B; B = (B);
coordinate C; C = (C);
coordinate D; D = (D); }
pgfcoordinate{E}{
pgfpointintersectionoflines
{pgfpoint{Ax}{Ay}}{pgfpoint{Bx}{By}}
{pgfpoint{Cx}{Cy}}{pgfpoint{Dx}{Dy}}}
draw (E) circle[radius=2pt];
end{tikzpicture}
end{document}
In the process of getting there, I learned the difference between pgfpoint
(canvas coordinates?) and pgfpointxy
(user coordinates).
I knew you would go fortikzmath
;-)
– marmot
9 hours ago
add a comment |
I did come up with another solution myself. It is not as nice as marmot's answer, but as it is a different approach to the same problem, possibly enabling a different set of options, I offer it here, for the record:
documentclass[tikz]{standalone}
usetikzlibrary{math}
begin{document}
begin{tikzpicture}[x=20mm,y=20mm]
draw
(.5,0) coordinate(A) node[left]{$A$} -- (1,.8) coordinate(B) node[left]{B}
(2,0) coordinate(C) node[left]{$C$} -- (1.5,1) coordinate(D) node[right]{D};
tikzmath{
coordinate A; A = (A);
coordinate B; B = (B);
coordinate C; C = (C);
coordinate D; D = (D); }
pgfcoordinate{E}{
pgfpointintersectionoflines
{pgfpoint{Ax}{Ay}}{pgfpoint{Bx}{By}}
{pgfpoint{Cx}{Cy}}{pgfpoint{Dx}{Dy}}}
draw (E) circle[radius=2pt];
end{tikzpicture}
end{document}
In the process of getting there, I learned the difference between pgfpoint
(canvas coordinates?) and pgfpointxy
(user coordinates).
I knew you would go fortikzmath
;-)
– marmot
9 hours ago
add a comment |
I did come up with another solution myself. It is not as nice as marmot's answer, but as it is a different approach to the same problem, possibly enabling a different set of options, I offer it here, for the record:
documentclass[tikz]{standalone}
usetikzlibrary{math}
begin{document}
begin{tikzpicture}[x=20mm,y=20mm]
draw
(.5,0) coordinate(A) node[left]{$A$} -- (1,.8) coordinate(B) node[left]{B}
(2,0) coordinate(C) node[left]{$C$} -- (1.5,1) coordinate(D) node[right]{D};
tikzmath{
coordinate A; A = (A);
coordinate B; B = (B);
coordinate C; C = (C);
coordinate D; D = (D); }
pgfcoordinate{E}{
pgfpointintersectionoflines
{pgfpoint{Ax}{Ay}}{pgfpoint{Bx}{By}}
{pgfpoint{Cx}{Cy}}{pgfpoint{Dx}{Dy}}}
draw (E) circle[radius=2pt];
end{tikzpicture}
end{document}
In the process of getting there, I learned the difference between pgfpoint
(canvas coordinates?) and pgfpointxy
(user coordinates).
I did come up with another solution myself. It is not as nice as marmot's answer, but as it is a different approach to the same problem, possibly enabling a different set of options, I offer it here, for the record:
documentclass[tikz]{standalone}
usetikzlibrary{math}
begin{document}
begin{tikzpicture}[x=20mm,y=20mm]
draw
(.5,0) coordinate(A) node[left]{$A$} -- (1,.8) coordinate(B) node[left]{B}
(2,0) coordinate(C) node[left]{$C$} -- (1.5,1) coordinate(D) node[right]{D};
tikzmath{
coordinate A; A = (A);
coordinate B; B = (B);
coordinate C; C = (C);
coordinate D; D = (D); }
pgfcoordinate{E}{
pgfpointintersectionoflines
{pgfpoint{Ax}{Ay}}{pgfpoint{Bx}{By}}
{pgfpoint{Cx}{Cy}}{pgfpoint{Dx}{Dy}}}
draw (E) circle[radius=2pt];
end{tikzpicture}
end{document}
In the process of getting there, I learned the difference between pgfpoint
(canvas coordinates?) and pgfpointxy
(user coordinates).
answered 9 hours ago
Harald Hanche-OlsenHarald Hanche-Olsen
13.1k24762
13.1k24762
I knew you would go fortikzmath
;-)
– marmot
9 hours ago
add a comment |
I knew you would go fortikzmath
;-)
– marmot
9 hours ago
I knew you would go for
tikzmath
;-)– marmot
9 hours ago
I knew you would go for
tikzmath
;-)– marmot
9 hours ago
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%2f477542%2fhow-can-i-use-pgf-from-within-tikz%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
1
For the second part, seems you can do e.g.
pgfcoordinate{foo}{ pgfpointintersectionoflines {pgfpointxy{.5}{0}}{pgfpointxy{1}{.8}} {pgfpointxy{2}{0}}{pgfpointxy{1.5}{1}}}
to get a coordinate namedfoo
at the intersection.– Torbjørn T.
12 hours ago
@TorbjørnT. Indeed, that works. Thanks! (To be clear, it can then be referred to as
(foo)
later on.)– Harald Hanche-Olsen
12 hours ago