3

I am trying to draw lines around a number of nodes. I very much like the definition of \convexpath definition given here, but it is not working well on my setup (MacTex 2014 with all available updates).

I tried to compile Claudio Fiandrino's first solution, but what I get is the following, which is clearly not what I should be getting. Any ideas would be much appreciated.

enter image description here

ozsu
  • 2,385
  • 2
    Can you try swapping the arguments to the PGFmath atan2 function? atan2(\x1,\y1) becomes atan2(\y1, \x1) and so on. – Qrrbrbirlbel May 12 '15 at 17:17
  • Wow, that did it. Thanks very much for this. If you enter it as an answer, I'll vote for it and mark this closed. – ozsu May 12 '15 at 17:27
  • What are tax nodes? Something to do with the IRS? – cfr May 23 '16 at 23:22

1 Answers1

5

When TikZ/PGF updated to version 3.0.0, the parameters of the PGFmath function atan2 where swapped. Up to version 2.10 it was

atan2(x, y)

It now is

atan2(y, x)

Think what you may of this change, however, it breaks backward compatibility, as you need to swap arguments in the linked code as well.


For my own libraries and purposes I created two substitute functions atanXY and atanYX

\csname pgfmathatan2@\endcsname{0}{1}
\ifdim\pgfmathresult pt=0pt % atan2(y, x)
  \pgfmathdeclarefunction{atanXY}{2}{\csname pgfmathatan2@\endcsname{#2}{#1}}
  \pgfmathdeclarefunction{atanYX}{2}{\csname pgfmathatan2@\endcsname{#1}{#2}}
\else                       % atan2(x, y)
  \pgfmathdeclarefunction{atanXY}{2}{\csname pgfmathatan2@\endcsname{#1}{#2}}
  \pgfmathdeclarefunction{atanYX}{2}{\csname pgfmathatan2@\endcsname{#2}{#1}}
\fi

which was even more important when switching between the 2.10 and the CVS version.

Nowadays

  \pgfmathdeclarefunction{atanXY}{2}{\pgfmathatantwo@{#2}{#1}}
  \pgfmathdeclarefunction{atanYX}{2}{\pgfmathatantwo@{#1}{#2}}

should be enough.

This also allows it again to use atanXY(\p{<name>}) after one has used calc’s

let \p{<name>}=(<coordinates>) … in

path operator.
The \p{<name>} macro just expands to \x{<name>},\y{<name>} which is usually used inside TikZ coordinate specifications.

Qrrbrbirlbel
  • 119,821