# use of pgf intersections package for paths

I have a question regarding the use of the intersections package in PGF 3.0 for paths:

For my case, it works fine if the number of intersections are >=1, but not when there is no intersection. Then the algorithm marks the origon as an intersection.

See example on page 982 in the PGF 3.0.1a manual. (If you put the rectangle completely inside the ellipse, you get a no intersection case and the code marks the origin.)

How can I by code catch the non-intersecting case to avoid this?

My macro

\def\mgthenumberofpathintersections{
\path [name path=ccp1cc]\myfirstpath;
\path [name path=ccp2cc]\mysecondpath;
\path [execute at begin node={\global\let\t=\t},
name intersections = {of = ccp1cc and ccp2cc,total=\t}];
}


gives the correct value (i.e. number of intersections between the two paths) when they intersect as stored in \t, but it seems that \t is not defined when there is no intersection. How can automatically I identify the case with no intersection?

Kent Holing, NORWAY

That \global\let won't do anything since there is no node defined in a draw path. It is already defined in the current scope so you can remove that completely.

You can check for also the existence of the intersection point if there is one or more. Suppose I also used name=myint key in the name intersection options:

\csname pgfutil@ifundefined\endcsname{pgf@sh@ns@myint-1}{True statement}{False statement}


You can also check for existence of \t but I haven't tested if it is already defined or not.

Here is one application : Draw arrows ending at half circle

• @KentHoling My pleasure – percusse Jan 12 '18 at 15:14
• To follow, up, how can I deactivate myint-1 after it has been activated? – Kent Holing Jan 28 '18 at 12:30