Graphics, Figures & Tables ⇒ intersection
intersection
I have 4 intersections in this case, and want to draw and fill that number of circles. Question: Why does not my code do want I want it to do ?
See the attached .tex file.
Kent Holing
See the attached .tex file.
Kent Holing
- Attachments
-
- intersections.tex
- (758 Bytes) Downloaded 535 times
NEW: TikZ book now 40% off at Amazon.com for a short time.

- Stefan Kottwitz
- Site Admin
- Posts: 10347
- Joined: Mon Mar 10, 2008 9:44 pm
intersection
Hi Kent,
I don't have
Without that, commenting it out, I get errors:
Stefan
I don't have
mypgfmacrolibrary.tex
to test. Can you attach it, if it is relevant?Without that, commenting it out, I get errors:
Code: Select all
! Undefined control sequence.
\UseTextAccent ...up \@firstofone \let \@curr@enc
\cf@encoding \@use@text@en...
l.21 }
LaTeX.org admin
intersection
You do not need the library. I did run the input file without it.
It seems to be a problem with the \foreach loop.
It seems to be a problem with the \foreach loop.
- Stefan Kottwitz
- Site Admin
- Posts: 10347
- Joined: Mon Mar 10, 2008 9:44 pm
intersection
Ok, since you did not mention the error but said that the code just doesn't do what you want it to do, I assumed the error is another thing that just with creating this example, and thought it's about doing something.
The
Stefn
The
total=\t
variable is only locally defined in the current path, that's why the \t
in your \foreach
loop is a predefined LaTeX macro. This way you can make it globally available:Code: Select all
\draw [execute at begin node={\global\let\t=\t},
name intersections = {of = c1 and c2,total=\t}] ...
LaTeX.org admin
- Stefan Kottwitz
- Site Admin
- Posts: 10347
- Joined: Mon Mar 10, 2008 9:44 pm
intersection
Here is the modified code to get four filled circles at the intersection points:
Stefan
Code: Select all
\documentclass[margin=10pt]{standalone}
\usepackage{tikz}
%\input{mypgfmacrolibrary}
\usetikzlibrary{intersections}
\begin{document}
\begin{tikzpicture}
\coordinate (O) at (0,0);
\coordinate (A) at (2.0,2.0);
\draw [name path = c1, red, thick] (A) circle [radius = 4cm];
\draw [name path = c2, green, thin] (A) ellipse (5.0cm and 2.0cm);
\draw [execute at begin node={\global\let\t=\t},
name intersections = {of = c1 and c2,total=\t}]
(intersection-1) -- (intersection-2) -- (intersection-3)
-- (intersection-4) -- cycle;
\pgfmathsetmacro{\nr}{0}
\foreach \point in {1,...,\t}
\filldraw[red] (intersection-\point) circle (0.5cm);
\end{tikzpicture}
\end{document}
LaTeX.org admin
intersection
Thanks pointing this out.
This answers one part of my earlier posting on intersections on apparently differences between PGF 2.0 and PGF 3.0.
Kent
This answers one part of my earlier posting on intersections on apparently differences between PGF 2.0 and PGF 3.0.
Kent
intersection
One additional question regarding the global value \t:
If we have a case with no intersections, it seems to me, based on testing, that \t is not defined.
It should really be defined to be 0 in such cases.
How can this be fixed?
Best regards,
Kent
If we have a case with no intersections, it seems to me, based on testing, that \t is not defined.
It should really be defined to be 0 in such cases.
How can this be fixed?
Best regards,
Kent
- Stefan Kottwitz
- Site Admin
- Posts: 10347
- Joined: Mon Mar 10, 2008 9:44 pm
intersection
Can you post your test case? I just don't have time now to construct another case. Also I expect
Stefan
\t
to be 0 then, and we could work with \ifnum \t>0 ... \fi
.Stefan
LaTeX.org admin
intersection
See the attached .tex file where you find one example where the two paths intersect and the code works
and one example where the two paths do not intersect and the code does not work.
Kent
and one example where the two paths do not intersect and the code does not work.
Kent
- Attachments
-
- latexforumposting.tex
- (1.99 KiB) Downloaded 504 times
intersection
I modified the example on page 982 in the PGF 3.0 manual to let the square be completely inside the ellipse
such that the number of intersection points should be 0. (See the attached file.)
As described in the manual, the origion is indeed highlighted.
In such case, I would prefer to not highlight any point. How can I achieve this? This posting is a direct follow-up
from the above.
Kent
such that the number of intersection points should be 0. (See the attached file.)
As described in the manual, the origion is indeed highlighted.
In such case, I would prefer to not highlight any point. How can I achieve this? This posting is a direct follow-up
from the above.
Kent
- Attachments
-
- intersections4.tex
- (726 Bytes) Downloaded 472 times