summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/venndiagram/venndiagram.dtx
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2016-03-17 21:34:36 +0000
committerKarl Berry <karl@freefriends.org>2016-03-17 21:34:36 +0000
commitc3e45a18cd1d6e3912efb68c36588ff0c86ce75f (patch)
tree597c5217c463082d37015ab7aae1db6aa96e8b65 /Master/texmf-dist/source/latex/venndiagram/venndiagram.dtx
parent8f657991c60e3567495c2403a20d67d9f2d0224a (diff)
venndiagram (17mar16)
git-svn-id: svn://tug.org/texlive/trunk@40058 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/venndiagram/venndiagram.dtx')
-rw-r--r--Master/texmf-dist/source/latex/venndiagram/venndiagram.dtx1486
1 files changed, 1176 insertions, 310 deletions
diff --git a/Master/texmf-dist/source/latex/venndiagram/venndiagram.dtx b/Master/texmf-dist/source/latex/venndiagram/venndiagram.dtx
index 1171abf5542..8ca85092e80 100644
--- a/Master/texmf-dist/source/latex/venndiagram/venndiagram.dtx
+++ b/Master/texmf-dist/source/latex/venndiagram/venndiagram.dtx
@@ -1,11 +1,11 @@
%\iffalse
-% venndiagram.dtx generated using makedtx version 0.94b (c) Nicola Talbot
+% venndiagram.dtx generated using makedtx version 1.1 (c) Nicola Talbot
% Command line args:
+% -author "Nicola Talbot"
% -src "venndiagram.sty\Z=>venndiagram.sty"
% -doc "venndiagram-manual.tex"
-% -author "Nicola Talbot"
% venndiagram
-% Created on 2012/10/24 12:21
+% Created on 2016/3/16 22:06
%\fi
%\iffalse
%<*package>
@@ -28,12 +28,13 @@
%\fi
% \iffalse
% Doc-Source file to use with LaTeX2e
-% Copyright (C) 2012 Nicola Talbot, all rights reserved.
+% Copyright (C) 2016 Nicola Talbot, all rights reserved.
% \fi
% \iffalse
%<*driver>
-\documentclass{nlctdoc}
+\documentclass[widecs]{nlctdoc}
+\usepackage{amsmath}
\usepackage{venndiagram}
\usepackage{alltt}
\usepackage[utf8]{inputenc}
@@ -45,9 +46,13 @@
pdftitle={venndiagram.sty: LaTeX2e Package for Drawing Venn Diagrams},
pdfkeywords={LaTeX,package,venn diagram}]{hyperref}
+\DisableCrossrefs
+
+\setlength\marginparwidth{6pc}
+
\doxitem{KeyValOption}{keyvaloption}{options}
-\CheckSum{1237}
+\CheckSum{2598}
\begin{document}
\DocInput{venndiagram.dtx}
@@ -57,16 +62,24 @@
%
%\MakeShortVerb{"}
%
-%\title{venndiagram v1.0:
+%\title{venndiagram v1.1:
%Drawing Simple Venn Diagrams}
%\author{Nicola L. C. Talbot\\\url{http://www.dickimaw-books.com/}}
%
-%\date{2012-10-24}
+%\date{2016-03-16}
%\maketitle
%
%The \styfmt{venndiagram} package is provided to assist generating
%simple two- and three-set Venn diagrams for lectures or assignment
%sheets. This package requires the \sty{tikz} package.
+%As from v1.1, this package no longer requires the
+%\styfmt{intersections} library.
+%
+%\begin{important}
+%The aim of this package is to provide very simple Venn diagrams for
+%assignments or exam questions. If you require more complex diagrams
+%or different layouts it's simpler to directly use the \sty{tikz} package.
+%\end{important}
%
%\tableofcontents
%
@@ -76,12 +89,14 @@
%\begin{definition}[\DescribeEnv{venndiagram3sets}]
%\cs{begin}\{venndiagram3sets\}\oarg{options}
%\end{definition}
-%and
+%(for two sets) and
%\begin{definition}[\DescribeEnv{venndiagram2sets}]
%\cs{begin}\{venndiagram2sets\}\oarg{options}
%\end{definition}
+%(for three sets).
+%
%The optional argument \meta{options} is a comma-separated list of
-%key=value settings.
+%\meta{key}=\meta{value} settings.
%
%\begin{important}
%If the \meta{value} contains commas or equal
@@ -412,7 +427,7 @@
%
%\end{enumerate}
%
-%\StopEventually{\phantomsection\addcontentsline{toc}{section}{\indexname}\PrintIndex}
+%\StopEventually{\PrintIndex}
%
%
%\section{The Code}
@@ -424,7 +439,7 @@
% Package identification:
% \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{venndiagram}[2012/10/24 v1.0 (NLCT) Venn diagrams]
+\ProvidesPackage{venndiagram}[2016/03/16 v1.1 (NLCT) Venn diagrams]
% \end{macrocode}
% Required packages:
% \begin{macrocode}
@@ -432,9 +447,32 @@
\RequirePackage{tikz}
\RequirePackage{etoolbox}
% \end{macrocode}
-% TiKZ intersections library needed:
+% TiKZ intersections library no longer needed. (Removed in v1.1)
+%\changes{1.1}{2016-03-16}{removed intersections library}
+%
+% The \sty{pgf} package reversed the order of arguments of
+% \texttt{atan2} in v3.0, which messes things up a bit.
+% In the event that there are users with older versions of
+% \sty{pgf}, backward-compatibility is required. Add a switch to
+% determine which syntax to use.
+%\begin{macro}{\ifvennoldpgf}
+%\changes{1.1}{2016-03-16}{new}
+% If true use old syntax.
+% \begin{macrocode}
+\newif\ifvennoldpgf
+% \end{macrocode}
+%\end{macro}
+% Try to determine this setting.
% \begin{macrocode}
-\usetikzlibrary{intersections}
+\ifdef\pgfversion
+{
+ \def\@venn@checkversion#1.#2\@venn@end@checkversion{%
+ \ifnum#1<3 \vennoldpgftrue \else \vennoldpgffalse\fi}
+ \expandafter\@venn@checkversion\pgfversion.0\@venn@end@checkversion
+}
+{
+ \vennoldpgftrue
+}
% \end{macrocode}
%
%\subsection{Initialising the Default Values}
@@ -750,8 +788,295 @@
% \end{macrocode}
%\end{keyvaloption}
%
+%\subsection{Circle Intersection}
+% Previously commands like \cs{fillOnlyA} used \sty{pgf} path operations
+% to compute the intersection points of the circles, but the code
+% didn't work properly when the co-ordinate system has been scaled.
+% Version 1.1 changes this to calculate the co-ordinates in a more
+% low-level way. We have two circles centred on $(a_x, a_y)$ and
+% $(b_x, b_y)$ both with radius $r$. This gives the equations:
+%\begin{align}
+%(x-a_x)^2+(y-a_y)^2 &= r^2\label{eq:A}\\
+%(x-b_x)^2+(y-b_y)^2 &= r^2
+%\end{align}
+%Combining:
+%\begin{equation}
+%(x-a_x)^2-(x-b_x)^2+(y-a_y)^2-(y-b_y)^2 = 0\label{eq:chord}
+%\end{equation}
+%Re-arranging gives the equation of the chord between the two points
+%of intersection:
+%\[
+%x(b_x-a_x)+y(b_y-a_y) = \frac{b_x^2-a_x^2+b_y^2-a_y^2}{2}
+%\]
+%Special cases:
+%\begin{enumerate}
+%\item $b_x=a_x$ (circles vertically stacked):
+%\[y(b_y-a_y) = \frac{b_y^2-a_y^2}{2}\]
+%Rearranging gives $y=\frac{1}{2}(b_y+a_y)$. Substituting into
+%\eqref{eq:A}:
+%\begin{align*}
+%(x-a_x)^2+\left(\frac{1}{2}(b_y+a_y)-a_y\right)^2 &= r^2\\
+%(x-a_x)^2+\frac{1}{4}(b_y-a_y)^2 &= r^2\\
+%x^2 - 2x a_x + a_x^2+\frac{(b_y-a_y)^2}{4} -r^2 &=0
+%\end{align*}
+%This is a quadratic equation in $x$ with solutions given by
+%\begin{align*}
+%x &= a_x\pm\sqrt{a_x^2-\left(a_x^2+\frac{(b_y-a_y)^2}{4}-r^2\right)}\\
+%&= a_x\pm\sqrt{r^2-\frac{1}{4}(b_y-a_y)^2}
+%\end{align*}
+%If $r^2 < \frac{1}{4}(b_y-a_y)^2$ then no solution exists (circles
+%don't overlap). If $r^2 = \frac{1}{4}(b_y-a_y)^2$ then there's only
+%one point of intersection.
+%\item $b_y=a_y$ (circles horizontally aligned):
+%\[x(b_x-a_x) = \frac{b_x^2-a_x^2}{2} \]
+%Rearranging gives $x=\frac{1}{2}(b_x+a_x)$. Substituting into
+%\eqref{eq:A}:
+%\begin{align*}
+%\left(\frac{b_x+a_x}{2}-a_x\right)^2+(y-a_y)^2 &= r^2\\
+%\frac{1}{4}(b_x-a_x)^2+(y-a_y)^2 &= r^2\\
+%y^2 - 2ya_y+a_y^2+\frac{1}{4}(b_x-a_x)^2-r^2 &= 0
+%\end{align*}
+%This is a quadratic equation in $y$ with solutions given by
+%\begin{align*}
+%y &= a_y\pm\sqrt{a_y^2-\left(a_y^2+\frac{(b_x-a_x)^2}{4}-r^2\right)}\\
+%&= a_y\pm\sqrt{r^2-\frac{1}{4}(b_x-a_x)^2}
+%\end{align*}
+%If $r^2 < \frac{1}{4}(b_x-a_x)^2$ then no solution exists (circles
+%don't overlap). If $r^2 = \frac{1}{4}(b_x-a_x)^2$ then there's only
+%one point of intersection.
+%\end{enumerate}
+%The general case has the chord given by equation~\eqref{eq:chord},
+%which can be rewritten in the form $y = mx + c$ where
+%\begin{align*}
+% m &= \frac{a_x-b_x}{b_y-a_y}\\
+% c &= \frac{b_x^2-a_x^2+b_y^2-a_y^2}{2(b_y-a_y)}
+%\end{align*}
+%Substituting into equation~\eqref{eq:A}:
+%\[
+%(x-a_x)^2+((mx+c)-a_y)^2 = r^2
+%\]
+%Rearranging:
+%\begin{displaymath}
+%(1+m^2)x^2+2x(mc-a_x-a_ym)+a_x^2+c^2-2a_yc+a_y^2-r^2 = 0
+%\end{displaymath}
+%This is a quadratic solution in $x$ with solutions given by
+%\[
+%x = \frac{-(mc-a_x-a_ym)\pm
+%\sqrt{(mc-a_x-a_ym)^2-(1+m^2)(a_x^2+c^2-2a_yc+a_y^2-r^2)}}{1+m^2}
+%\]
+%
+%Provide command to compute the intersection of two circles of the
+%same radius (given by \cs{@venn@radius}.
+%\begin{macro}{\@venn@computecircleintersects}
+%The four arguments are $a_x$, $a_y$, $b_x$ and $b_y$ (the centre
+%co-ordinates in lengths). The results are stored in \cs{@venn@intersect@i@x},
+% \cs{@venn@intersect@i@y}, \cs{@venn@intersect@ii@x} and
+% \cs{@venn@intersect@ii@y}. The number of intersects (0, 1 or 2)
+% is stored in \cs{@venn@intersect@n}.
+% \begin{macrocode}
+\newcommand*{\@venn@computecircleintersects}[4]{%
+ \ifdim#1=#3\relax
+% \end{macrocode}
+% Case 1 ($a_x = b_x$). Compute $y = \frac{1}{2}(b_y+a_y)$.
+% \begin{macrocode}
+ \pgfmathsetlength{\@venn@intersect@i@y}{0.5*(#4+#2)}%
+ \setlength{\@venn@intersect@ii@y}{\@venn@intersect@i@y}%
+% \end{macrocode}
+% Compute $r^2 - \frac{1}{4}(b_y-a_y)^2$
+% \begin{macrocode}
+ \pgfmathsetlength{\dimen@i}{#4-#2}%
+ \pgfmathsetlength{\dimen@}{\@venn@radius*\@venn@radius-0.25*\dimen@i*\dimen@i}%
+ \setlength{\@venn@intersect@i@x}{#1}%
+ \setlength{\@venn@intersect@ii@x}{#1}%
+ \ifdim\dimen@=0pt\relax
+% \end{macrocode}
+% One point of intersection.
+% \begin{macrocode}
+ \def\@venn@intersect@n{1}%
+ \else
+ \ifdim\dimen@>0pt\relax
+% \end{macrocode}
+% Two points of intersection.
+% \begin{macrocode}
+ \def\@venn@intersect@n{2}%
+ \pgfmathsetlength{\dimen@i}{sqrt(\dimen@)}%
+ \addtolength{\@venn@intersect@i@x}{\dimen@i}%
+ \addtolength{\@venn@intersect@ii@x}{-\dimen@i}%
+ \else
+% \end{macrocode}
+% No intersection.
+% \begin{macrocode}
+ \def\@venn@intersect@n{0}%
+ \fi
+ \fi
+ \else
+ \ifdim#2=#4\relax
+% \end{macrocode}
+% Case 2 ($a_y = b_y$). Compute $x = \frac{1}{2}(b_x+a_x)$
+% \begin{macrocode}
+ \pgfmathsetlength{\@venn@intersect@i@x}{0.5*(#3+#1)}%
+ \setlength{\@venn@intersect@ii@x}{\@venn@intersect@i@x}%
+% \end{macrocode}
+% Compute $r^2 - \frac{1}{4}(b_x-a_x)^2$
+% \begin{macrocode}
+ \setlength{\dimen@i}{#3}%
+ \addtolength{\dimen@i}{-#1}%
+ \pgfmathsetlength{\dimen@}{\@venn@radius*\@venn@radius
+ -0.25*\dimen@i*\dimen@i}%
+ \setlength{\@venn@intersect@i@y}{#2}%
+ \setlength{\@venn@intersect@ii@y}{#2}%
+ \ifdim\dimen@=0pt\relax
+% \end{macrocode}
+% One point of intersection.
+% \begin{macrocode}
+ \def\@venn@intersect@n{1}%
+ \else
+ \ifdim\dimen@>0pt\relax
+% \end{macrocode}
+% Two points of intersection.
+% \begin{macrocode}
+ \def\@venn@intersect@n{2}%
+ \pgfmathsetlength{\dimen@i}{sqrt(\dimen@)}%
+ \addtolength{\@venn@intersect@i@y}{\dimen@i}%
+ \addtolength{\@venn@intersect@ii@y}{-\dimen@i}%
+ \else
+% \end{macrocode}
+% No intersection.
+% \begin{macrocode}
+ \def\@venn@intersect@n{0}%
+ \fi
+ \fi
+ \else
+% \end{macrocode}
+% General case. Convert all lengths to scalar to reduce chances of
+% exceeding max dimension. Using inches to ensure more reasonable
+% values.
+% \begin{macrocode}
+ \pgfmathparse{#1/72.27}\let\@vnn@ax\pgfmathresult
+ \pgfmathparse{#2/72.27}\let\@vnn@ay\pgfmathresult
+ \pgfmathparse{#3/72.27}\let\@vnn@bx\pgfmathresult
+ \pgfmathparse{#4/72.27}\let\@vnn@by\pgfmathresult
+ \pgfmathparse{\@venn@radius/72.27}\let\@vnn@r\pgfmathresult
+ \pgfmathparse{\@vnn@ax*\@vnn@ax}\let\@vnn@ax@sq\pgfmathresult
+ \pgfmathparse{\@vnn@ay*\@vnn@ay}\let\@vnn@ay@sq\pgfmathresult
+ \pgfmathparse{\@vnn@bx*\@vnn@bx}\let\@vnn@bx@sq\pgfmathresult
+ \pgfmathparse{\@vnn@by*\@vnn@by}\let\@vnn@by@sq\pgfmathresult
+ \pgfmathparse{\@vnn@r*\@vnn@r}\let\@vnn@r@sq\pgfmathresult
+% \end{macrocode}
+% Set
+%\[c = \frac{b_x^2-a_x^2+b_y^2-a_y^2}{2(b_y-a_y)}\]
+% \begin{macrocode}
+ \pgfmathparse{0.5*(\@vnn@bx@sq-\@vnn@ax@sq+\@vnn@by@sq-\@vnn@ay@sq)
+ /(\@vnn@by-\@vnn@ay)}%
+ \let\@vnn@c\pgfmathresult
+% \end{macrocode}
+% Set
+%\[m = \frac{a_x-b_x}{b_y-a_y}\]
+% \begin{macrocode}
+ \pgfmathparse{(\@vnn@ax-\@vnn@bx)/(\@vnn@by-\@vnn@ay)}%
+ \let\@vnn@m\pgfmathresult
+% \end{macrocode}
+% Compute $(1+m^2)$.
+% \begin{macrocode}
+ \pgfmathparse{1+\@vnn@m*\@vnn@m}%
+ \let\@vnn@one@plus@m@sq\pgfmathresult
+% \end{macrocode}
+% Compute \[mc-a_x-a_ym = m(c-a_y)-a_x\]
+% \begin{macrocode}
+ \pgfmathparse{\@vnn@m*(\@vnn@c-\@vnn@ay)-\@vnn@ax}%
+ \let\@vnn@b\pgfmathresult
+% \end{macrocode}
+% Denote this value $b$ and now compute
+% \[b^2-(1+m^2)(a_x^2+a_y^2+c^2-2a_yc-r^2)\]
+% \begin{macrocode}
+ \pgfmathparse{\@vnn@b*\@vnn@b
+ - \@vnn@one@plus@m@sq
+ *(\@vnn@ax@sq+\@vnn@ay@sq+\@vnn@c*\@vnn@c
+ -2*\@vnn@ay*\@vnn@c-\@vnn@r@sq)}%
+ \let\@vnn@root\pgfmathresult
+ \setlength\dimen@{\pgfmathresult in}%
+ \ifdim\dimen@=0pt\relax
+% \end{macrocode}
+% One point of intersection.
+% \begin{macrocode}
+ \def\@venn@intersect@n{1}%
+% \end{macrocode}
+%\[x_1 = \frac{-b}{1+m^2}\]
+% \begin{macrocode}
+ \pgfmathparse{-\@vnn@b/\@vnn@one@plus@m@sq}%
+ \setlength{\@venn@intersect@i@x}{\pgfmathresult in}%
+ \setlength{\@venn@intersect@ii@x}{\@venn@intersect@i@x}%
+% \end{macrocode}
+%\[y_1 = mx_1 + c\]
+% \begin{macrocode}
+ \pgfmathparse{\pgfmathresult*\@vnn@m+c}%
+ \setlength{\@venn@intersect@i@y}{\pgfmathresult in}%
+ \setlength{\@venn@intersect@ii@y}{\@venn@intesect@i@y}%
+ \else
+ \ifdim\dimen@>0pt\relax
+% \end{macrocode}
+% Two points of intersection.
+% \begin{macrocode}
+ \def\@venn@intersect@n{2}%
+ \pgfmathsqrt{\@vnn@root}%
+ \let\@vnn@root\pgfmathresult
+% \end{macrocode}
+% First point.
+% \begin{macrocode}
+ \pgfmathparse{(-\@vnn@b+\@vnn@root)/\@vnn@one@plus@m@sq}%
+ \setlength{\@venn@intersect@i@x}{\pgfmathresult in}%
+ \pgfmathparse{\pgfmathresult*\@vnn@m+\@vnn@c}%
+ \setlength{\@venn@intersect@i@y}{\pgfmathresult in}%
+% \end{macrocode}
+% Second point.
+% \begin{macrocode}
+ \pgfmathparse{(-\@vnn@b-\@vnn@root)/\@vnn@one@plus@m@sq}%
+ \setlength{\@venn@intersect@ii@x}{\pgfmathresult in}%
+ \pgfmathparse{\pgfmathresult*\@vnn@m+\@vnn@c}%
+ \setlength{\@venn@intersect@ii@y}{\pgfmathresult in}%
+ \else
+% \end{macrocode}
+% No intersection.
+% \begin{macrocode}
+ \def\@venn@intersect@n{0}%
+ \fi
+ \fi
+ \fi
+ \fi
+}
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\@venn@intersect@i@x}
+%\changes{1.1}{2016-03-16}{new}
+% \begin{macrocode}
+\newlength\@venn@intersect@i@x
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\@venn@intersect@i@y}
+%\changes{1.1}{2016-03-16}{new}
+% \begin{macrocode}
+\newlength\@venn@intersect@i@y
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\@venn@intersect@ii@x}
+%\changes{1.1}{2016-03-16}{new}
+% \begin{macrocode}
+\newlength\@venn@intersect@ii@x
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\@venn@intersect@ii@y}
+%\changes{1.1}{2016-03-16}{new}
+% \begin{macrocode}
+\newlength\@venn@intersect@ii@y
+% \end{macrocode}
+%\end{macro}
+%
%\subsection{Environment Definitions}
-
+%
%\begin{environment}{venndiagram3sets}
% Environment to draw Venn diagram with three sets.
% \begin{macrocode}
@@ -830,223 +1155,21 @@
(0,0) rectangle (\@venn@w,\@venn@h)
(\@venn@Cx,\@venn@Cy) circle (\@venn@radius);}%
% \end{macrocode}
-% Fill only set $A$:
+% Fill only set $A$.
% \begin{macrocode}
- \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);
-% \end{macrocode}
-% Get intersection points of paths A and BC
-% \begin{macrocode}
- \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}
-% \end{macrocode}
-% Compute the start and end angles of arc between intersection
-% points
-% \begin{macrocode}
- \pgfmathparse{atan2(\@venn@AB@xi-\@venn@Ax,\@venn@AB@yi-\@venn@Ay)}
- \let\@venn@start@i=\pgfmathresult
- \pgfmathparse{360+atan2(\@venn@AB@xii-\@venn@Ax,\@venn@AB@yii-\@venn@Ay)}
- \let\@venn@end@i=\pgfmathresult
-% \end{macrocode}
-% Get intersection point of B and C
-% \begin{macrocode}
- \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}
-% \end{macrocode}
-% Compute start and end angles
-% \begin{macrocode}
- \pgfmathparse{atan2(\@venn@AB@xii-\@venn@Cx, \@venn@AB@yii-\@venn@Cy)}
- \let\@venn@start@ii=\pgfmathresult
- \pgfmathparse{atan2(\@venn@BC@x-\@venn@Cx, \@venn@BC@y-\@venn@Cy)}
- \let\@venn@end@ii=\pgfmathresult
- \pgfmathparse{atan2(\@venn@BC@x-\@venn@Bx, \@venn@BC@y-\@venn@By)}
- \let\@venn@start@iii=\pgfmathresult
- \pgfmathparse{atan2(\@venn@AB@xi-\@venn@Bx, \@venn@AB@yi-\@venn@By)-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}
- }%
+ \let\fillOnlyA\@venn@fillOnlyA@threesets
% \end{macrocode}
% Fill only set $B$:
% \begin{macrocode}
- \def\fillOnlyB{%
- \begin{scope}
- \path[name path=B] (\@venn@Bx,\@venn@By) circle (\@venn@radius);
- \path[name path=AC] (\@venn@Ax,\@venn@Ay) circle (\@venn@radius)
- (\@venn@Cx,\@venn@Cy) circle (\@venn@radius);
-% \end{macrocode}
-% Get intersection points of B and AC
-% \begin{macrocode}
- \path[name intersections={of=B and AC,name=BAintersect,sort by=B}]
- (BAintersect-1);
- \pgfgetlastxy{\@venn@BA@xi}{\@venn@BA@yi}
- \path (BAintersect-4);
- \pgfgetlastxy{\@venn@BA@xii}{\@venn@BA@yii}
-% \end{macrocode}
-% Compute the start and end angles of arc between intersection
-% points
-% \begin{macrocode}
- \pgfmathparse{atan2(\@venn@BA@xi-\@venn@Bx,\@venn@BA@yi-\@venn@By)}
- \let\@venn@start@i=\pgfmathresult
- \pgfmathparse{atan2(\@venn@BA@xii-\@venn@Bx,\@venn@BA@yii-\@venn@By)}
- \let\@venn@end@i=\pgfmathresult
-% \end{macrocode}
-% Get intersection point of A and C
-% \begin{macrocode}
- \path[name path=A] (\@venn@Ax,\@venn@Ay) circle (\@venn@radius);
- \path[name path=C] (\@venn@Cx,\@venn@Cy) circle (\@venn@radius);
- \path[name intersections={of=A and C,name=ACintersect}]
- (ACintersect-2);
- \pgfgetlastxy{\@venn@AC@x}{\@venn@AC@y}
-% \end{macrocode}
-% Compute start and end angles
-% \begin{macrocode}
- \pgfmathparse{atan2(\@venn@BA@xii-\@venn@Cx, \@venn@BA@yii-\@venn@Cy)}
- \let\@venn@start@ii=\pgfmathresult
- \pgfmathparse{atan2(\@venn@AC@x-\@venn@Cx, \@venn@AC@y-\@venn@Cy)}
- \let\@venn@end@ii=\pgfmathresult
- \pgfmathparse{atan2(\@venn@AC@x-\@venn@Ax, \@venn@AC@y-\@venn@Ay)}
- \let\@venn@start@iii=\pgfmathresult
- \pgfmathparse{atan2(\@venn@BA@xi-\@venn@Ax, \@venn@BA@yi-\@venn@Ay)}
- \let\@venn@end@iii=\pgfmathresult
- \path[fill=\@venn@shade] (BAintersect-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}
- }%
+ \let\fillOnlyB\@venn@fillOnlyB@threesets
% \end{macrocode}
% Fill only set $C$:
% \begin{macrocode}
- \def\fillOnlyC{%
- \begin{scope}
- \path[name path=C] (\@venn@Cx,\@venn@Cy) circle (\@venn@radius);
- \path[name path=BA] (\@venn@Bx,\@venn@By) circle (\@venn@radius)
- (\@venn@Ax,\@venn@Ay) circle (\@venn@radius);
-% \end{macrocode}
-% Get intersection points of C and BA
-% \begin{macrocode}
- \path[name intersections={of=C and BA,name=CBintersect,sort by=C}]
- (CBintersect-1);
- \pgfgetlastxy{\@venn@CB@xi}{\@venn@CB@yi}
- \path (CBintersect-4);
- \pgfgetlastxy{\@venn@CB@xii}{\@venn@CB@yii}
-% \end{macrocode}
-% Compute the start and end angles of arc between intersection
-% points
-% \begin{macrocode}
- \pgfmathparse{atan2(\@venn@CB@xi-\@venn@Cx,\@venn@CB@yi-\@venn@Cy)}
- \let\@venn@start@i=\pgfmathresult
- \pgfmathparse{atan2(\@venn@CB@xii-\@venn@Cx,\@venn@CB@yii-\@venn@Cy)-360}
- \let\@venn@end@i=\pgfmathresult
-% \end{macrocode}
-% Get intersection point of B and A
-% \begin{macrocode}
- \path[name path=B] (\@venn@Bx,\@venn@By) circle (\@venn@radius);
- \path[name path=A] (\@venn@Ax,\@venn@Ay) circle (\@venn@radius);
- \path[name intersections={of=B and A,name=BAintersect}]
- (BAintersect-2);
- \pgfgetlastxy{\@venn@BA@x}{\@venn@BA@y}
-% \end{macrocode}
-% Compute start and end angles
-% \begin{macrocode}
- \pgfmathparse{atan2(\@venn@CB@xii-\@venn@Ax, \@venn@CB@yii-\@venn@Ay)}
- \let\@venn@start@ii=\pgfmathresult
- \pgfmathparse{atan2(\@venn@BA@x-\@venn@Ax, \@venn@BA@y-\@venn@Ay)}
- \let\@venn@end@ii=\pgfmathresult
- \pgfmathparse{atan2(\@venn@BA@x-\@venn@Bx, \@venn@BA@y-\@venn@By)}
- \let\@venn@start@iii=\pgfmathresult
- \pgfmathparse{atan2(\@venn@CB@xi-\@venn@Bx, \@venn@CB@yi-\@venn@By)}
- \let\@venn@end@iii=\pgfmathresult
- \path[fill=\@venn@shade] (CBintersect-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}
- }%
+ \let\fillOnlyC\@venn@fillOnlyC@threesets
% \end{macrocode}
% Fill everything except $A$, $B$ or $C$.
% \begin{macrocode}
- \def\fillNotABC{%
- \begin{scope}
- \path[name path=A] (\@venn@Ax,\@venn@Ay) circle (\@venn@radius);
- \path[name path=B] (\@venn@Bx,\@venn@By) circle (\@venn@radius);
- \path[name path=C] (\@venn@Cx,\@venn@Cy) circle (\@venn@radius);
-% \end{macrocode}
-% Get first intersection point of A and B
-% \begin{macrocode}
- \path[name intersections={of=A and B,name=ABintersect}]
- (ABintersect-1);
- \pgfgetlastxy{\@venn@AB@x}{\@venn@AB@y}
-% \end{macrocode}
-% Get intersection point of A and C
-% \begin{macrocode}
- \path[name intersections={of=A and C,name=ACintersect}]
- (ACintersect-1);
- \pgfgetlastxy{\@venn@AC@x}{\@venn@AC@y}
-% \end{macrocode}
-% Get intersection point of C and B
-% \begin{macrocode}
- \path[name intersections={of=C and B,name=CBintersect}]
- (CBintersect-1);
- \pgfgetlastxy{\@venn@CB@x}{\@venn@CB@y}
-% \end{macrocode}
-% Compute start and end angles for first arc
-% \begin{macrocode}
- \pgfmathparse{atan2(\@venn@AB@x-\@venn@Ax, \@venn@AB@y-\@venn@Ay)}
- \let\@venn@start@i=\pgfmathresult
- \pgfmathparse{atan2(\@venn@AC@x-\@venn@Ax, \@venn@AC@y-\@venn@Ay)+360}
- \let\@venn@end@i=\pgfmathresult
-% \end{macrocode}
-% Compute start and end angles for second arc
-% \begin{macrocode}
- \pgfmathparse{atan2(\@venn@AC@x-\@venn@Cx,\@venn@AC@y-\@venn@Cy)}
- \let\@venn@start@ii=\pgfmathresult
- \pgfmathparse{atan2(\@venn@CB@x-\@venn@Cx,\@venn@CB@y-\@venn@Cy)+360}
- \let\@venn@end@ii=\pgfmathresult
-% \end{macrocode}
-% Compute start and end angles for third arc
-% \begin{macrocode}
- \pgfmathparse{atan2(\@venn@CB@x-\@venn@Bx,\@venn@CB@y-\@venn@By)}
- \let\@venn@start@iii=\pgfmathresult
- \pgfmathparse{atan2(\@venn@AB@x-\@venn@Bx,\@venn@AB@y-\@venn@By)}
- \let\@venn@end@iii=\pgfmathresult
- \path[fill=\@venn@shade]
- (0,0) rectangle (\@venn@w,\@venn@h)
- (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}
- }%
+ \let\fillNotABC\@venn@fillNotABC@threesets
% \end{macrocode}
% Fill $A$ but not $B$
% \begin{macrocode}
@@ -1294,6 +1417,664 @@
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\@venn@fillOnlyA@threesets}
+%\changes{1.1}{2016-03-16}{new}
+%\cs{fillOnlyA} is set to this for the three set version.
+% Reimplemented in v1.1 to use new circle intersect code.
+% \begin{macrocode}
+\newcommand*\@venn@fillOnlyA@threesets{%
+% \end{macrocode}
+% Get the intersection points between $A$ and $B$.
+% \begin{macrocode}
+ \@venn@computecircleintersects{\@venn@Ax}{\@venn@Ay}{\@venn@Bx}{\@venn@By}%
+% \end{macrocode}
+% If there aren't two points of intersection, then the circles don't
+% overlap.
+% \begin{macrocode}
+ \ifnum\@venn@intersect@n=2\relax
+% \end{macrocode}
+% We need the point that's furthest from $C$.
+% \begin{macrocode}
+ \pgfmathsetlength{\dimen@i}{\@venn@Cx-\@venn@intersect@i@x}%
+ \pgfmathsetlength{\dimen@ii}{\@venn@Cy-\@venn@intersect@i@y}%
+ \pgfmathsetlength{\dimen@}{\dimen@i*\dimen@i+\dimen@ii*\dimen@ii}%
+ \pgfmathsetlength{\dimen@i}{\@venn@Cx-\@venn@intersect@ii@x}%
+ \pgfmathsetlength{\dimen@ii}{\@venn@Cy-\@venn@intersect@ii@y}%
+ \pgfmathsetlength{\dimen@i}{\dimen@i*\dimen@i+\dimen@ii*\dimen@ii}%
+ \ifdim\dimen@>\dimen@i
+ \pgfmathsetlength{\dimen@i}{\@venn@intersect@i@x-\@venn@Ax}%
+ \pgfmathsetlength{\dimen@ii}{\@venn@intersect@i@y-\@venn@Ay}%
+ \edef\@venn@start@pt@x{\the\@venn@intersect@i@x}%
+ \edef\@venn@start@pt@y{\the\@venn@intersect@i@y}%
+ \else
+ \pgfmathsetlength{\dimen@i}{\@venn@intersect@ii@x-\@venn@Ax}%
+ \pgfmathsetlength{\dimen@ii}{\@venn@intersect@ii@y-\@venn@Ay}%
+ \edef\@venn@start@pt@x{\the\@venn@intersect@ii@x}%
+ \edef\@venn@start@pt@y{\the\@venn@intersect@ii@y}%
+ \fi
+% \end{macrocode}
+% Compute the initial angle of the first arc.
+% \begin{macrocode}
+ \ifvennoldpgf
+ \pgfmathatantwo{\dimen@i}{\dimen@ii}%
+ \else
+ \pgfmathatantwo{\dimen@ii}{\dimen@i}%
+ \fi
+ \let\@venn@start@i@angle\pgfmathresult
+% \end{macrocode}
+% Compute the intersection between $A$ and $C$.
+% \begin{macrocode}
+ \@venn@computecircleintersects{\@venn@Ax}{\@venn@Ay}{\@venn@Cx}{\@venn@Cy}%
+% \end{macrocode}
+% Need the point furthest from $B$.
+% \begin{macrocode}
+ \pgfmathsetlength{\dimen@i}{\@venn@Bx-\@venn@intersect@i@x}%
+ \pgfmathsetlength{\dimen@ii}{\@venn@By-\@venn@intersect@i@y}%
+ \pgfmathsetlength{\dimen@}{\dimen@i*\dimen@i+\dimen@ii*\dimen@ii}%
+ \pgfmathsetlength{\dimen@i}{\@venn@Bx-\@venn@intersect@ii@x}%
+ \pgfmathsetlength{\dimen@ii}{\@venn@By-\@venn@intersect@ii@y}%
+ \pgfmathsetlength{\dimen@i}{\dimen@i*\dimen@i+\dimen@ii*\dimen@ii}%
+ \ifdim\dimen@>\dimen@i
+ \pgfmathsetlength{\dimen@i}{\@venn@intersect@i@x-\@venn@Ax}%
+ \pgfmathsetlength{\dimen@ii}{\@venn@intersect@i@y-\@venn@Ay}%
+ \edef\@venn@end@pt@i@x{\the\@venn@intersect@i@x}%
+ \edef\@venn@end@pt@i@y{\the\@venn@intersect@i@y}%
+ \else
+ \pgfmathsetlength{\dimen@i}{\@venn@intersect@ii@x-\@venn@Ax}%
+ \pgfmathsetlength{\dimen@ii}{\@venn@intersect@ii@y-\@venn@Ay}%
+ \edef\@venn@end@pt@i@x{\the\@venn@intersect@ii@x}%
+ \edef\@venn@end@pt@i@y{\the\@venn@intersect@ii@y}%
+ \fi
+% \end{macrocode}
+% Compute the end angle of the first arc.
+% \begin{macrocode}
+ \ifvennoldpgf
+ \pgfmathatantwo{\dimen@i}{\dimen@ii}%
+ \else
+ \pgfmathatantwo{\dimen@ii}{\dimen@i}%
+ \fi
+ \let\@venn@end@i@angle\pgfmathresult
+ \pgfmathadd{\@venn@end@i@angle}{360}%
+ \let\@venn@end@i@angle\pgfmathresult
+% \end{macrocode}
+% Compute the start angle of the second arc.
+% \begin{macrocode}
+ \pgfmathsetlength{\dimen@i}{\@venn@end@pt@i@x-\@venn@Cx}%
+ \pgfmathsetlength{\dimen@ii}{\@venn@end@pt@i@y-\@venn@Cy}%
+ \ifvennoldpgf
+ \pgfmathatantwo{\dimen@i}{\dimen@ii}%
+ \else
+ \pgfmathatantwo{\dimen@ii}{\dimen@i}%
+ \fi
+ \let\@venn@start@ii@angle\pgfmathresult
+% \end{macrocode}
+% Compute the intersection between $B$ and $C$.
+% \begin{macrocode}
+ \@venn@computecircleintersects{\@venn@Bx}{\@venn@By}{\@venn@Cx}{\@venn@Cy}%
+% \end{macrocode}
+% Need the point closest to $A$.
+% \begin{macrocode}
+ \pgfmathsetlength{\dimen@i}{\@venn@Ax-\@venn@intersect@i@x}%
+ \pgfmathsetlength{\dimen@ii}{\@venn@Ay-\@venn@intersect@i@y}%
+ \pgfmathsetlength{\dimen@}{\dimen@i*\dimen@i+\dimen@ii*\dimen@ii}%
+ \pgfmathsetlength{\dimen@i}{\@venn@Ax-\@venn@intersect@ii@x}%
+ \pgfmathsetlength{\dimen@ii}{\@venn@Ay-\@venn@intersect@ii@y}%
+ \pgfmathsetlength{\dimen@i}{\dimen@i*\dimen@i+\dimen@ii*\dimen@ii}%
+ \ifdim\dimen@<\dimen@i
+ \pgfmathsetlength{\dimen@i}{\@venn@intersect@i@x-\@venn@Cx}%
+ \pgfmathsetlength{\dimen@ii}{\@venn@intersect@i@y-\@venn@Cy}%
+ \edef\@venn@end@pt@ii@x{\the\@venn@intersect@i@x}%
+ \edef\@venn@end@pt@ii@y{\the\@venn@intersect@i@y}%
+ \else
+ \pgfmathsetlength{\dimen@i}{\@venn@intersect@ii@x-\@venn@Cx}%
+ \pgfmathsetlength{\dimen@ii}{\@venn@intersect@ii@y-\@venn@Cy}%
+ \edef\@venn@end@pt@ii@x{\the\@venn@intersect@ii@x}%
+ \edef\@venn@end@pt@ii@y{\the\@venn@intersect@ii@y}%
+ \fi
+% \end{macrocode}
+% Compute the end angle of the second arc.
+% \begin{macrocode}
+ \ifvennoldpgf
+ \pgfmathatantwo{\dimen@i}{\dimen@ii}%
+ \else
+ \pgfmathatantwo{\dimen@ii}{\dimen@i}%
+ \fi
+ \let\@venn@end@ii@angle\pgfmathresult
+% \end{macrocode}
+% Compute the start angle of the third arc.
+% \begin{macrocode}
+ \pgfmathsetlength{\dimen@i}{\@venn@end@pt@ii@x-\@venn@Bx}%
+ \pgfmathsetlength{\dimen@ii}{\@venn@end@pt@ii@y-\@venn@By}%
+ \ifvennoldpgf
+ \pgfmathatantwo{\dimen@i}{\dimen@ii}%
+ \else
+ \pgfmathatantwo{\dimen@ii}{\dimen@i}%
+ \fi
+ \let\@venn@start@iii@angle\pgfmathresult
+% \end{macrocode}
+% Compute the end angle of the third arc.
+% \begin{macrocode}
+ \pgfmathsetlength{\dimen@i}{\@venn@start@pt@x-\@venn@Bx}%
+ \pgfmathsetlength{\dimen@ii}{\@venn@start@pt@y-\@venn@By}%
+ \ifvennoldpgf
+ \pgfmathatantwo{\dimen@i}{\dimen@ii}%
+ \else
+ \pgfmathatantwo{\dimen@ii}{\dimen@i}%
+ \fi
+ \let\@venn@end@iii@angle\pgfmathresult
+ \pgfmathsubtract{\@venn@end@iii@angle}{360}%
+ \let\@venn@end@iii@angle\pgfmathresult
+% \end{macrocode}
+% Fill path
+% \begin{macrocode}
+ \path[fill=\@venn@shade] (\@venn@start@pt@x,\@venn@start@pt@y)
+ arc[radius=\@venn@radius,start angle=\@venn@start@i@angle,
+ end angle=\@venn@end@i@angle]
+ arc[radius=\@venn@radius,start angle=\@venn@start@ii@angle,
+ end angle=\@venn@end@ii@angle]
+ arc[radius=\@venn@radius,start angle=\@venn@start@iii@angle,
+ end angle=\@venn@end@iii@angle] -- cycle;
+ \else
+ \fillOnlyA
+ \fi
+}%
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\@venn@fillOnlyB@threesets}
+%\changes{1.1}{2016-03-16}{new}
+%\cs{fillOnlyB} is set to this for the three set version.
+% Reimplemented in v1.1 to use new circle intersect code.
+% \begin{macrocode}
+\newcommand*\@venn@fillOnlyB@threesets{%
+% \end{macrocode}
+% Get the intersection points between $B$ and $A$.
+% \begin{macrocode}
+ \@venn@computecircleintersects{\@venn@Bx}{\@venn@By}{\@venn@Ax}{\@venn@Ay}%
+% \end{macrocode}
+% If there aren't two points of intersection, then the circles don't
+% overlap.
+% \begin{macrocode}
+ \ifnum\@venn@intersect@n=2\relax
+% \end{macrocode}
+% We need the point that's furthest from $C$.
+% \begin{macrocode}
+ \pgfmathsetlength{\dimen@i}{\@venn@Cx-\@venn@intersect@i@x}%
+ \pgfmathsetlength{\dimen@ii}{\@venn@Cy-\@venn@intersect@i@y}%
+ \pgfmathsetlength{\dimen@}{\dimen@i*\dimen@i+\dimen@ii*\dimen@ii}%
+ \pgfmathsetlength{\dimen@i}{\@venn@Cx-\@venn@intersect@ii@x}%
+ \pgfmathsetlength{\dimen@ii}{\@venn@Cy-\@venn@intersect@ii@y}%
+ \pgfmathsetlength{\dimen@i}{\dimen@i*\dimen@i+\dimen@ii*\dimen@ii}%
+ \ifdim\dimen@>\dimen@i
+ \pgfmathsetlength{\dimen@i}{\@venn@intersect@i@x-\@venn@Bx}%
+ \pgfmathsetlength{\dimen@ii}{\@venn@intersect@i@y-\@venn@By}%
+ \edef\@venn@start@pt@x{\the\@venn@intersect@i@x}%
+ \edef\@venn@start@pt@y{\the\@venn@intersect@i@y}%
+ \else
+ \pgfmathsetlength{\dimen@i}{\@venn@intersect@ii@x-\@venn@Bx}%
+ \pgfmathsetlength{\dimen@ii}{\@venn@intersect@ii@y-\@venn@By}%
+ \edef\@venn@start@pt@x{\the\@venn@intersect@ii@x}%
+ \edef\@venn@start@pt@y{\the\@venn@intersect@ii@y}%
+ \fi
+% \end{macrocode}
+% Compute the initial angle of the first arc.
+% \begin{macrocode}
+ \ifvennoldpgf
+ \pgfmathatantwo{\dimen@i}{\dimen@ii}%
+ \else
+ \pgfmathatantwo{\dimen@ii}{\dimen@i}%
+ \fi
+ \let\@venn@start@i@angle\pgfmathresult
+% \end{macrocode}
+% Compute the intersection between $B$ and $C$.
+% \begin{macrocode}
+ \@venn@computecircleintersects{\@venn@Bx}{\@venn@By}{\@venn@Cx}{\@venn@Cy}%
+% \end{macrocode}
+% Need the point furthest from $A$.
+% \begin{macrocode}
+ \pgfmathsetlength{\dimen@i}{\@venn@Ax-\@venn@intersect@i@x}%
+ \pgfmathsetlength{\dimen@ii}{\@venn@Ay-\@venn@intersect@i@y}%
+ \pgfmathsetlength{\dimen@}{\dimen@i*\dimen@i+\dimen@ii*\dimen@ii}%
+ \pgfmathsetlength{\dimen@i}{\@venn@Ax-\@venn@intersect@ii@x}%
+ \pgfmathsetlength{\dimen@ii}{\@venn@Ay-\@venn@intersect@ii@y}%
+ \pgfmathsetlength{\dimen@i}{\dimen@i*\dimen@i+\dimen@ii*\dimen@ii}%
+ \ifdim\dimen@>\dimen@i
+ \pgfmathsetlength{\dimen@i}{\@venn@intersect@i@x-\@venn@Bx}%
+ \pgfmathsetlength{\dimen@ii}{\@venn@intersect@i@y-\@venn@By}%
+ \edef\@venn@end@pt@i@x{\the\@venn@intersect@i@x}%
+ \edef\@venn@end@pt@i@y{\the\@venn@intersect@i@y}%
+ \else
+ \pgfmathsetlength{\dimen@i}{\@venn@intersect@ii@x-\@venn@Bx}%
+ \pgfmathsetlength{\dimen@ii}{\@venn@intersect@ii@y-\@venn@By}%
+ \edef\@venn@end@pt@i@x{\the\@venn@intersect@ii@x}%
+ \edef\@venn@end@pt@i@y{\the\@venn@intersect@ii@y}%
+ \fi
+% \end{macrocode}
+% Compute the end angle of the first arc.
+% \begin{macrocode}
+ \ifvennoldpgf
+ \pgfmathatantwo{\dimen@i}{\dimen@ii}%
+ \else
+ \pgfmathatantwo{\dimen@ii}{\dimen@i}%
+ \fi
+ \let\@venn@end@i@angle\pgfmathresult
+% \end{macrocode}
+% Compute the start angle of the second arc.
+% \begin{macrocode}
+ \pgfmathsetlength{\dimen@i}{\@venn@end@pt@i@x-\@venn@Cx}%
+ \pgfmathsetlength{\dimen@ii}{\@venn@end@pt@i@y-\@venn@Cy}%
+ \ifvennoldpgf
+ \pgfmathatantwo{\dimen@i}{\dimen@ii}%
+ \else
+ \pgfmathatantwo{\dimen@ii}{\dimen@i}%
+ \fi
+ \let\@venn@start@ii@angle\pgfmathresult
+% \end{macrocode}
+% Compute the intersection between $A$ and $C$.
+% \begin{macrocode}
+ \@venn@computecircleintersects{\@venn@Ax}{\@venn@Ay}{\@venn@Cx}{\@venn@Cy}%
+% \end{macrocode}
+% Need the point closest to $A$.
+% \begin{macrocode}
+ \pgfmathsetlength{\dimen@i}{\@venn@Bx-\@venn@intersect@i@x}%
+ \pgfmathsetlength{\dimen@ii}{\@venn@By-\@venn@intersect@i@y}%
+ \pgfmathsetlength{\dimen@}{\dimen@i*\dimen@i+\dimen@ii*\dimen@ii}%
+ \pgfmathsetlength{\dimen@i}{\@venn@Bx-\@venn@intersect@ii@x}%
+ \pgfmathsetlength{\dimen@ii}{\@venn@By-\@venn@intersect@ii@y}%
+ \pgfmathsetlength{\dimen@i}{\dimen@i*\dimen@i+\dimen@ii*\dimen@ii}%
+ \ifdim\dimen@<\dimen@i
+ \pgfmathsetlength{\dimen@i}{\@venn@intersect@i@x-\@venn@Cx}%
+ \pgfmathsetlength{\dimen@ii}{\@venn@intersect@i@y-\@venn@Cy}%
+ \edef\@venn@end@pt@ii@x{\the\@venn@intersect@i@x}%
+ \edef\@venn@end@pt@ii@y{\the\@venn@intersect@i@y}%
+ \else
+ \pgfmathsetlength{\dimen@i}{\@venn@intersect@ii@x-\@venn@Cx}%
+ \pgfmathsetlength{\dimen@ii}{\@venn@intersect@ii@y-\@venn@Cy}%
+ \edef\@venn@end@pt@ii@x{\the\@venn@intersect@ii@x}%
+ \edef\@venn@end@pt@ii@y{\the\@venn@intersect@ii@y}%
+ \fi
+% \end{macrocode}
+% Compute the end angle of the second arc.
+% \begin{macrocode}
+ \ifvennoldpgf
+ \pgfmathatantwo{\dimen@i}{\dimen@ii}%
+ \else
+ \pgfmathatantwo{\dimen@ii}{\dimen@i}%
+ \fi
+ \let\@venn@end@ii@angle\pgfmathresult
+% \end{macrocode}
+% Compute the start angle of the third arc.
+% \begin{macrocode}
+ \pgfmathsetlength{\dimen@i}{\@venn@end@pt@ii@x-\@venn@Ax}%
+ \pgfmathsetlength{\dimen@ii}{\@venn@end@pt@ii@y-\@venn@Ay}%
+ \ifvennoldpgf
+ \pgfmathatantwo{\dimen@i}{\dimen@ii}%
+ \else
+ \pgfmathatantwo{\dimen@ii}{\dimen@i}%
+ \fi
+ \let\@venn@start@iii@angle\pgfmathresult
+% \end{macrocode}
+% Compute the end angle of the third arc.
+% \begin{macrocode}
+ \pgfmathsetlength{\dimen@i}{\@venn@start@pt@x-\@venn@Ax}%
+ \pgfmathsetlength{\dimen@ii}{\@venn@start@pt@y-\@venn@Ay}%
+ \ifvennoldpgf
+ \pgfmathatantwo{\dimen@i}{\dimen@ii}%
+ \else
+ \pgfmathatantwo{\dimen@ii}{\dimen@i}%
+ \fi
+ \let\@venn@end@iii@angle\pgfmathresult
+% \end{macrocode}
+% Fill path
+% \begin{macrocode}
+ \path[fill=\@venn@shade]
+ (\@venn@start@pt@x,\@venn@start@pt@y)
+ arc[radius=\@venn@radius,start angle=\@venn@start@i@angle,
+ end angle=\@venn@end@i@angle]
+ arc[radius=\@venn@radius,start angle=\@venn@start@ii@angle,
+ end angle=\@venn@end@ii@angle]
+ arc[radius=\@venn@radius,start angle=\@venn@start@iii@angle,
+ end angle=\@venn@end@iii@angle] -- cycle;
+ \else
+ \fillOnlyB
+ \fi
+}%
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\@venn@fillOnlyC@threesets}
+%\changes{1.1}{2016-03-16}{new}
+%\cs{fillOnlyC} is set to this for the three set version.
+% Reimplemented in v1.1 to use new circle intersect code.
+% \begin{macrocode}
+\newcommand*\@venn@fillOnlyC@threesets{%
+% \end{macrocode}
+% Get the intersection points between $C$ and $B$.
+% \begin{macrocode}
+ \@venn@computecircleintersects{\@venn@Cx}{\@venn@Cy}{\@venn@Bx}{\@venn@By}%
+% \end{macrocode}
+% If there aren't two points of intersection, then the circles don't
+% overlap.
+% \begin{macrocode}
+ \ifnum\@venn@intersect@n=2\relax
+% \end{macrocode}
+% We need the point that's furthest from $A$.
+% \begin{macrocode}
+ \pgfmathsetlength{\dimen@i}{\@venn@Ax-\@venn@intersect@i@x}%
+ \pgfmathsetlength{\dimen@ii}{\@venn@Ay-\@venn@intersect@i@y}%
+ \pgfmathsetlength{\dimen@}{\dimen@i*\dimen@i+\dimen@ii*\dimen@ii}%
+ \pgfmathsetlength{\dimen@i}{\@venn@Ax-\@venn@intersect@ii@x}%
+ \pgfmathsetlength{\dimen@ii}{\@venn@Ay-\@venn@intersect@ii@y}%
+ \pgfmathsetlength{\dimen@i}{\dimen@i*\dimen@i+\dimen@ii*\dimen@ii}%
+ \ifdim\dimen@>\dimen@i
+ \pgfmathsetlength{\dimen@i}{\@venn@intersect@i@x-\@venn@Cx}%
+ \pgfmathsetlength{\dimen@ii}{\@venn@intersect@i@y-\@venn@Cy}%
+ \edef\@venn@start@pt@x{\the\@venn@intersect@i@x}%
+ \edef\@venn@start@pt@y{\the\@venn@intersect@i@y}%
+ \else
+ \pgfmathsetlength{\dimen@i}{\@venn@intersect@ii@x-\@venn@Cx}%
+ \pgfmathsetlength{\dimen@ii}{\@venn@intersect@ii@y-\@venn@Cy}%
+ \edef\@venn@start@pt@x{\the\@venn@intersect@ii@x}%
+ \edef\@venn@start@pt@y{\the\@venn@intersect@ii@y}%
+ \fi
+% \end{macrocode}
+% Compute the initial angle of the first arc.
+% \begin{macrocode}
+ \ifvennoldpgf
+ \pgfmathatantwo{\dimen@i}{\dimen@ii}%
+ \else
+ \pgfmathatantwo{\dimen@ii}{\dimen@i}%
+ \fi
+ \let\@venn@start@i@angle\pgfmathresult
+% \end{macrocode}
+% Compute the intersection between $C$ and $A$.
+% \begin{macrocode}
+ \@venn@computecircleintersects{\@venn@Cx}{\@venn@Cy}{\@venn@Ax}{\@venn@Ay}%
+% \end{macrocode}
+% Need the point furthest from $B$.
+% \begin{macrocode}
+ \pgfmathsetlength{\dimen@i}{\@venn@Bx-\@venn@intersect@i@x}%
+ \pgfmathsetlength{\dimen@ii}{\@venn@By-\@venn@intersect@i@y}%
+ \pgfmathsetlength{\dimen@}{\dimen@i*\dimen@i+\dimen@ii*\dimen@ii}%
+ \pgfmathsetlength{\dimen@i}{\@venn@Bx-\@venn@intersect@ii@x}%
+ \pgfmathsetlength{\dimen@ii}{\@venn@By-\@venn@intersect@ii@y}%
+ \pgfmathsetlength{\dimen@i}{\dimen@i*\dimen@i+\dimen@ii*\dimen@ii}%
+ \ifdim\dimen@>\dimen@i
+ \pgfmathsetlength{\dimen@i}{\@venn@intersect@i@x-\@venn@Cx}%
+ \pgfmathsetlength{\dimen@ii}{\@venn@intersect@i@y-\@venn@Cy}%
+ \edef\@venn@end@pt@i@x{\the\@venn@intersect@i@x}%
+ \edef\@venn@end@pt@i@y{\the\@venn@intersect@i@y}%
+ \else
+ \pgfmathsetlength{\dimen@i}{\@venn@intersect@ii@x-\@venn@Cx}%
+ \pgfmathsetlength{\dimen@ii}{\@venn@intersect@ii@y-\@venn@Cy}%
+ \edef\@venn@end@pt@i@x{\the\@venn@intersect@ii@x}%
+ \edef\@venn@end@pt@i@y{\the\@venn@intersect@ii@y}%
+ \fi
+% \end{macrocode}
+% Compute the end angle of the first arc.
+% \begin{macrocode}
+ \ifvennoldpgf
+ \pgfmathatantwo{\dimen@i}{\dimen@ii}%
+ \else
+ \pgfmathatantwo{\dimen@ii}{\dimen@i}%
+ \fi
+ \let\@venn@end@i@angle\pgfmathresult
+ \pgfmathsubtract{\@venn@end@i@angle}{360}%
+ \let\@venn@end@i@angle\pgfmathresult
+% \end{macrocode}
+% Compute the start angle of the second arc.
+% \begin{macrocode}
+ \pgfmathsetlength{\dimen@i}{\@venn@end@pt@i@x-\@venn@Ax}%
+ \pgfmathsetlength{\dimen@ii}{\@venn@end@pt@i@y-\@venn@Ay}%
+ \ifvennoldpgf
+ \pgfmathatantwo{\dimen@i}{\dimen@ii}%
+ \else
+ \pgfmathatantwo{\dimen@ii}{\dimen@i}%
+ \fi
+ \let\@venn@start@ii@angle\pgfmathresult
+% \end{macrocode}
+% Compute the intersection between $B$ and $A$.
+% \begin{macrocode}
+ \@venn@computecircleintersects{\@venn@Bx}{\@venn@By}{\@venn@Ax}{\@venn@Ay}%
+% \end{macrocode}
+% Need the point closest to $C$.
+% \begin{macrocode}
+ \pgfmathsetlength{\dimen@i}{\@venn@Cx-\@venn@intersect@i@x}%
+ \pgfmathsetlength{\dimen@ii}{\@venn@Cy-\@venn@intersect@i@y}%
+ \pgfmathsetlength{\dimen@}{\dimen@i*\dimen@i+\dimen@ii*\dimen@ii}%
+ \pgfmathsetlength{\dimen@i}{\@venn@Cx-\@venn@intersect@ii@x}%
+ \pgfmathsetlength{\dimen@ii}{\@venn@Cy-\@venn@intersect@ii@y}%
+ \pgfmathsetlength{\dimen@i}{\dimen@i*\dimen@i+\dimen@ii*\dimen@ii}%
+ \ifdim\dimen@<\dimen@i
+ \pgfmathsetlength{\dimen@i}{\@venn@intersect@i@x-\@venn@Ax}%
+ \pgfmathsetlength{\dimen@ii}{\@venn@intersect@i@y-\@venn@Ay}%
+ \edef\@venn@end@pt@ii@x{\the\@venn@intersect@i@x}%
+ \edef\@venn@end@pt@ii@y{\the\@venn@intersect@i@y}%
+ \else
+ \pgfmathsetlength{\dimen@i}{\@venn@intersect@ii@x-\@venn@Ax}%
+ \pgfmathsetlength{\dimen@ii}{\@venn@intersect@ii@y-\@venn@Ay}%
+ \edef\@venn@end@pt@ii@x{\the\@venn@intersect@ii@x}%
+ \edef\@venn@end@pt@ii@y{\the\@venn@intersect@ii@y}%
+ \fi
+% \end{macrocode}
+% Compute the end angle of the second arc.
+% \begin{macrocode}
+ \ifvennoldpgf
+ \pgfmathatantwo{\dimen@i}{\dimen@ii}%
+ \else
+ \pgfmathatantwo{\dimen@ii}{\dimen@i}%
+ \fi
+ \let\@venn@end@ii@angle\pgfmathresult
+% \end{macrocode}
+% Compute the start angle of the third arc.
+% \begin{macrocode}
+ \pgfmathsetlength{\dimen@i}{\@venn@end@pt@ii@x-\@venn@Bx}%
+ \pgfmathsetlength{\dimen@ii}{\@venn@end@pt@ii@y-\@venn@By}%
+ \ifvennoldpgf
+ \pgfmathatantwo{\dimen@i}{\dimen@ii}%
+ \else
+ \pgfmathatantwo{\dimen@ii}{\dimen@i}%
+ \fi
+ \let\@venn@start@iii@angle\pgfmathresult
+% \end{macrocode}
+% Compute the end angle of the third arc.
+% \begin{macrocode}
+ \pgfmathsetlength{\dimen@i}{\@venn@start@pt@x-\@venn@Bx}%
+ \pgfmathsetlength{\dimen@ii}{\@venn@start@pt@y-\@venn@By}%
+ \ifvennoldpgf
+ \pgfmathatantwo{\dimen@i}{\dimen@ii}%
+ \else
+ \pgfmathatantwo{\dimen@ii}{\dimen@i}%
+ \fi
+ \let\@venn@end@iii@angle\pgfmathresult
+% \end{macrocode}
+% Fill path
+% \begin{macrocode}
+ \path[fill=\@venn@shade] (\@venn@start@pt@x,\@venn@start@pt@y)
+ arc[radius=\@venn@radius,start angle=\@venn@start@i@angle,
+ end angle=\@venn@end@i@angle]
+ arc[radius=\@venn@radius,start angle=\@venn@start@ii@angle,
+ end angle=\@venn@end@ii@angle]
+ arc[radius=\@venn@radius,start angle=\@venn@start@iii@angle,
+ end angle=\@venn@end@iii@angle] -- cycle;
+ \else
+ \fillOnlyC
+ \fi
+}%
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\@venn@fillNotABC@threesets}
+%\changes{1.1}{2016-03-16}{new}
+%\cs{fillNotABC} is set to this for the three set version.
+% Reimplemented in v1.1 to use new circle intersect code.
+% \begin{macrocode}
+\newcommand*\@venn@fillNotABC@threesets{%
+% \end{macrocode}
+% Get the intersection points between $A$ and $B$.
+% \begin{macrocode}
+ \@venn@computecircleintersects{\@venn@Ax}{\@venn@Ay}{\@venn@Bx}{\@venn@By}%
+% \end{macrocode}
+% If there aren't two points of intersection, then the circles don't
+% overlap.
+% \begin{macrocode}
+ \ifnum\@venn@intersect@n=2\relax
+% \end{macrocode}
+% We need the point that's furthest from $C$.
+% \begin{macrocode}
+ \pgfmathsetlength{\dimen@i}{\@venn@Cx-\@venn@intersect@i@x}%
+ \pgfmathsetlength{\dimen@ii}{\@venn@Cy-\@venn@intersect@i@y}%
+ \pgfmathsetlength{\dimen@}{\dimen@i*\dimen@i+\dimen@ii*\dimen@ii}%
+ \pgfmathsetlength{\dimen@i}{\@venn@Cx-\@venn@intersect@ii@x}%
+ \pgfmathsetlength{\dimen@ii}{\@venn@Cy-\@venn@intersect@ii@y}%
+ \pgfmathsetlength{\dimen@i}{\dimen@i*\dimen@i+\dimen@ii*\dimen@ii}%
+ \ifdim\dimen@>\dimen@i
+ \pgfmathsetlength{\dimen@i}{\@venn@intersect@i@x-\@venn@Ax}%
+ \pgfmathsetlength{\dimen@ii}{\@venn@intersect@i@y-\@venn@Ay}%
+ \edef\@venn@start@pt@x{\the\@venn@intersect@i@x}%
+ \edef\@venn@start@pt@y{\the\@venn@intersect@i@y}%
+ \else
+ \pgfmathsetlength{\dimen@i}{\@venn@intersect@ii@x-\@venn@Ax}%
+ \pgfmathsetlength{\dimen@ii}{\@venn@intersect@ii@y-\@venn@Ay}%
+ \edef\@venn@start@pt@x{\the\@venn@intersect@ii@x}%
+ \edef\@venn@start@pt@y{\the\@venn@intersect@ii@y}%
+ \fi
+% \end{macrocode}
+% Compute the initial angle of the first arc.
+% \begin{macrocode}
+ \ifvennoldpgf
+ \pgfmathatantwo{\dimen@i}{\dimen@ii}%
+ \else
+ \pgfmathatantwo{\dimen@ii}{\dimen@i}%
+ \fi
+ \let\@venn@start@i@angle\pgfmathresult
+% \end{macrocode}
+% Compute the intersection between $A$ and $C$.
+% \begin{macrocode}
+ \@venn@computecircleintersects{\@venn@Ax}{\@venn@Ay}{\@venn@Cx}{\@venn@Cy}%
+% \end{macrocode}
+% We need the point that's furthest from $B$.
+% \begin{macrocode}
+ \pgfmathsetlength{\dimen@i}{\@venn@Bx-\@venn@intersect@i@x}%
+ \pgfmathsetlength{\dimen@ii}{\@venn@By-\@venn@intersect@i@y}%
+ \pgfmathsetlength{\dimen@}{\dimen@i*\dimen@i+\dimen@ii*\dimen@ii}%
+ \pgfmathsetlength{\dimen@i}{\@venn@Bx-\@venn@intersect@ii@x}%
+ \pgfmathsetlength{\dimen@ii}{\@venn@By-\@venn@intersect@ii@y}%
+ \pgfmathsetlength{\dimen@i}{\dimen@i*\dimen@i+\dimen@ii*\dimen@ii}%
+ \ifdim\dimen@>\dimen@i
+ \pgfmathsetlength{\dimen@i}{\@venn@intersect@i@x-\@venn@Ax}%
+ \pgfmathsetlength{\dimen@ii}{\@venn@intersect@i@y-\@venn@Ay}%
+ \edef\@venn@end@pt@i@x{\the\@venn@intersect@i@x}%
+ \edef\@venn@end@pt@i@y{\the\@venn@intersect@i@y}%
+ \else
+ \pgfmathsetlength{\dimen@i}{\@venn@intersect@ii@x-\@venn@Ax}%
+ \pgfmathsetlength{\dimen@ii}{\@venn@intersect@ii@y-\@venn@Ay}%
+ \edef\@venn@end@pt@i@x{\the\@venn@intersect@ii@x}%
+ \edef\@venn@end@pt@i@y{\the\@venn@intersect@ii@y}%
+ \fi
+% \end{macrocode}
+% Compute the end angle of the first arc.
+% \begin{macrocode}
+ \ifvennoldpgf
+ \pgfmathatantwo{\dimen@i}{\dimen@ii}%
+ \else
+ \pgfmathatantwo{\dimen@ii}{\dimen@i}%
+ \fi
+ \let\@venn@end@i@angle\pgfmathresult
+ \pgfmathadd{\@venn@end@i@angle}{360}%
+ \let\@venn@end@i@angle\pgfmathresult
+% \end{macrocode}
+% Compute the start angle of the second arc.
+% \begin{macrocode}
+ \pgfmathsetlength{\dimen@i}{\@venn@end@pt@i@x-\@venn@Cx}%
+ \pgfmathsetlength{\dimen@ii}{\@venn@end@pt@i@y-\@venn@Cy}%
+ \ifvennoldpgf
+ \pgfmathatantwo{\dimen@i}{\dimen@ii}%
+ \else
+ \pgfmathatantwo{\dimen@ii}{\dimen@i}%
+ \fi
+ \let\@venn@start@ii@angle\pgfmathresult
+% \end{macrocode}
+% Compute the intersection between $C$ and $B$.
+% \begin{macrocode}
+ \@venn@computecircleintersects{\@venn@Cx}{\@venn@Cy}{\@venn@Bx}{\@venn@By}%
+% \end{macrocode}
+% We need the point that's furthest from $A$.
+% \begin{macrocode}
+ \pgfmathsetlength{\dimen@i}{\@venn@Ax-\@venn@intersect@i@x}%
+ \pgfmathsetlength{\dimen@ii}{\@venn@Ay-\@venn@intersect@i@y}%
+ \pgfmathsetlength{\dimen@}{\dimen@i*\dimen@i+\dimen@ii*\dimen@ii}%
+ \pgfmathsetlength{\dimen@i}{\@venn@Ax-\@venn@intersect@ii@x}%
+ \pgfmathsetlength{\dimen@ii}{\@venn@Ay-\@venn@intersect@ii@y}%
+ \pgfmathsetlength{\dimen@i}{\dimen@i*\dimen@i+\dimen@ii*\dimen@ii}%
+ \ifdim\dimen@>\dimen@i
+ \pgfmathsetlength{\dimen@i}{\@venn@intersect@i@x-\@venn@Cx}%
+ \pgfmathsetlength{\dimen@ii}{\@venn@intersect@i@y-\@venn@Cy}%
+ \edef\@venn@end@pt@ii@x{\the\@venn@intersect@i@x}%
+ \edef\@venn@end@pt@ii@y{\the\@venn@intersect@i@y}%
+ \else
+ \pgfmathsetlength{\dimen@i}{\@venn@intersect@ii@x-\@venn@Cx}%
+ \pgfmathsetlength{\dimen@ii}{\@venn@intersect@ii@y-\@venn@Cy}%
+ \edef\@venn@end@pt@ii@x{\the\@venn@intersect@ii@x}%
+ \edef\@venn@end@pt@ii@y{\the\@venn@intersect@ii@y}%
+ \fi
+% \end{macrocode}
+% Compute the end angle of the second arc.
+% \begin{macrocode}
+ \ifvennoldpgf
+ \pgfmathatantwo{\dimen@i}{\dimen@ii}%
+ \else
+ \pgfmathatantwo{\dimen@ii}{\dimen@i}%
+ \fi
+ \let\@venn@end@ii@angle\pgfmathresult
+ \pgfmathadd{\@venn@end@ii@angle}{360}%
+ \let\@venn@end@ii@angle\pgfmathresult
+% \end{macrocode}
+% Compute the start angle of the third arc.
+% \begin{macrocode}
+ \pgfmathsetlength{\dimen@i}{\@venn@end@pt@ii@x-\@venn@Bx}%
+ \pgfmathsetlength{\dimen@ii}{\@venn@end@pt@ii@y-\@venn@By}%
+ \ifvennoldpgf
+ \pgfmathatantwo{\dimen@i}{\dimen@ii}%
+ \else
+ \pgfmathatantwo{\dimen@ii}{\dimen@i}%
+ \fi
+ \let\@venn@start@iii@angle\pgfmathresult
+% \end{macrocode}
+% Compute the end angle of the third arc.
+% \begin{macrocode}
+ \pgfmathsetlength{\dimen@i}{\@venn@start@pt@x-\@venn@Bx}%
+ \pgfmathsetlength{\dimen@ii}{\@venn@start@pt@y-\@venn@By}%
+ \ifvennoldpgf
+ \pgfmathatantwo{\dimen@i}{\dimen@ii}%
+ \else
+ \pgfmathatantwo{\dimen@ii}{\dimen@i}%
+ \fi
+ \let\@venn@end@iii@angle\pgfmathresult
+% \end{macrocode}
+% Fill path
+% \begin{macrocode}
+ \path[fill=\@venn@shade,even odd rule]
+ (0,0) rectangle (\@venn@w,\@venn@h)
+ (\@venn@start@pt@x,\@venn@start@pt@y)
+ arc[radius=\@venn@radius,start angle=\@venn@start@i@angle,
+ end angle=\@venn@end@i@angle]
+ arc[radius=\@venn@radius,start angle=\@venn@start@ii@angle,
+ end angle=\@venn@end@ii@angle]
+ arc[radius=\@venn@radius,start angle=\@venn@start@iii@angle,
+ end angle=\@venn@end@iii@angle]
+ -- cycle;
+ \else
+ \path[fill=\@venn@shade,even odd rule]
+ (0,0) rectangle (\@venn@w,\@venn@h)
+ (\@venn@Ax,\@venn@Ay) circle (\@venn@radius)
+ (\@venn@Bx,\@venn@By) circle (\@venn@radius)
+ (\@venn@Cx,\@venn@Cy) circle (\@venn@radius);%
+ \fi
+}%
+% \end{macrocode}
+%\end{macro}
+%
%\begin{environment}{venndiagram2sets}
% \begin{macrocode}
\newenvironment{venndiagram2sets}[1][]%
@@ -1333,79 +2114,14 @@
circle (\@venn@radius);}%
\def\fillAll{\path[fill=\@venn@shade] (0,0)
rectangle (\@venn@w,\@venn@h);}%
- \def\fillOnlyA{%
- \begin{scope}
- \path[name path=A] (\@venn@Ax,\@venn@Ay) circle (\@venn@radius);
- \path[name path=B] (\@venn@Bx,\@venn@By) circle (\@venn@radius);
-% \end{macrocode}
-% Get intersection points of A and B
-% \begin{macrocode}
- \path[name intersections={of=A and B,name=ABintersect}]
- (ABintersect-1) ;
- \pgfgetlastxy{\@venn@AB@xi}{\@venn@AB@yi}
- \path (ABintersect-2);
- \pgfgetlastxy{\@venn@AB@xii}{\@venn@AB@yii}
-% \end{macrocode}
-% Compute the start and end angles of arc between intersection
-% points
-% \begin{macrocode}
- \pgfmathparse{atan2(\@venn@AB@xi-\@venn@Ax,\@venn@AB@yi-\@venn@Ay)}
- \let\@venn@start@i=\pgfmathresult
- \pgfmathparse{360+atan2(\@venn@AB@xii-\@venn@Ax,\@venn@AB@yii-\@venn@Ay)}
- \let\@venn@end@i=\pgfmathresult
-% \end{macrocode}
-% Compute start and end angles
-% \begin{macrocode}
- \pgfmathparse{atan2(\@venn@AB@xii-\@venn@Bx, \@venn@AB@yii-\@venn@By)}
- \let\@venn@start@ii=\pgfmathresult
- \pgfmathparse{atan2(\@venn@AB@xi-\@venn@Bx, \@venn@AB@yi-\@venn@By)-360}
- \let\@venn@end@ii=\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]
- -- cycle;
- \end{scope}
- }%
+% \end{macrocode}
+% Fill only set $A$
+% \begin{macrocode}
+ \let\fillOnlyA\@venn@fillOnlyA@twosets
% \end{macrocode}
% Fill only set $B$
% \begin{macrocode}
- \def\fillOnlyB{%
- \begin{scope}
- \path[name path=A] (\@venn@Ax,\@venn@Ay) circle (\@venn@radius);
- \path[name path=B] (\@venn@Bx,\@venn@By) circle (\@venn@radius);
-% \end{macrocode}
-% Get intersection points of A and B
-% \begin{macrocode}
- \path[name intersections={of=A and B,name=ABintersect}]
- (ABintersect-1) ;
- \pgfgetlastxy{\@venn@AB@xi}{\@venn@AB@yi}
- \path (ABintersect-2);
- \pgfgetlastxy{\@venn@AB@xii}{\@venn@AB@yii}
-% \end{macrocode}
-% Compute the start and end angles of arc between intersection
-% points
-% \begin{macrocode}
- \pgfmathparse{atan2(\@venn@AB@xi-\@venn@Bx,\@venn@AB@yi-\@venn@By)}
- \let\@venn@start@i=\pgfmathresult
- \pgfmathparse{atan2(\@venn@AB@xii-\@venn@Bx,\@venn@AB@yii-\@venn@By)}
- \let\@venn@end@i=\pgfmathresult
-% \end{macrocode}
-% Compute start and end angles
-% \begin{macrocode}
- \pgfmathparse{atan2(\@venn@AB@xii-\@venn@Ax, \@venn@AB@yii-\@venn@Ay)}
- \let\@venn@start@ii=\pgfmathresult
- \pgfmathparse{atan2(\@venn@AB@xi-\@venn@Ax, \@venn@AB@yi-\@venn@Ay)}
- \let\@venn@end@ii=\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]
- -- cycle;
- \end{scope}
- }%
+ \let\fillOnlyB\@venn@fillOnlyB@twosets
% \end{macrocode}
% Fill everything except $A$
% \begin{macrocode}
@@ -1445,27 +2161,17 @@
;
}%
% \end{macrocode}
-% Fill $A$ but not $B$
+% Fill $A$ but not $B$ (same as only $A$ for two sets).
+%\changes{1.1}{2016-03-16}{made \cs{fillANotB} a synonym for
+%\cs{fillOnlyA}}
% \begin{macrocode}
- \def\fillANotB{%
- \begin{scope}
- \clip (\@venn@Ax,\@venn@Ay) circle (\@venn@radius);
- \path[fill=\@venn@shade,even odd rule]
- (\@venn@Ax,\@venn@Ay) circle (\@venn@radius)
- (\@venn@Bx,\@venn@By) circle (\@venn@radius);
- \end{scope}
- }%
+ \let\fillANotB\fillOnlyA
% \end{macrocode}
-% Fill $B$ but not $A$
+% Fill $B$ but not $A$ (same as only $B$ for two sets).
+%\changes{1.1}{2016-03-16}{made \cs{fillBNotA} a synonym for
+%\cs{fillOnlyB}}
% \begin{macrocode}
- \def\fillBNotA{%
- \begin{scope}
- \clip (\@venn@Bx,\@venn@By) circle (\@venn@radius);
- \path[fill=\@venn@shade,even odd rule]
- (\@venn@Bx,\@venn@By) circle (\@venn@radius)
- (\@venn@Ax,\@venn@Ay) circle (\@venn@radius);
- \end{scope}
- }%
+ \let\fillBNotA\fillOnlyB
% \end{macrocode}
% Fill $A$ intersect $B$
% \begin{macrocode}
@@ -1531,6 +2237,166 @@
}
% \end{macrocode}
%\end{environment}
+%
+%\begin{macro}{\@venn@fillOnlyA@twosets}
+%\changes{1.1}{2016-03-16}{new}
+%\cs{fillOnlyA} is set to this for the two set version.
+% Reimplemented in v1.1 to use new circle intersect code.
+% \begin{macrocode}
+\newcommand*\@venn@fillOnlyA@twosets{%
+% \end{macrocode}
+% Get the intersection points between $A$ and $B$.
+% \begin{macrocode}
+ \@venn@computecircleintersects{\@venn@Ax}{\@venn@Ay}{\@venn@Bx}{\@venn@By}%
+% \end{macrocode}
+% If there aren't two points of intersection, then the circles don't
+% overlap.
+% \begin{macrocode}
+ \ifnum\@venn@intersect@n=2\relax
+% \end{macrocode}
+% Compute the start angle for the first arc.
+% \begin{macrocode}
+ \pgfmathsetlength{\dimen@i}{\@venn@intersect@i@x-\@venn@Ax}%
+ \pgfmathsetlength{\dimen@ii}{\@venn@intersect@i@y-\@venn@Ay}%
+ \ifvennoldpgf
+ \pgfmathatantwo{\dimen@i}{\dimen@ii}%
+ \else
+ \pgfmathatantwo{\dimen@ii}{\dimen@i}%
+ \fi
+ \let\@venn@start@i@angle\pgfmathresult
+% \end{macrocode}
+% Compute the end angle for the first arc.
+% \begin{macrocode}
+ \pgfmathsetlength{\dimen@i}{\@venn@intersect@ii@x-\@venn@Ax}%
+ \pgfmathsetlength{\dimen@ii}{\@venn@intersect@ii@y-\@venn@Ay}%
+ \ifvennoldpgf
+ \pgfmathatantwo{\dimen@i}{\dimen@ii}%
+ \else
+ \pgfmathatantwo{\dimen@ii}{\dimen@i}%
+ \fi
+ \let\@venn@end@i@angle\pgfmathresult
+ \pgfmathadd{\@venn@end@i@angle}{360}%
+ \let\@venn@end@i@angle\pgfmathresult
+% \end{macrocode}
+% Compute the start angle for the second arc.
+% \begin{macrocode}
+ \pgfmathsetlength{\dimen@i}{\@venn@intersect@ii@x-\@venn@Bx}%
+ \pgfmathsetlength{\dimen@ii}{\@venn@intersect@ii@y-\@venn@By}%
+ \ifvennoldpgf
+ \pgfmathatantwo{\dimen@i}{\dimen@ii}%
+ \else
+ \pgfmathatantwo{\dimen@ii}{\dimen@i}%
+ \fi
+ \let\@venn@start@ii@angle\pgfmathresult
+% \end{macrocode}
+% Compute the end angle for the second arc.
+% \begin{macrocode}
+ \pgfmathsetlength{\dimen@i}{\@venn@intersect@i@x-\@venn@Bx}%
+ \pgfmathsetlength{\dimen@ii}{\@venn@intersect@i@y-\@venn@By}%
+ \ifvennoldpgf
+ \pgfmathatantwo{\dimen@i}{\dimen@ii}%
+ \else
+ \pgfmathatantwo{\dimen@ii}{\dimen@i}%
+ \fi
+ \let\@venn@end@ii@angle\pgfmathresult
+ \pgfmathadd{\@venn@start@ii@angle}{360}%
+ \let\@venn@start@ii@angle\pgfmathresult
+% \end{macrocode}
+% Fill the path
+% \begin{macrocode}
+ \path[fill=\@venn@shade]
+ (\@venn@intersect@i@x,\@venn@intersect@i@y)
+ arc[radius=\@venn@radius,start angle=\@venn@start@i@angle,
+ end angle=\@venn@end@i@angle]
+ arc[radius=\@venn@radius,start angle=\@venn@start@ii@angle,
+ end angle=\@venn@end@ii@angle]
+ -- cycle;
+ \else
+ \fillOnlyA
+ \fi
+}%
+% \end{macrocode}
+%\end{macro}
+%
+%\begin{macro}{\@venn@fillOnlyB@twosets}
+%\changes{1.1}{2016-03-16}{new}
+%\cs{fillOnlyB} is set to this for the two set version.
+% Reimplemented in v1.1 to use new circle intersect code.
+% \begin{macrocode}
+\newcommand*\@venn@fillOnlyB@twosets{%
+% \end{macrocode}
+% Get the intersection points between $A$ and $B$.
+% \begin{macrocode}
+ \@venn@computecircleintersects{\@venn@Ax}{\@venn@Ay}{\@venn@Bx}{\@venn@By}%
+% \end{macrocode}
+% If there aren't two points of intersection, then the circles don't
+% overlap.
+% \begin{macrocode}
+ \ifnum\@venn@intersect@n=2\relax
+% \end{macrocode}
+% Compute the start angle for the first arc.
+% \begin{macrocode}
+ \pgfmathsetlength{\dimen@i}{\@venn@intersect@i@x-\@venn@Bx}%
+ \pgfmathsetlength{\dimen@ii}{\@venn@intersect@i@y-\@venn@By}%
+ \ifvennoldpgf
+ \pgfmathatantwo{\dimen@i}{\dimen@ii}%
+ \else
+ \pgfmathatantwo{\dimen@ii}{\dimen@i}%
+ \fi
+ \let\@venn@start@i@angle\pgfmathresult
+% \end{macrocode}
+% Compute the end angle for the first arc.
+% \begin{macrocode}
+ \pgfmathsetlength{\dimen@i}{\@venn@intersect@ii@x-\@venn@Bx}%
+ \pgfmathsetlength{\dimen@ii}{\@venn@intersect@ii@y-\@venn@By}%
+ \ifvennoldpgf
+ \pgfmathatantwo{\dimen@i}{\dimen@ii}%
+ \else
+ \pgfmathatantwo{\dimen@ii}{\dimen@i}%
+ \fi
+ \let\@venn@end@i@angle\pgfmathresult
+% \pgfmathadd{\@venn@end@i@angle}{360}%
+% \let\@venn@end@i@angle\pgfmathresult
+% \end{macrocode}
+% Compute the start angle for the second arc.
+% \begin{macrocode}
+ \pgfmathsetlength{\dimen@i}{\@venn@intersect@ii@x-\@venn@Ax}%
+ \pgfmathsetlength{\dimen@ii}{\@venn@intersect@ii@y-\@venn@Ay}%
+ \ifvennoldpgf
+ \pgfmathatantwo{\dimen@i}{\dimen@ii}%
+ \else
+ \pgfmathatantwo{\dimen@ii}{\dimen@i}%
+ \fi
+ \let\@venn@start@ii@angle\pgfmathresult
+% \end{macrocode}
+% Compute the end angle for the second arc.
+% \begin{macrocode}
+ \pgfmathsetlength{\dimen@i}{\@venn@intersect@i@x-\@venn@Ax}%
+ \pgfmathsetlength{\dimen@ii}{\@venn@intersect@i@y-\@venn@Ay}%
+ \ifvennoldpgf
+ \pgfmathatantwo{\dimen@i}{\dimen@ii}%
+ \else
+ \pgfmathatantwo{\dimen@ii}{\dimen@i}%
+ \fi
+ \let\@venn@end@ii@angle\pgfmathresult
+% \pgfmathadd{\@venn@start@ii@angle}{360}%
+% \let\@venn@start@ii@angle\pgfmathresult
+% \end{macrocode}
+% Fill the path
+% \begin{macrocode}
+ \path[fill=\@venn@shade]
+ (\@venn@intersect@i@x,\@venn@intersect@i@y)
+ arc[radius=\@venn@radius,start angle=\@venn@start@i@angle,
+ end angle=\@venn@end@i@angle]
+ arc[radius=\@venn@radius,start angle=\@venn@start@ii@angle,
+ end angle=\@venn@end@ii@angle]
+ -- cycle;
+ \else
+ \fillOnlyB
+ \fi
+}%
+% \end{macrocode}
+%\end{macro}
%\iffalse
% \begin{macrocode}
%</venndiagram.sty>