Graphics, Figures & Tables ⇒ intersection
intersection
See the attached .tex file.
Kent Holing
- Attachments
-
- intersections.tex
- (758 Bytes) Downloaded 532 times
NEW: TikZ book now 40% off at Amazon.com for a short time.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p
- Stefan Kottwitz
- Site Admin
- Posts: 10328
- Joined: Mon Mar 10, 2008 9:44 pm
intersection
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 }
intersection
It seems to be a problem with the \foreach loop.
- Stefan Kottwitz
- Site Admin
- Posts: 10328
- Joined: Mon Mar 10, 2008 9:44 pm
intersection
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}] ...
- Stefan Kottwitz
- Site Admin
- Posts: 10328
- Joined: Mon Mar 10, 2008 9:44 pm
intersection
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}
intersection
This answers one part of my earlier posting on intersections on apparently differences between PGF 2.0 and PGF 3.0.
Kent
intersection
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: 10328
- Joined: Mon Mar 10, 2008 9:44 pm
intersection
\t
to be 0 then, and we could work with \ifnum \t>0 ... \fi
.Stefan
intersection
and one example where the two paths do not intersect and the code does not work.
Kent
- Attachments
-
- latexforumposting.tex
- (1.99 KiB) Downloaded 501 times
intersection
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 468 times