2

I am trying to make the "convexhull" code from this question to work for both pgf/tikz 3.0 and older versions work (the definition of atan changed from version 2.9 to 3.0). However, so far I have failed to do so.

In the preamble I defined

\newboolean{curr_tikzv}    
\makeatletter
\@ifpackagelater{tikz}{2013/12/01}
 { \setboolean{curr_tikzv}{true}}
 { \setboolean{curr_tikzv}{false}
}
\makeatother

and I replaced the critical definitions of \n1 and \n2 by

    \n1 = {\ifthenelse{\boolean{curr_tikzv}}{atan2(\y1,\x1) + 90}{atan2(\x1,\y1) + 90}},

and the corresp. change for \n2. Yet this produces an error, claiming there are unmatched "}".

What am I doing wrong? The first error message I get is

! Argument of \XC@definec@lor has an extra }.
john_leo
  • 133

1 Answers1

3

\ifthenelse is not expandable and is not supported in the setting argument for \n1. A simple \if switch should work:

\newif\ifCurrTikzV
\makeatletter
\@ifpackagelater{tikz}{2013/12/01}{\CurrTikzVtrue}{\CurrTikzVfalse}
\makeatother

\n1 = {\ifCurrTikzV atan2(\y1,\x1) + 90\else atan2(\x1,\y1) + 90\fi},

Instead of \ifCurrTikzV for each atan2, a macro could be defined:

\makeatletter
\@ifpackagelater{tikz}{2013/12/01}{%
  \def\AtanTwo(#1,#2){atan2({#1},{#2})}%
}{%
  \def\AtanTwo(#1,#2){atan2({#2},{#1})}%
}
\makeatother

\n1 = {\AtanTwo(\y1,\x1) + 90},
Heiko Oberdiek
  • 271,626