How can I use pgf from within TikZTransforming coordinates, so (0,0) from tikzpicture is put in the desired...
A Wacky, Wacky Chessboard (That Makes No Sense)
How to avoid being sexist when trying to employ someone to function in a very sexist environment?
Do authors have to be politically correct in article-writing?
What is the purpose of easy combat scenarios that don't need resource expenditure?
Why do members of Congress in committee hearings ask witnesses the same question multiple times?
Which aircraft had such a luxurious-looking navigator's station?
Is the theory of the category of topological spaces computable?
Can the Count of Monte Cristo's calculation of poison dosage be explained?
Can a hotel cancel a confirmed reservation?
Sometimes a banana is just a banana
Is Draco canonically good-looking?
Why do neural networks need so many training examples to perform?
How to mitigate "bandwagon attacking" from players?
Inventor that creates machine that grabs man from future
Where was Karl Mordo in Infinity War?
Is it a fallacy if someone claims they need an explanation for every word of your argument to the point where they don't understand common terms?
Called into a meeting and told we are being made redundant (laid off) and "not to share outside". Can I tell my partner?
Why does the DC-9-80 have this cusp in its fuselage?
Finding ratio of the area of triangles
Does Windows 10's telemetry include sending *.doc files if Word crashed?
Yeshiva University RIETS Semicha Yorei and Yadin
Could quantum mechanics be necessary to analyze some biology scenarios?
Obtaining a matrix of complex values from associations giving the real and imaginary parts of each element?
When does coming up with an idea constitute sufficient contribution for authorship?
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.
15 hours ago
@TorbjørnT. Indeed, that works. Thanks! (To be clear, it can then be referred to as(foo)
later on.)
– Harald Hanche-Olsen
15 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 17 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.
15 hours ago
@TorbjørnT. Indeed, that works. Thanks! (To be clear, it can then be referred to as(foo)
later on.)
– Harald Hanche-Olsen
15 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.
15 hours ago
@TorbjørnT. Indeed, that works. Thanks! (To be clear, it can then be referred to as(foo)
later on.)
– Harald Hanche-Olsen
15 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.
15 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.
15 hours ago
@TorbjørnT. Indeed, that works. Thanks! (To be clear, it can then be referred to as
(foo)
later on.)– Harald Hanche-Olsen
15 hours ago
@TorbjørnT. Indeed, that works. Thanks! (To be clear, it can then be referred to as
(foo)
later on.)– Harald Hanche-Olsen
15 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
12 hours ago
@HaraldHanche-Olsen You haven't "messed up" I think.;-)
– marmot
12 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
12 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
12 hours ago
@HaraldHanche-Olsen You haven't "messed up" I think.;-)
– marmot
12 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
12 hours ago
@HaraldHanche-Olsen You haven't "messed up" I think.;-)
– marmot
12 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 14 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
12 hours ago
@HaraldHanche-Olsen You haven't "messed up" I think.;-)
– marmot
12 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
12 hours ago
@HaraldHanche-Olsen You haven't "messed up" I think.;-)
– marmot
12 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
12 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
12 hours ago
@HaraldHanche-Olsen You haven't "messed up" I think.;-)
– marmot
12 hours ago
@HaraldHanche-Olsen You haven't "messed up" I think.;-)
– marmot
12 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
12 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
12 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 12 hours ago
Harald Hanche-OlsenHarald Hanche-Olsen
13.1k24762
13.1k24762
I knew you would go fortikzmath
;-)
– marmot
12 hours ago
add a comment |
I knew you would go fortikzmath
;-)
– marmot
12 hours ago
I knew you would go for
tikzmath
;-)– marmot
12 hours ago
I knew you would go for
tikzmath
;-)– marmot
12 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.
15 hours ago
@TorbjørnT. Indeed, that works. Thanks! (To be clear, it can then be referred to as
(foo)
later on.)– Harald Hanche-Olsen
15 hours ago