7

I was trying out the venndiagram package in order to answer another question. Having drawn the diagram for that answer, I thought I'd try a slightly more complex example:

\documentclass[tikz,border=20pt,multi]{standalone}
\usepackage{venndiagram}
\begin{document}
\begin{venndiagram3sets}
  \fillOnlyA
\end{venndiagram3sets}
\end{document}

But this did not yield the expected results:

unexpected results

The diagram should shade just that part of set A which intersects with neither B nor C, as I understand it.

As far as I can tell, this example is just example 3 on pages 6/7 of the documentation. The issue is not caused by the use of standalone - I get the same results with article, except on a bigger page, obviously.

Have I missed something crucial or might this be a bug? I'm wondering if there's a compatibility issue with current versions of TikZ.

1
  • 3
    Same wrong result here; things go even worst with \fillOnlyC! Aug 19, 2015 at 3:47

2 Answers 2

8

In venndiagram.sty on lines 138, 140, 147, 159, 151, 153, the arguments of atan2 are in the wrong order. When I reverse them, one gets the desired results. What I mean is that the original arguments to atan2 were entered as (dx,dy), but they should be entered as (dy,dx).

Corrected passage: (lines 128-164)

  \def\fillOnlyA{%
    \begin{scope}
    \path[name path=A] (\@venn@Ax,\@venn@Ay) circle (\@venn@radius);
    \path[name path=BC] (\@venn@Bx,\@venn@By) circle (\@venn@radius)
      (\@venn@Cx,\@venn@Cy) circle (\@venn@radius);
    \path[name intersections={of=A and BC,name=ABintersect}]
      (ABintersect-1) ;
    \pgfgetlastxy{\@venn@AB@xi}{\@venn@AB@yi}
    \path (ABintersect-2);
    \pgfgetlastxy{\@venn@AB@xii}{\@venn@AB@yii}
    \pgfmathparse{atan2(\@venn@AB@yi-\@venn@Ay,\@venn@AB@xi-\@venn@Ax)}
    \let\@venn@start@i=\pgfmathresult
    \pgfmathparse{360+atan2(\@venn@AB@yii-\@venn@Ay,\@venn@AB@xii-\@venn@Ax)}
    \let\@venn@end@i=\pgfmathresult
    \path[name path=B] (\@venn@Bx,\@venn@By) circle (\@venn@radius);
    \path[name path=C] (\@venn@Cx,\@venn@Cy) circle (\@venn@radius);
    \path[name intersections={of=B and C,name=BCintersect}]
      (BCintersect-1);
    \pgfgetlastxy{\@venn@BC@x}{\@venn@BC@y}
    \pgfmathparse{atan2(\@venn@AB@yii-\@venn@Cy,\@venn@AB@xii-\@venn@Cx )}
    \let\@venn@start@ii=\pgfmathresult
    \pgfmathparse{atan2(\@venn@BC@y-\@venn@Cy,\@venn@BC@x-\@venn@Cx )}
    \let\@venn@end@ii=\pgfmathresult
    \pgfmathparse{atan2(\@venn@BC@y-\@venn@By,\@venn@BC@x-\@venn@Bx )}
    \let\@venn@start@iii=\pgfmathresult
    \pgfmathparse{atan2(\@venn@AB@yi-\@venn@By,\@venn@AB@xi-\@venn@Bx )-360}
    \let\@venn@end@iii=\pgfmathresult
    \path[fill=\@venn@shade] (ABintersect-1)
     arc[radius=\@venn@radius,
         start angle=\@venn@start@i,end angle=\@venn@end@i]
     arc[radius=\@venn@radius,
         start angle=\@venn@start@ii,end angle=\@venn@end@ii]
     arc[radius=\@venn@radius,
         start angle=\@venn@start@iii,end angle=\@venn@end@iii]
     -- cycle;
    \end{scope}
  }%

enter image description here

6
  • 4
    TikZ v3 came with this modification that atan2 reversed the order of arguments.
    – percusse
    Aug 19, 2015 at 5:22
  • 1
    That'll break a few things, wow.
    – JPi
    Aug 19, 2015 at 11:51
  • I've alerted the package author.
    – JPi
    Aug 19, 2015 at 12:58
  • 1
    It broke already including hobby and a few others. This stayed in the dark until now apparently
    – percusse
    Aug 19, 2015 at 13:52
  • 1
    @JPi Thanks for diagnosing and for alerting the author. (+1 for now.)
    – cfr
    Aug 19, 2015 at 22:24
6

This is now fixed in venndiagram v1.1 which checks \pgfversion to determine what syntax to use for atan2, so venndiagram should now work with both pgf v2.0 and pgf v3.0.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .