| 1 |
%\iffalse |
| 2 |
% venndiagram.dtx generated using makedtx version 1.2 (c) Nicola Talbot |
| 3 |
% Command line args: |
| 4 |
% -doc "venndiagram-manual.tex" |
| 5 |
% -author "Nicola Talbot" |
| 6 |
% -src "venndiagram.sty\Z=>venndiagram.sty" |
| 7 |
% venndiagram |
| 8 |
% Created on 2018/6/7 15:50 |
| 9 |
%\fi |
| 10 |
%\iffalse |
| 11 |
%<*package> |
| 12 |
%% \CharacterTable |
| 13 |
%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z |
| 14 |
%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z |
| 15 |
%% Digits \0\1\2\3\4\5\6\7\8\9 |
| 16 |
%% Exclamation \! Double quote \" Hash (number) \# |
| 17 |
%% Dollar \$ Percent \% Ampersand \& |
| 18 |
%% Acute accent \' Left paren \( Right paren \) |
| 19 |
%% Asterisk \* Plus \+ Comma \, |
| 20 |
%% Minus \- Point \. Solidus \/ |
| 21 |
%% Colon \: Semicolon \; Less than \< |
| 22 |
%% Equals \= Greater than \> Question mark \? |
| 23 |
%% Commercial at \@ Left bracket \[ Backslash \\ |
| 24 |
%% Right bracket \] Circumflex \^ Underscore \_ |
| 25 |
%% Grave accent \` Left brace \{ Vertical bar \| |
| 26 |
%% Right brace \} Tilde \~} |
| 27 |
%</package> |
| 28 |
%\fi |
| 29 |
% \iffalse |
| 30 |
% Doc-Source file to use with LaTeX2e |
| 31 |
% Copyright (C) 2018 Nicola Talbot, all rights reserved. |
| 32 |
% \fi |
| 33 |
% \iffalse |
| 34 |
%<*driver> |
| 35 |
\documentclass[widecs]{nlctdoc} |
| 36 |
|
| 37 |
\usepackage{amsmath} |
| 38 |
\usepackage{venndiagram} |
| 39 |
\usepackage{alltt} |
| 40 |
\usepackage[utf8]{inputenc} |
| 41 |
\usepackage[T1]{fontenc} |
| 42 |
\usepackage[colorlinks, |
| 43 |
bookmarks, |
| 44 |
hyperindex=false, |
| 45 |
pdfauthor={Nicola L.C. Talbot}, |
| 46 |
pdftitle={venndiagram.sty: LaTeX2e Package for Drawing Venn Diagrams}, |
| 47 |
pdfkeywords={LaTeX,package,venn diagram}]{hyperref} |
| 48 |
|
| 49 |
\DisableCrossrefs |
| 50 |
|
| 51 |
\setlength\marginparwidth{6pc} |
| 52 |
|
| 53 |
\doxitem{KeyValOption}{keyvaloption}{options} |
| 54 |
|
| 55 |
\CheckSum{2612} |
| 56 |
|
| 57 |
\begin{document} |
| 58 |
\DocInput{venndiagram.dtx} |
| 59 |
\end{document} |
| 60 |
%</driver> |
| 61 |
%\fi |
| 62 |
% |
| 63 |
%\MakeShortVerb{"} |
| 64 |
% |
| 65 |
%\title{venndiagram v1.2: |
| 66 |
%Drawing Simple Venn Diagrams} |
| 67 |
%\author{Nicola L. C. Talbot\\\url{http://www.dickimaw-books.com/}} |
| 68 |
% |
| 69 |
%\date{2018-06-07} |
| 70 |
%\maketitle |
| 71 |
% |
| 72 |
%The \styfmt{venndiagram} package is provided to assist generating |
| 73 |
%simple two- and three-set Venn diagrams for lectures or assignment |
| 74 |
%sheets. This package requires the \sty{tikz} package. |
| 75 |
%As from v1.1, this package no longer requires the |
| 76 |
%\styfmt{intersections} library. |
| 77 |
% |
| 78 |
%\begin{important} |
| 79 |
%The aim of this package is to provide very simple Venn diagrams for |
| 80 |
%assignments or exam questions. If you require more complex diagrams |
| 81 |
%or different layouts it's simpler to directly use the \sty{tikz} package. |
| 82 |
%\end{important} |
| 83 |
% |
| 84 |
%\tableofcontents |
| 85 |
% |
| 86 |
%\section{Available Commands and Environments} |
| 87 |
% |
| 88 |
%This package defines two environments: |
| 89 |
%\begin{definition}[\DescribeEnv{venndiagram3sets}] |
| 90 |
%\cs{begin}\{venndiagram3sets\}\oarg{options} |
| 91 |
%\end{definition} |
| 92 |
%(for two sets) and |
| 93 |
%\begin{definition}[\DescribeEnv{venndiagram2sets}] |
| 94 |
%\cs{begin}\{venndiagram2sets\}\oarg{options} |
| 95 |
%\end{definition} |
| 96 |
%(for three sets). |
| 97 |
% |
| 98 |
%The optional argument \meta{options} is a comma-separated list of |
| 99 |
%\meta{key}=\meta{value} settings. |
| 100 |
% |
| 101 |
%\begin{important} |
| 102 |
%If the \meta{value} contains commas or equal |
| 103 |
%signs, make sure you enclose the entire value in braces. |
| 104 |
%For example: |
| 105 |
%\begin{verbatim} |
| 106 |
%\begin{venndiagram3sets}[tikzoptions={scale=2,thick}] |
| 107 |
%\end{verbatim} |
| 108 |
%\end{important} |
| 109 |
% |
| 110 |
%The following keys are available: |
| 111 |
%\begin{description} |
| 112 |
%\item[shade] The name of the colour used to shade regions (default: |
| 113 |
%\texttt{lightgray}). |
| 114 |
% |
| 115 |
%\item[labelA] The label for the first set (default: \verb|$A$|). |
| 116 |
% |
| 117 |
%\item[labelB] The label for the second set (default: \verb|$B$|). |
| 118 |
% |
| 119 |
%\item[labelC] (Not available for the 2 set version.) The label for the third set (default: \verb|$C$|). |
| 120 |
% |
| 121 |
%\item[labelOnlyA] The label for the region given by $A\setminus(B \cup C)$ (for 3 set version) |
| 122 |
%or $A\setminus B$ (for 2 set version). (Default: empty.) |
| 123 |
% |
| 124 |
%\item[labelOnlyB] The label for the region given by $B\setminus(A \cup C)$ (for 3 set version) |
| 125 |
%or $B\setminus A$ (for 2 set version). (Default: empty.) |
| 126 |
% |
| 127 |
%\item[labelOnlyC] (Not available for 2 set version.) The label for the region given by |
| 128 |
%$C\setminus(A \cup B)$. (Default: empty.) |
| 129 |
% |
| 130 |
%\item[labelOnlyAB] (Not available for 2 set version.) The label for the region given by |
| 131 |
%$(A \cap B) \setminus C$. (Default: empty.) |
| 132 |
% |
| 133 |
%\item[labelOnlyAC] (Not available for 2 set version.) The label for the region given by |
| 134 |
%$(A \cap C)\setminus B$. (Default: empty.) |
| 135 |
% |
| 136 |
%\item[labelOnlyBC] (Not available for 2 set version.) The label for the region given by |
| 137 |
%$(B \cap C)\setminus A$. (Default: empty.) |
| 138 |
% |
| 139 |
%\item[labelABC] (Not available for 2 set version.) The label for the region given by |
| 140 |
%$A \cap B \cap C$. (Default: empty.) |
| 141 |
% |
| 142 |
%\item[labelNotABC] (Not available for 2 set version.) The label for the region given by |
| 143 |
%$(A \cup B \cup C)^c$. (Default: empty.) |
| 144 |
% |
| 145 |
%\item[labelAB] (Not available for 3 set version.) The label for the region given by |
| 146 |
%$A \cap B$. (Default: empty.) |
| 147 |
% |
| 148 |
%\item[labelNotAB] (Not available for 3 set version.) The label for the region given by |
| 149 |
%$(A \cup B)^c$. (Default: empty.) |
| 150 |
% |
| 151 |
%\item[radius] The radius of each set. (Default: 1.2cm.) |
| 152 |
% |
| 153 |
%\item[hgap] The horizontal gap between the outer vertical edge and the |
| 154 |
%nearest set edge. (Default: 0.5cm.) |
| 155 |
% |
| 156 |
%\item[vgap] The vertical gap between the outer horizontal edge and |
| 157 |
%the nearest set edge. (Default: 0.5cm.) |
| 158 |
% |
| 159 |
%\item[overlap] The overlap between the sets. (Default: 0.75cm.) |
| 160 |
% |
| 161 |
%\item[showframe] This is a boolean option (default: \texttt{true}). |
| 162 |
%If \texttt{true}, the surrounding rectangular frame is drawn. If |
| 163 |
%\texttt{false}, the frame isn't drawn but still contributes to the |
| 164 |
%total image size as a hidden path. If the value is omitted |
| 165 |
%\texttt{true} is assumed. |
| 166 |
% |
| 167 |
%\item[tikzoptions] Any options to pass to \env{tikzpicture}. |
| 168 |
% |
| 169 |
%\end{description} |
| 170 |
% |
| 171 |
%Both environments draw the outline of the sets and the rectangular |
| 172 |
%outline of the encompassing universal set. Within the Venn diagram environments |
| 173 |
%commands are provided to shade various regions. (The commands have a |
| 174 |
%cumulative effect, possibly drawing over each other. The set |
| 175 |
%outlines and labels are drawn at the end of the environment.) |
| 176 |
%Available commands are as follows: |
| 177 |
% |
| 178 |
%\begin{definition}[\DescribeMacro{\fillA}] |
| 179 |
%\cs{fillA} |
| 180 |
%\end{definition} |
| 181 |
%Shades set $A$. |
| 182 |
%\begin{definition}[\DescribeMacro{\fillB}] |
| 183 |
%\cs{fillB} |
| 184 |
%\end{definition} |
| 185 |
%Shades set $B$. |
| 186 |
%\begin{definition}[\DescribeMacro{\fillC}] |
| 187 |
%\cs{fillC} |
| 188 |
%\end{definition} |
| 189 |
%(Only for 3 set version.) Shades set $C$. |
| 190 |
% |
| 191 |
%\begin{definition}[\DescribeMacro{\fillAll}] |
| 192 |
%\cs{fillAll} |
| 193 |
%\end{definition} |
| 194 |
%Shades the entire Venn diagram. |
| 195 |
% |
| 196 |
%\begin{definition}[\DescribeMacro{\fillNotABC}] |
| 197 |
%\cs{fillNotABC} |
| 198 |
%\end{definition} |
| 199 |
%(Not available for 2 sets version.) Fills $(A\cup B \cup C)^c$. |
| 200 |
% |
| 201 |
%\begin{definition}[\DescribeMacro{\fillOnlyA}] |
| 202 |
%\cs{fillOnlyA} |
| 203 |
%\end{definition} |
| 204 |
%Shades set $A \setminus (B \cup C)$ (for 3 sets version) |
| 205 |
%or $A \setminus B$ (for 2 sets version). |
| 206 |
%\begin{definition}[\DescribeMacro{\fillOnlyB}] |
| 207 |
%\cs{fillOnlyB} |
| 208 |
%\end{definition} |
| 209 |
%Shades set $B \setminus (A \cup C)$ (for 3 sets version) |
| 210 |
%or $B \setminus A$ (for 2 sets version). |
| 211 |
%\begin{definition}[\DescribeMacro{\fillOnlyC}] |
| 212 |
%\cs{fillOnlyC} |
| 213 |
%\end{definition} |
| 214 |
%(Not available for 2 sets version.) Shades $C \setminus (A \cup B)$. |
| 215 |
% |
| 216 |
%\begin{definition}[\DescribeMacro{\fillNotA}] |
| 217 |
%\cs{fillNotA} |
| 218 |
%\end{definition} |
| 219 |
%Shades everything except $A$ (that is $A^c$). |
| 220 |
%\begin{definition}[\DescribeMacro{\fillNotB}] |
| 221 |
%\cs{fillNotB} |
| 222 |
%\end{definition} |
| 223 |
%Shades everything except $B$ (that is $B^c$). |
| 224 |
%\begin{definition}[\DescribeMacro{\fillNotC}] |
| 225 |
%\cs{fillNotC} |
| 226 |
%\end{definition} |
| 227 |
%(Not available for 2 set version.) Shades everything except $C$ (that is $C^c$). |
| 228 |
% |
| 229 |
%\begin{definition}[\DescribeMacro{\fillNotAorB}] |
| 230 |
%\cs{fillNotAorB} |
| 231 |
%\end{definition} |
| 232 |
%(Not available for 3 set version.) Shades $(A\cup B)^c$ |
| 233 |
%\begin{definition}[\DescribeMacro{\fillNotAorNotB}] |
| 234 |
%\cs{fillNotAorNotB} |
| 235 |
%\end{definition} |
| 236 |
%(Not available for 3 set version.) Shades $(A\cap B)^c$ |
| 237 |
% |
| 238 |
% |
| 239 |
%\begin{definition}[\DescribeMacro{\fillANotB}] |
| 240 |
%\cs{fillANotB} |
| 241 |
%\end{definition} |
| 242 |
%Shades $A\setminus B$. |
| 243 |
%\begin{definition}[\DescribeMacro{\fillBNotA}] |
| 244 |
%\cs{fillBNotA} |
| 245 |
%\end{definition} |
| 246 |
%Shades $B\setminus A$. |
| 247 |
%\begin{definition}[\DescribeMacro{\fillANotC}] |
| 248 |
%\cs{fillANotC} |
| 249 |
%\end{definition} |
| 250 |
%(Not available for 2 set version.) Shades $A\setminus C$. |
| 251 |
%\begin{definition}[\DescribeMacro{\fillCNotA}] |
| 252 |
%\cs{fillCNotA} |
| 253 |
%\end{definition} |
| 254 |
%(Not available for 2 set version.) Shades $C\setminus A$. |
| 255 |
%\begin{definition}[\DescribeMacro{\fillBNotC}] |
| 256 |
%\cs{fillBNotC} |
| 257 |
%\end{definition} |
| 258 |
%(Not available for 2 set version.) Shades $B\setminus C$. |
| 259 |
%\begin{definition}[\DescribeMacro{\fillCNotB}] |
| 260 |
%\cs{fillCNotB} |
| 261 |
%\end{definition} |
| 262 |
%(Not available for 2 set version.) Shades $C\setminus B$. |
| 263 |
% |
| 264 |
%\begin{definition}[\DescribeMacro{\fillACapB}] |
| 265 |
%\cs{fillACapB} |
| 266 |
%\end{definition} |
| 267 |
%Shades $A \cap B$. (\cs{fillBCapA} is equivalent to \cs{fillACapB}.) |
| 268 |
%\begin{definition}[\DescribeMacro{\fillACapC}] |
| 269 |
%\cs{fillACapC} |
| 270 |
%\end{definition} |
| 271 |
%(Not available for 2 set version.) Shades $A \cap C$. (\cs{fillCCapA} is equivalent to \cs{fillACapC}.) |
| 272 |
%\begin{definition}[\DescribeMacro{\fillBCapC}] |
| 273 |
%\cs{fillBCapC} |
| 274 |
%\end{definition} |
| 275 |
%(Not available for 2 set version.) Shades $B \cap C$. (\cs{fillCCapB} is equivalent to \cs{fillBCapC}.) |
| 276 |
% |
| 277 |
%\begin{definition}[\DescribeMacro{\fillACapBNotC}] |
| 278 |
%\cs{fillACapBNotC} |
| 279 |
%\end{definition} |
| 280 |
%(Not available for 2 set version.) Shades $A \cap B \setminus C$. |
| 281 |
%(\cs{fillBCapANotC} is equivalent to \cs{fillACapBNotC}.) |
| 282 |
%\begin{definition}[\DescribeMacro{\fillACapCNotB}] |
| 283 |
%\cs{fillACapCNotB} |
| 284 |
%\end{definition} |
| 285 |
%(Not available for 2 set version.) Shades $A \cap C \setminus B$. |
| 286 |
%(\cs{fillCCapANotB} is equivalent to \cs{fillACapCNotB}.) |
| 287 |
%\begin{definition}[\DescribeMacro{\fillBCapCNotA}] |
| 288 |
%\cs{fillBCapCNotA} |
| 289 |
%\end{definition} |
| 290 |
%(Not available for 2 set version.) Shades $B \cap C \setminus A$. |
| 291 |
%(\cs{fillCCapBNotA} is equivalent to \cs{fillBCapCNotA}.) |
| 292 |
%\begin{definition}[\DescribeMacro{\fillACapBCapC}] |
| 293 |
%\cs{fillACapBCapC} |
| 294 |
%\end{definition} |
| 295 |
%(Not available for 2 set version.) Shades $A \cap B \cap C$. |
| 296 |
%(Synonyms: \cs{fillACapCCapB}, \cs{fillBCapACapC}, \cs{fillBCapCCapA}, |
| 297 |
%\cs{fillCCapACapB}, \cs{fillCCapBCapA}.) |
| 298 |
% |
| 299 |
% |
| 300 |
%\begin{definition}[\DescribeMacro{\setpostvennhook}] |
| 301 |
%\cs{setpostvennhook}\marg{cmds} |
| 302 |
%\end{definition} |
| 303 |
%Sets the hook applied at the very end of the Venn diagram |
| 304 |
%environments (after the outline and labels are drawn but before the |
| 305 |
%end of the \env{tikzpicture} environment). The Venn diagram |
| 306 |
%environments create coordinate nodes \texttt{venn bottom left}, |
| 307 |
%\texttt{venn top left}, \texttt{venn top right} and \texttt{venn |
| 308 |
%bottom right}, which may be referenced within the environment or in |
| 309 |
%the hook. |
| 310 |
% |
| 311 |
%The set labels may also be referenced \emph{but only in |
| 312 |
%\cs{setpostvennhook}}: \texttt{labelOnlyA}, \texttt{labelOnlyB}, |
| 313 |
%\texttt{labelOnlyC} (three set version only), \texttt{labelNotABC} |
| 314 |
%(three set version only), \texttt{labelNotAB} (two set version |
| 315 |
%only), \texttt{labelA}, \texttt{labelB}, \texttt{labelC} (three set |
| 316 |
%version only), \texttt{labelOnlyAB}, \texttt{labelOnlyAC} (three set |
| 317 |
%version only), \texttt{labelOnlyBC} (three set version only) and |
| 318 |
%\texttt{labelAB} (two set version only). |
| 319 |
% |
| 320 |
%\section{Examples} |
| 321 |
% |
| 322 |
%\begin{enumerate} |
| 323 |
%\item (Three sets) $ A \cup B \cup C $ |
| 324 |
% |
| 325 |
%\begin{verbatim} |
| 326 |
%\begin{venndiagram3sets} |
| 327 |
% \fillA \fillB \fillC |
| 328 |
%\end{venndiagram3sets} |
| 329 |
%\end{verbatim} |
| 330 |
%Produces: |
| 331 |
% |
| 332 |
%\begin{venndiagram3sets} |
| 333 |
% \fillA \fillB \fillC |
| 334 |
%\end{venndiagram3sets} |
| 335 |
% |
| 336 |
%\item (Two sets) $ A \cup B $ |
| 337 |
% |
| 338 |
%\begin{verbatim} |
| 339 |
%\begin{venndiagram2sets} |
| 340 |
% \fillA \fillB |
| 341 |
%\end{venndiagram2sets} |
| 342 |
%\end{verbatim} |
| 343 |
%Produces: |
| 344 |
% |
| 345 |
%\begin{venndiagram2sets} |
| 346 |
% \fillA \fillB |
| 347 |
%\end{venndiagram2sets} |
| 348 |
% |
| 349 |
%\item (Three sets) $ A \setminus (B \cup C)$ |
| 350 |
% |
| 351 |
%\begin{verbatim} |
| 352 |
%\begin{venndiagram3sets} |
| 353 |
% \fillOnlyA |
| 354 |
%\end{venndiagram3sets} |
| 355 |
%\end{verbatim} |
| 356 |
%Produces: |
| 357 |
% |
| 358 |
%\begin{venndiagram3sets} |
| 359 |
% \fillOnlyA |
| 360 |
%\end{venndiagram3sets} |
| 361 |
% |
| 362 |
%\item (Two sets) $ A \cap B$: |
| 363 |
% |
| 364 |
%\begin{verbatim} |
| 365 |
%\begin{venndiagram2sets} |
| 366 |
%\fillACapB |
| 367 |
%\end{venndiagram2sets} |
| 368 |
%\end{verbatim} |
| 369 |
% |
| 370 |
%\begin{venndiagram2sets} |
| 371 |
%\fillACapB |
| 372 |
%\end{venndiagram2sets} |
| 373 |
% |
| 374 |
%\item (Three sets) region labels: |
| 375 |
% |
| 376 |
%\begin{verbatim} |
| 377 |
%\begin{venndiagram3sets}[labelOnlyA={1},labelOnlyB={2},labelOnlyC={3}, |
| 378 |
% labelOnlyAB={4},labelOnlyAC={5},labelOnlyBC={6},labelABC={7}, |
| 379 |
% labelNotABC={8}] |
| 380 |
%\end{venndiagram3sets} |
| 381 |
%\end{verbatim} |
| 382 |
%Produces: |
| 383 |
% |
| 384 |
%\begin{venndiagram3sets}[labelOnlyA={1},labelOnlyB={2},labelOnlyC={3}, |
| 385 |
% labelOnlyAB={4},labelOnlyAC={5},labelOnlyBC={6},labelABC={7}, |
| 386 |
% labelNotABC={8}] |
| 387 |
%\end{venndiagram3sets} |
| 388 |
% |
| 389 |
%\item Annotating the diagram: |
| 390 |
% |
| 391 |
%\begin{verbatim} |
| 392 |
%\begin{venndiagram3sets}[labelOnlyA={1},labelOnlyB={2},labelOnlyC={3}, |
| 393 |
% labelOnlyAB={4},labelOnlyAC={5},labelOnlyBC={6},labelABC={7}, |
| 394 |
% labelNotABC={8}] |
| 395 |
%\setpostvennhook |
| 396 |
%{ |
| 397 |
% \draw[<-] (labelA) -- ++(135:3cm) node[above] {Students who eat |
| 398 |
%artichokes}; |
| 399 |
% \draw[<-] (labelB) -- ++(45:3cm) node[above] {Students who eat |
| 400 |
%broccoli}; |
| 401 |
% \draw[<-] (labelC) -- ++(-90:3cm) node[below] {Students who eat |
| 402 |
%carrots}; |
| 403 |
% \draw[<-] (labelABC) -- ++(0:3cm) |
| 404 |
% node[right,text width=4cm,align=flush left] |
| 405 |
% {7 students eat artichokes, broccoli and carrots}; |
| 406 |
% \draw[<-] (labelNotABC) -- ++(-135:3cm) |
| 407 |
% node[below,text width=4cm,align=flush left] |
| 408 |
% {8 students don't eat artichokes, broccoli or carrots}; |
| 409 |
%} |
| 410 |
%\end{venndiagram3sets} |
| 411 |
%\end{verbatim} |
| 412 |
%Produces: |
| 413 |
% |
| 414 |
%\begin{venndiagram3sets}[labelOnlyA={1},labelOnlyB={2},labelOnlyC={3}, |
| 415 |
% labelOnlyAB={4},labelOnlyAC={5},labelOnlyBC={6},labelABC={7}, |
| 416 |
% labelNotABC={8}] |
| 417 |
%\setpostvennhook |
| 418 |
%{ |
| 419 |
% \draw[<-] (labelA) -- ++(135:3cm) node[above] {Students who eat |
| 420 |
%artichokes}; |
| 421 |
% \draw[<-] (labelB) -- ++(45:3cm) node[above] {Students who eat |
| 422 |
%broccoli}; |
| 423 |
% \draw[<-] (labelC) -- ++(-90:3cm) node[below] {Students who eat |
| 424 |
%carrots}; |
| 425 |
% \draw[<-] (labelABC) -- ++(0:3cm) |
| 426 |
% node[right,text width=4cm,align=flush left] |
| 427 |
% {7 students eat artichokes, broccoli and carrots}; |
| 428 |
% \draw[<-] (labelNotABC) -- ++(-135:3cm) |
| 429 |
% node[below,text width=4cm,align=flush left] |
| 430 |
% {8 students don't eat artichokes, broccoli or carrots}; |
| 431 |
%} |
| 432 |
%\end{venndiagram3sets} |
| 433 |
% |
| 434 |
%\end{enumerate} |
| 435 |
% |
| 436 |
%\StopEventually{\PrintIndex} |
| 437 |
% |
| 438 |
% |
| 439 |
%\section{The Code} |
| 440 |
%\iffalse |
| 441 |
% \begin{macrocode} |
| 442 |
%<*venndiagram.sty> |
| 443 |
% \end{macrocode} |
| 444 |
%\fi |
| 445 |
% Package identification: |
| 446 |
% \begin{macrocode} |
| 447 |
\NeedsTeXFormat{LaTeX2e} |
| 448 |
\ProvidesPackage{venndiagram}[2018/06/07 v1.2 (NLCT) Venn diagrams] |
| 449 |
% \end{macrocode} |
| 450 |
% Required packages: |
| 451 |
% \begin{macrocode} |
| 452 |
\RequirePackage{xkeyval} |
| 453 |
\RequirePackage{tikz} |
| 454 |
\RequirePackage{etoolbox} |
| 455 |
% \end{macrocode} |
| 456 |
% TiKZ intersections library no longer needed. (Removed in v1.1) |
| 457 |
%\changes{1.1}{2016-03-16}{removed intersections library} |
| 458 |
% |
| 459 |
% The \sty{pgf} package reversed the order of arguments of |
| 460 |
% \texttt{atan2} in v3.0, which messes things up a bit. |
| 461 |
% In the event that there are users with older versions of |
| 462 |
% \sty{pgf}, backward-compatibility is required. Add a switch to |
| 463 |
% determine which syntax to use. |
| 464 |
%\begin{macro}{\ifvennoldpgf} |
| 465 |
%\changes{1.1}{2016-03-16}{new} |
| 466 |
% If true use old syntax. |
| 467 |
% \begin{macrocode} |
| 468 |
\newif\ifvennoldpgf |
| 469 |
% \end{macrocode} |
| 470 |
%\end{macro} |
| 471 |
% Try to determine this setting. |
| 472 |
% \begin{macrocode} |
| 473 |
\ifdef\pgfversion |
| 474 |
{ |
| 475 |
\def\@venn@checkversion#1.#2\@venn@end@checkversion{% |
| 476 |
\ifnum#1<3 \vennoldpgftrue \else \vennoldpgffalse\fi} |
| 477 |
\expandafter\@venn@checkversion\pgfversion.0\@venn@end@checkversion |
| 478 |
} |
| 479 |
{ |
| 480 |
\vennoldpgftrue |
| 481 |
} |
| 482 |
% \end{macrocode} |
| 483 |
% |
| 484 |
%\subsection{Initialising the Default Values} |
| 485 |
% Set up macros used by the keys for the Venn diagram options. First the |
| 486 |
% default set labels. |
| 487 |
%\begin{macro}{\@venn@label@A} |
| 488 |
% Set $A$: |
| 489 |
% \begin{macrocode} |
| 490 |
\newcommand*{\@venn@label@A}{$A$} |
| 491 |
% \end{macrocode} |
| 492 |
%\end{macro} |
| 493 |
%\begin{macro}{\@venn@label@B} |
| 494 |
% Set $B$: |
| 495 |
% \begin{macrocode} |
| 496 |
\newcommand*{\@venn@label@B}{$B$} |
| 497 |
% \end{macrocode} |
| 498 |
%\end{macro} |
| 499 |
%\begin{macro}{\@venn@label@C} |
| 500 |
% Set $C$: |
| 501 |
% \begin{macrocode} |
| 502 |
\newcommand*{\@venn@label@C}{$C$} |
| 503 |
% \end{macrocode} |
| 504 |
%\end{macro} |
| 505 |
% |
| 506 |
%\begin{macro}{\@venn@shade} |
| 507 |
% The colour used to shade regions. |
| 508 |
% \begin{macrocode} |
| 509 |
\newcommand*{\@venn@shade}{lightgray} |
| 510 |
% \end{macrocode} |
| 511 |
%\end{macro} |
| 512 |
% |
| 513 |
% The default labels for all the other regions are empty. |
| 514 |
%\begin{macro}{\@venn@label@OnlyA} |
| 515 |
% Only set $A$: |
| 516 |
% \begin{macrocode} |
| 517 |
\newcommand*{\@venn@label@OnlyA}{} |
| 518 |
% \end{macrocode} |
| 519 |
%\end{macro} |
| 520 |
%\begin{macro}{\@venn@label@OnlyB} |
| 521 |
% Only set $B$: |
| 522 |
% \begin{macrocode} |
| 523 |
\newcommand*{\@venn@label@OnlyB}{} |
| 524 |
% \end{macrocode} |
| 525 |
%\end{macro} |
| 526 |
%\begin{macro}{\@venn@label@OnlyC} |
| 527 |
% Only set $C$: |
| 528 |
% \begin{macrocode} |
| 529 |
\newcommand*{\@venn@label@OnlyC}{} |
| 530 |
% \end{macrocode} |
| 531 |
%\end{macro} |
| 532 |
%\begin{macro}{\@venn@label@OnlyAB} |
| 533 |
% Sets $A$ and $B$ but not $C$: |
| 534 |
% \begin{macrocode} |
| 535 |
\newcommand*{\@venn@label@OnlyAB}{} |
| 536 |
% \end{macrocode} |
| 537 |
%\end{macro} |
| 538 |
%\begin{macro}{\@venn@label@OnlyAC} |
| 539 |
% Sets $A$ and $C$ but not $B$: |
| 540 |
% \begin{macrocode} |
| 541 |
\newcommand*{\@venn@label@OnlyAC}{} |
| 542 |
% \end{macrocode} |
| 543 |
%\end{macro} |
| 544 |
%\begin{macro}{\@venn@label@OnlyBC} |
| 545 |
% Sets $B$ and $C$ but not $A$: |
| 546 |
% \begin{macrocode} |
| 547 |
\newcommand*{\@venn@label@OnlyBC}{} |
| 548 |
% \end{macrocode} |
| 549 |
%\end{macro} |
| 550 |
%\begin{macro}{\@venn@label@ABC} |
| 551 |
% Intersection of sets $A$, $B$ and $C$: |
| 552 |
% \begin{macrocode} |
| 553 |
\newcommand*{\@venn@label@ABC}{} |
| 554 |
% \end{macrocode} |
| 555 |
%\end{macro} |
| 556 |
%\begin{macro}{\@venn@label@NotABC} |
| 557 |
% Everything except $A$, $B$ or $C$: |
| 558 |
% \begin{macrocode} |
| 559 |
\newcommand*{\@venn@label@NotABC}{} |
| 560 |
% \end{macrocode} |
| 561 |
%\end{macro} |
| 562 |
%\begin{macro}{\@venn@label@NotAB} |
| 563 |
% Everything except $A$ or $B$ (two set version only): |
| 564 |
% \begin{macrocode} |
| 565 |
\newcommand*{\@venn@label@NotAB}{} |
| 566 |
% \end{macrocode} |
| 567 |
%\end{macro} |
| 568 |
%\begin{macro}{\@venn@label@AB} |
| 569 |
% Intersection of $A$ and $B$ (two set version only): |
| 570 |
% \begin{macrocode} |
| 571 |
\newcommand*{\@venn@label@AB}{} |
| 572 |
% \end{macrocode} |
| 573 |
%\end{macro} |
| 574 |
% |
| 575 |
% Now the default dimensions of the diagrams. |
| 576 |
%\begin{macro}{\@venn@radius} |
| 577 |
% The radius of the sets. |
| 578 |
% \begin{macrocode} |
| 579 |
\newcommand*{\@venn@radius}{1.2cm} |
| 580 |
% \end{macrocode} |
| 581 |
%\end{macro} |
| 582 |
%\begin{macro}{\@venn@hgap} |
| 583 |
% The horizontal distance between the edge of the diagram and the |
| 584 |
% outer edge of the nearest set. |
| 585 |
% \begin{macrocode} |
| 586 |
\newcommand*{\@venn@hgap}{0.5cm} |
| 587 |
% \end{macrocode} |
| 588 |
%\end{macro} |
| 589 |
%\begin{macro}{\@venn@vgap} |
| 590 |
% \begin{macrocode} |
| 591 |
% The vertical distance between the edge of the diagram and the |
| 592 |
% outer edge of the nearest set. |
| 593 |
\newcommand*{\@venn@vgap}{0.5cm} |
| 594 |
% \end{macrocode} |
| 595 |
%\end{macro} |
| 596 |
%\begin{macro}{\@venn@overlap} |
| 597 |
% The size of the set overlap. |
| 598 |
% \begin{macrocode} |
| 599 |
\newcommand*{\@venn@overlap}{0.75cm} |
| 600 |
% \end{macrocode} |
| 601 |
%\end{macro} |
| 602 |
% |
| 603 |
%\begin{macro}{\@venn@tikzoptions} |
| 604 |
% Any options to be passed to the \env{tikzpicture} environment. |
| 605 |
% \begin{macrocode} |
| 606 |
\newcommand*{\@venn@tikzoptions}{} |
| 607 |
% \end{macrocode} |
| 608 |
%\end{macro} |
| 609 |
% |
| 610 |
% Lengths to store the centres of the sets and the overall width and |
| 611 |
% height of the diagram. |
| 612 |
%\begin{macro}{\@venn@Ax} |
| 613 |
% The $x$-coordinate of set $A$: |
| 614 |
% \begin{macrocode} |
| 615 |
\newlength\@venn@Ax |
| 616 |
% \end{macrocode} |
| 617 |
%\end{macro} |
| 618 |
%\begin{macro}{\@venn@Ay} |
| 619 |
% The $y$-coordinate of set $A$: |
| 620 |
% \begin{macrocode} |
| 621 |
\newlength\@venn@Ay |
| 622 |
% \end{macrocode} |
| 623 |
%\end{macro} |
| 624 |
%\begin{macro}{\@venn@Bx} |
| 625 |
% The $x$-coordinate of set $B$: |
| 626 |
% \begin{macrocode} |
| 627 |
\newlength\@venn@Bx |
| 628 |
% \end{macrocode} |
| 629 |
%\end{macro} |
| 630 |
%\begin{macro}{\@venn@By} |
| 631 |
% The $y$-coordinate of set $B$: |
| 632 |
% \begin{macrocode} |
| 633 |
\newlength\@venn@By |
| 634 |
% \end{macrocode} |
| 635 |
%\end{macro} |
| 636 |
%\begin{macro}{\@venn@Cx} |
| 637 |
% The $x$-coordinate of set $C$: |
| 638 |
% \begin{macrocode} |
| 639 |
\newlength\@venn@Cx |
| 640 |
% \end{macrocode} |
| 641 |
%\end{macro} |
| 642 |
%\begin{macro}{\@venn@Cy} |
| 643 |
% The $y$-coordinate of set $C$: |
| 644 |
% \begin{macrocode} |
| 645 |
\newlength\@venn@Cy |
| 646 |
% \end{macrocode} |
| 647 |
%\end{macro} |
| 648 |
% |
| 649 |
%\begin{macro}{\@venn@w} |
| 650 |
% The width of the entire Venn diagram. |
| 651 |
% \begin{macrocode} |
| 652 |
\newlength\@venn@w |
| 653 |
% \end{macrocode} |
| 654 |
%\end{macro} |
| 655 |
%\begin{macro}{\@venn@h} |
| 656 |
% The height of the entire Venn diagram. |
| 657 |
% \begin{macrocode} |
| 658 |
\newlength\@venn@h |
| 659 |
% \end{macrocode} |
| 660 |
%\end{macro} |
| 661 |
% |
| 662 |
%\subsection{Defining the key=value Options} |
| 663 |
% |
| 664 |
% Now define the keys for the optional argument of |
| 665 |
% \env{venndiagram2sets} and \env{venndiagram3sets}. |
| 666 |
% They are all in the family "venn". |
| 667 |
% |
| 668 |
%\begin{keyvaloption}{shade} |
| 669 |
% Option to set the shading. |
| 670 |
% \begin{macrocode} |
| 671 |
\define@key{venn}{shade}{\def\@venn@shade{#1}} |
| 672 |
% \end{macrocode} |
| 673 |
%\end{keyvaloption} |
| 674 |
%\begin{keyvaloption}{labelA} |
| 675 |
% Option to set the label for set $A$. |
| 676 |
% \begin{macrocode} |
| 677 |
\define@key{venn}{labelA}{\def\@venn@label@A{#1}} |
| 678 |
% \end{macrocode} |
| 679 |
%\end{keyvaloption} |
| 680 |
%\begin{keyvaloption}{labelB} |
| 681 |
% Option to set the label for set $B$. |
| 682 |
% \begin{macrocode} |
| 683 |
\define@key{venn}{labelB}{\def\@venn@label@B{#1}} |
| 684 |
% \end{macrocode} |
| 685 |
%\end{keyvaloption} |
| 686 |
%\begin{keyvaloption}{labelC} |
| 687 |
% Option to set the label for set $C$. |
| 688 |
% \begin{macrocode} |
| 689 |
\define@key{venn}{labelC}{\def\@venn@label@C{#1}} |
| 690 |
% \end{macrocode} |
| 691 |
%\end{keyvaloption} |
| 692 |
% |
| 693 |
% Now for the region labels. |
| 694 |
% |
| 695 |
%\begin{keyvaloption}{labelOnlyA} |
| 696 |
% Option to set the label for only set $A$. |
| 697 |
% \begin{macrocode} |
| 698 |
\define@key{venn}{labelOnlyA}{\def\@venn@label@OnlyA{#1}} |
| 699 |
% \end{macrocode} |
| 700 |
%\end{keyvaloption} |
| 701 |
%\begin{keyvaloption}{labelOnlyB} |
| 702 |
% Option to set the label for only set $B$. |
| 703 |
% \begin{macrocode} |
| 704 |
\define@key{venn}{labelOnlyB}{\def\@venn@label@OnlyB{#1}} |
| 705 |
% \end{macrocode} |
| 706 |
%\end{keyvaloption} |
| 707 |
%\begin{keyvaloption}{labelOnlyC} |
| 708 |
% Option to set the label for only set $C$. |
| 709 |
% \begin{macrocode} |
| 710 |
\define@key{venn}{labelOnlyC}{\def\@venn@label@OnlyC{#1}} |
| 711 |
% \end{macrocode} |
| 712 |
%\end{keyvaloption} |
| 713 |
%\begin{keyvaloption}{labelOnlyAB} |
| 714 |
% Option to set the label for the intersection of $A$ and $B$. |
| 715 |
% \begin{macrocode} |
| 716 |
\define@key{venn}{labelOnlyAB}{\def\@venn@label@OnlyAB{#1}} |
| 717 |
% \end{macrocode} |
| 718 |
%\end{keyvaloption} |
| 719 |
%\begin{keyvaloption}{labelOnlyAC} |
| 720 |
% Option to set the label for the intersection of $A$ and $C$. |
| 721 |
% \begin{macrocode} |
| 722 |
\define@key{venn}{labelOnlyAC}{\def\@venn@label@OnlyAC{#1}} |
| 723 |
% \end{macrocode} |
| 724 |
%\end{keyvaloption} |
| 725 |
%\begin{keyvaloption}{labelOnlyBC} |
| 726 |
% Option to set the label for the intersection of $B$ and $C$. |
| 727 |
% \begin{macrocode} |
| 728 |
\define@key{venn}{labelOnlyBC}{\def\@venn@label@OnlyBC{#1}} |
| 729 |
% \end{macrocode} |
| 730 |
%\end{keyvaloption} |
| 731 |
%\begin{keyvaloption}{labelABC} |
| 732 |
% Option to set the label for the intersection of $A$, $B$ and $C$. |
| 733 |
% (Three set version only) |
| 734 |
% \begin{macrocode} |
| 735 |
\define@key{venn}{labelABC}{\def\@venn@label@ABC{#1}} |
| 736 |
% \end{macrocode} |
| 737 |
%\end{keyvaloption} |
| 738 |
%\begin{keyvaloption}{labelNotABC} |
| 739 |
% Option to set the label for the region outside the three sets. |
| 740 |
% (Three set version only) |
| 741 |
% \begin{macrocode} |
| 742 |
\define@key{venn}{labelNotABC}{\def\@venn@label@NotABC{#1}} |
| 743 |
% \end{macrocode} |
| 744 |
%\end{keyvaloption} |
| 745 |
%\begin{keyvaloption}{labelAB} |
| 746 |
% Option to set the label for the intersection of $A$ and $B$. |
| 747 |
% (Two set version only) |
| 748 |
% \begin{macrocode} |
| 749 |
\define@key{venn}{labelAB}{\def\@venn@label@AB{#1}} |
| 750 |
% \end{macrocode} |
| 751 |
%\end{keyvaloption} |
| 752 |
%\begin{keyvaloption}{labelNotAB} |
| 753 |
% Option to set the label for the region outside the two sets. |
| 754 |
% (Two set version only) |
| 755 |
% \begin{macrocode} |
| 756 |
\define@key{venn}{labelNotAB}{\def\@venn@label@NotAB{#1}} |
| 757 |
% \end{macrocode} |
| 758 |
%\end{keyvaloption} |
| 759 |
% |
| 760 |
% Now for the dimension options. |
| 761 |
% |
| 762 |
%\begin{keyvaloption}{radius} |
| 763 |
% Option to set the radius. |
| 764 |
% \begin{macrocode} |
| 765 |
\define@key{venn}{radius}{\def\@venn@radius{#1}} |
| 766 |
% \end{macrocode} |
| 767 |
%\end{keyvaloption} |
| 768 |
%\begin{keyvaloption}{hgap} |
| 769 |
% Option to set the horizontal gap between the outer edge of the |
| 770 |
% diagram and the nearest set edge. |
| 771 |
% \begin{macrocode} |
| 772 |
\define@key{venn}{hgap}{\def\@venn@hgap{#1}} |
| 773 |
% \end{macrocode} |
| 774 |
%\end{keyvaloption} |
| 775 |
%\begin{keyvaloption}{vgap} |
| 776 |
% Option to set the vertical gap between the outer edge of the |
| 777 |
% diagram and the nearest set edge. |
| 778 |
% \begin{macrocode} |
| 779 |
\define@key{venn}{vgap}{\def\@venn@vgap{#1}} |
| 780 |
% \end{macrocode} |
| 781 |
%\end{keyvaloption} |
| 782 |
%\begin{keyvaloption}{overlap} |
| 783 |
% Option to set the set overlap. |
| 784 |
% \begin{macrocode} |
| 785 |
\define@key{venn}{overlap}{\def\@venn@overlap{#1}} |
| 786 |
% \end{macrocode} |
| 787 |
%\end{keyvaloption} |
| 788 |
%\begin{keyvaloption}{showframe} |
| 789 |
% Draw the frame outline. |
| 790 |
%\changes{1.2}{2018-06-07}{added showframe option} |
| 791 |
% \begin{macrocode} |
| 792 |
\define@boolkey{venn}[venn]{showframe}[true]{} |
| 793 |
\vennshowframetrue |
| 794 |
% \end{macrocode} |
| 795 |
%\end{keyvaloption} |
| 796 |
% |
| 797 |
% Finally the option to set the information to pass to the |
| 798 |
% \env{tikzpicture} environment. |
| 799 |
%\begin{keyvaloption}{tikzoptions} |
| 800 |
% \begin{macrocode} |
| 801 |
\define@key{venn}{tikzoptions}{\def\@venn@tikzoptions{#1}} |
| 802 |
% \end{macrocode} |
| 803 |
%\end{keyvaloption} |
| 804 |
% |
| 805 |
%\subsection{Circle Intersection} |
| 806 |
% Previously commands like \cs{fillOnlyA} used \sty{pgf} path operations |
| 807 |
% to compute the intersection points of the circles, but the code |
| 808 |
% didn't work properly when the co-ordinate system has been scaled. |
| 809 |
% Version 1.1 changes this to calculate the co-ordinates in a more |
| 810 |
% low-level way. We have two circles centred on $(a_x, a_y)$ and |
| 811 |
% $(b_x, b_y)$ both with radius $r$. This gives the equations: |
| 812 |
%\begin{align} |
| 813 |
%(x-a_x)^2+(y-a_y)^2 &= r^2\label{eq:A}\\ |
| 814 |
%(x-b_x)^2+(y-b_y)^2 &= r^2 |
| 815 |
%\end{align} |
| 816 |
%Combining: |
| 817 |
%\begin{equation} |
| 818 |
%(x-a_x)^2-(x-b_x)^2+(y-a_y)^2-(y-b_y)^2 = 0\label{eq:chord} |
| 819 |
%\end{equation} |
| 820 |
%Re-arranging gives the equation of the chord between the two points |
| 821 |
%of intersection: |
| 822 |
%\[ |
| 823 |
%x(b_x-a_x)+y(b_y-a_y) = \frac{b_x^2-a_x^2+b_y^2-a_y^2}{2} |
| 824 |
%\] |
| 825 |
%Special cases: |
| 826 |
%\begin{enumerate} |
| 827 |
%\item $b_x=a_x$ (circles vertically stacked): |
| 828 |
%\[y(b_y-a_y) = \frac{b_y^2-a_y^2}{2}\] |
| 829 |
%Rearranging gives $y=\frac{1}{2}(b_y+a_y)$. Substituting into |
| 830 |
%\eqref{eq:A}: |
| 831 |
%\begin{align*} |
| 832 |
%(x-a_x)^2+\left(\frac{1}{2}(b_y+a_y)-a_y\right)^2 &= r^2\\ |
| 833 |
%(x-a_x)^2+\frac{1}{4}(b_y-a_y)^2 &= r^2\\ |
| 834 |
%x^2 - 2x a_x + a_x^2+\frac{(b_y-a_y)^2}{4} -r^2 &=0 |
| 835 |
%\end{align*} |
| 836 |
%This is a quadratic equation in $x$ with solutions given by |
| 837 |
%\begin{align*} |
| 838 |
%x &= a_x\pm\sqrt{a_x^2-\left(a_x^2+\frac{(b_y-a_y)^2}{4}-r^2\right)}\\ |
| 839 |
%&= a_x\pm\sqrt{r^2-\frac{1}{4}(b_y-a_y)^2} |
| 840 |
%\end{align*} |
| 841 |
%If $r^2 < \frac{1}{4}(b_y-a_y)^2$ then no solution exists (circles |
| 842 |
%don't overlap). If $r^2 = \frac{1}{4}(b_y-a_y)^2$ then there's only |
| 843 |
%one point of intersection. |
| 844 |
%\item $b_y=a_y$ (circles horizontally aligned): |
| 845 |
%\[x(b_x-a_x) = \frac{b_x^2-a_x^2}{2} \] |
| 846 |
%Rearranging gives $x=\frac{1}{2}(b_x+a_x)$. Substituting into |
| 847 |
%\eqref{eq:A}: |
| 848 |
%\begin{align*} |
| 849 |
%\left(\frac{b_x+a_x}{2}-a_x\right)^2+(y-a_y)^2 &= r^2\\ |
| 850 |
%\frac{1}{4}(b_x-a_x)^2+(y-a_y)^2 &= r^2\\ |
| 851 |
%y^2 - 2ya_y+a_y^2+\frac{1}{4}(b_x-a_x)^2-r^2 &= 0 |
| 852 |
%\end{align*} |
| 853 |
%This is a quadratic equation in $y$ with solutions given by |
| 854 |
%\begin{align*} |
| 855 |
%y &= a_y\pm\sqrt{a_y^2-\left(a_y^2+\frac{(b_x-a_x)^2}{4}-r^2\right)}\\ |
| 856 |
%&= a_y\pm\sqrt{r^2-\frac{1}{4}(b_x-a_x)^2} |
| 857 |
%\end{align*} |
| 858 |
%If $r^2 < \frac{1}{4}(b_x-a_x)^2$ then no solution exists (circles |
| 859 |
%don't overlap). If $r^2 = \frac{1}{4}(b_x-a_x)^2$ then there's only |
| 860 |
%one point of intersection. |
| 861 |
%\end{enumerate} |
| 862 |
%The general case has the chord given by equation~\eqref{eq:chord}, |
| 863 |
%which can be rewritten in the form $y = mx + c$ where |
| 864 |
%\begin{align*} |
| 865 |
% m &= \frac{a_x-b_x}{b_y-a_y}\\ |
| 866 |
% c &= \frac{b_x^2-a_x^2+b_y^2-a_y^2}{2(b_y-a_y)} |
| 867 |
%\end{align*} |
| 868 |
%Substituting into equation~\eqref{eq:A}: |
| 869 |
%\[ |
| 870 |
%(x-a_x)^2+((mx+c)-a_y)^2 = r^2 |
| 871 |
%\] |
| 872 |
%Rearranging: |
| 873 |
%\begin{displaymath} |
| 874 |
%(1+m^2)x^2+2x(mc-a_x-a_ym)+a_x^2+c^2-2a_yc+a_y^2-r^2 = 0 |
| 875 |
%\end{displaymath} |
| 876 |
%This is a quadratic solution in $x$ with solutions given by |
| 877 |
%\[ |
| 878 |
%x = \frac{-(mc-a_x-a_ym)\pm |
| 879 |
%\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} |
| 880 |
%\] |
| 881 |
% |
| 882 |
%Provide command to compute the intersection of two circles of the |
| 883 |
%same radius (given by \cs{@venn@radius}. |
| 884 |
%\begin{macro}{\@venn@computecircleintersects} |
| 885 |
%The four arguments are $a_x$, $a_y$, $b_x$ and $b_y$ (the centre |
| 886 |
%co-ordinates in lengths). The results are stored in \cs{@venn@intersect@i@x}, |
| 887 |
% \cs{@venn@intersect@i@y}, \cs{@venn@intersect@ii@x} and |
| 888 |
% \cs{@venn@intersect@ii@y}. The number of intersects (0, 1 or 2) |
| 889 |
% is stored in \cs{@venn@intersect@n}. |
| 890 |
% \begin{macrocode} |
| 891 |
\newcommand*{\@venn@computecircleintersects}[4]{% |
| 892 |
\ifdim#1=#3\relax |
| 893 |
% \end{macrocode} |
| 894 |
% Case 1 ($a_x = b_x$). Compute $y = \frac{1}{2}(b_y+a_y)$. |
| 895 |
% \begin{macrocode} |
| 896 |
\pgfmathsetlength{\@venn@intersect@i@y}{0.5*(#4+#2)}% |
| 897 |
\setlength{\@venn@intersect@ii@y}{\@venn@intersect@i@y}% |
| 898 |
% \end{macrocode} |
| 899 |
% Compute $r^2 - \frac{1}{4}(b_y-a_y)^2$ |
| 900 |
% \begin{macrocode} |
| 901 |
\pgfmathsetlength{\dimen@i}{#4-#2}% |
| 902 |
\pgfmathsetlength{\dimen@}{\@venn@radius*\@[email protected]*\dimen@i*\dimen@i}% |
| 903 |
\setlength{\@venn@intersect@i@x}{#1}% |
| 904 |
\setlength{\@venn@intersect@ii@x}{#1}% |
| 905 |
\ifdim\dimen@=0pt\relax |
| 906 |
% \end{macrocode} |
| 907 |
% One point of intersection. |
| 908 |
% \begin{macrocode} |
| 909 |
\def\@venn@intersect@n{1}% |
| 910 |
\else |
| 911 |
\ifdim\dimen@>0pt\relax |
| 912 |
% \end{macrocode} |
| 913 |
% Two points of intersection. |
| 914 |
% \begin{macrocode} |
| 915 |
\def\@venn@intersect@n{2}% |
| 916 |
\pgfmathsetlength{\dimen@i}{sqrt(\dimen@)}% |
| 917 |
\addtolength{\@venn@intersect@i@x}{\dimen@i}% |
| 918 |
\addtolength{\@venn@intersect@ii@x}{-\dimen@i}% |
| 919 |
\else |
| 920 |
% \end{macrocode} |
| 921 |
% No intersection. |
| 922 |
% \begin{macrocode} |
| 923 |
\def\@venn@intersect@n{0}% |
| 924 |
\fi |
| 925 |
\fi |
| 926 |
\else |
| 927 |
\ifdim#2=#4\relax |
| 928 |
% \end{macrocode} |
| 929 |
% Case 2 ($a_y = b_y$). Compute $x = \frac{1}{2}(b_x+a_x)$ |
| 930 |
% \begin{macrocode} |
| 931 |
\pgfmathsetlength{\@venn@intersect@i@x}{0.5*(#3+#1)}% |
| 932 |
\setlength{\@venn@intersect@ii@x}{\@venn@intersect@i@x}% |
| 933 |
% \end{macrocode} |
| 934 |
% Compute $r^2 - \frac{1}{4}(b_x-a_x)^2$ |
| 935 |
% \begin{macrocode} |
| 936 |
\setlength{\dimen@i}{#3}% |
| 937 |
\addtolength{\dimen@i}{-#1}% |
| 938 |
\pgfmathsetlength{\dimen@}{\@venn@radius*\@venn@radius |
| 939 |
-0.25*\dimen@i*\dimen@i}% |
| 940 |
\setlength{\@venn@intersect@i@y}{#2}% |
| 941 |
\setlength{\@venn@intersect@ii@y}{#2}% |
| 942 |
\ifdim\dimen@=0pt\relax |
| 943 |
% \end{macrocode} |
| 944 |
% One point of intersection. |
| 945 |
% \begin{macrocode} |
| 946 |
\def\@venn@intersect@n{1}% |
| 947 |
\else |
| 948 |
\ifdim\dimen@>0pt\relax |
| 949 |
% \end{macrocode} |
| 950 |
% Two points of intersection. |
| 951 |
% \begin{macrocode} |
| 952 |
\def\@venn@intersect@n{2}% |
| 953 |
\pgfmathsetlength{\dimen@i}{sqrt(\dimen@)}% |
| 954 |
\addtolength{\@venn@intersect@i@y}{\dimen@i}% |
| 955 |
\addtolength{\@venn@intersect@ii@y}{-\dimen@i}% |
| 956 |
\else |
| 957 |
% \end{macrocode} |
| 958 |
% No intersection. |
| 959 |
% \begin{macrocode} |
| 960 |
\def\@venn@intersect@n{0}% |
| 961 |
\fi |
| 962 |
\fi |
| 963 |
\else |
| 964 |
% \end{macrocode} |
| 965 |
% General case. Convert all lengths to scalar to reduce chances of |
| 966 |
% exceeding max dimension. Using inches to ensure more reasonable |
| 967 |
% values. |
| 968 |
% \begin{macrocode} |
| 969 |
\pgfmathparse{#1/72.27}\let\@vnn@ax\pgfmathresult |
| 970 |
\pgfmathparse{#2/72.27}\let\@vnn@ay\pgfmathresult |
| 971 |
\pgfmathparse{#3/72.27}\let\@vnn@bx\pgfmathresult |
| 972 |
\pgfmathparse{#4/72.27}\let\@vnn@by\pgfmathresult |
| 973 |
\pgfmathparse{\@venn@radius/72.27}\let\@vnn@r\pgfmathresult |
| 974 |
\pgfmathparse{\@vnn@ax*\@vnn@ax}\let\@vnn@ax@sq\pgfmathresult |
| 975 |
\pgfmathparse{\@vnn@ay*\@vnn@ay}\let\@vnn@ay@sq\pgfmathresult |
| 976 |
\pgfmathparse{\@vnn@bx*\@vnn@bx}\let\@vnn@bx@sq\pgfmathresult |
| 977 |
\pgfmathparse{\@vnn@by*\@vnn@by}\let\@vnn@by@sq\pgfmathresult |
| 978 |
\pgfmathparse{\@vnn@r*\@vnn@r}\let\@vnn@r@sq\pgfmathresult |
| 979 |
% \end{macrocode} |
| 980 |
% Set |
| 981 |
%\[c = \frac{b_x^2-a_x^2+b_y^2-a_y^2}{2(b_y-a_y)}\] |
| 982 |
% \begin{macrocode} |
| 983 |
\pgfmathparse{0.5*(\@vnn@bx@sq-\@vnn@ax@sq+\@vnn@by@sq-\@vnn@ay@sq) |
| 984 |
/(\@vnn@by-\@vnn@ay)}% |
| 985 |
\let\@vnn@c\pgfmathresult |
| 986 |
% \end{macrocode} |
| 987 |
% Set |
| 988 |
%\[m = \frac{a_x-b_x}{b_y-a_y}\] |
| 989 |
% \begin{macrocode} |
| 990 |
\pgfmathparse{(\@vnn@ax-\@vnn@bx)/(\@vnn@by-\@vnn@ay)}% |
| 991 |
\let\@vnn@m\pgfmathresult |
| 992 |
% \end{macrocode} |
| 993 |
% Compute $(1+m^2)$. |
| 994 |
% \begin{macrocode} |
| 995 |
\pgfmathparse{1+\@vnn@m*\@vnn@m}% |
| 996 |
\let\@vnn@one@plus@m@sq\pgfmathresult |
| 997 |
% \end{macrocode} |
| 998 |
% Compute \[mc-a_x-a_ym = m(c-a_y)-a_x\] |
| 999 |
% \begin{macrocode} |
| 1000 |
\pgfmathparse{\@vnn@m*(\@vnn@c-\@vnn@ay)-\@vnn@ax}% |
| 1001 |
\let\@vnn@b\pgfmathresult |
| 1002 |
% \end{macrocode} |
| 1003 |
% Denote this value $b$ and now compute |
| 1004 |
% \[b^2-(1+m^2)(a_x^2+a_y^2+c^2-2a_yc-r^2)\] |
| 1005 |
% \begin{macrocode} |
| 1006 |
\pgfmathparse{\@vnn@b*\@vnn@b |
| 1007 |
- \@vnn@one@plus@m@sq |
| 1008 |
*(\@vnn@ax@sq+\@vnn@ay@sq+\@vnn@c*\@vnn@c |
| 1009 |
-2*\@vnn@ay*\@vnn@c-\@vnn@r@sq)}% |
| 1010 |
\let\@vnn@root\pgfmathresult |
| 1011 |
\setlength\dimen@{\pgfmathresult in}% |
| 1012 |
\ifdim\dimen@=0pt\relax |
| 1013 |
% \end{macrocode} |
| 1014 |
% One point of intersection. |
| 1015 |
% \begin{macrocode} |
| 1016 |
\def\@venn@intersect@n{1}% |
| 1017 |
% \end{macrocode} |
| 1018 |
%\[x_1 = \frac{-b}{1+m^2}\] |
| 1019 |
% \begin{macrocode} |
| 1020 |
\pgfmathparse{-\@vnn@b/\@vnn@one@plus@m@sq}% |
| 1021 |
\setlength{\@venn@intersect@i@x}{\pgfmathresult in}% |
| 1022 |
\setlength{\@venn@intersect@ii@x}{\@venn@intersect@i@x}% |
| 1023 |
% \end{macrocode} |
| 1024 |
%\[y_1 = mx_1 + c\] |
| 1025 |
% \begin{macrocode} |
| 1026 |
\pgfmathparse{\pgfmathresult*\@vnn@m+c}% |
| 1027 |
\setlength{\@venn@intersect@i@y}{\pgfmathresult in}% |
| 1028 |
\setlength{\@venn@intersect@ii@y}{\@venn@intesect@i@y}% |
| 1029 |
\else |
| 1030 |
\ifdim\dimen@>0pt\relax |
| 1031 |
% \end{macrocode} |
| 1032 |
% Two points of intersection. |
| 1033 |
% \begin{macrocode} |
| 1034 |
\def\@venn@intersect@n{2}% |
| 1035 |
\pgfmathsqrt{\@vnn@root}% |
| 1036 |
\let\@vnn@root\pgfmathresult |
| 1037 |
% \end{macrocode} |
| 1038 |
% First point. |
| 1039 |
% \begin{macrocode} |
| 1040 |
\pgfmathparse{(-\@vnn@b+\@vnn@root)/\@vnn@one@plus@m@sq}% |
| 1041 |
\setlength{\@venn@intersect@i@x}{\pgfmathresult in}% |
| 1042 |
\pgfmathparse{\pgfmathresult*\@vnn@m+\@vnn@c}% |
| 1043 |
\setlength{\@venn@intersect@i@y}{\pgfmathresult in}% |
| 1044 |
% \end{macrocode} |
| 1045 |
% Second point. |
| 1046 |
% \begin{macrocode} |
| 1047 |
\pgfmathparse{(-\@vnn@b-\@vnn@root)/\@vnn@one@plus@m@sq}% |
| 1048 |
\setlength{\@venn@intersect@ii@x}{\pgfmathresult in}% |
| 1049 |
\pgfmathparse{\pgfmathresult*\@vnn@m+\@vnn@c}% |
| 1050 |
\setlength{\@venn@intersect@ii@y}{\pgfmathresult in}% |
| 1051 |
\else |
| 1052 |
% \end{macrocode} |
| 1053 |
% No intersection. |
| 1054 |
% \begin{macrocode} |
| 1055 |
\def\@venn@intersect@n{0}% |
| 1056 |
\fi |
| 1057 |
\fi |
| 1058 |
\fi |
| 1059 |
\fi |
| 1060 |
} |
| 1061 |
% \end{macrocode} |
| 1062 |
%\end{macro} |
| 1063 |
% |
| 1064 |
%\begin{macro}{\@venn@intersect@i@x} |
| 1065 |
%\changes{1.1}{2016-03-16}{new} |
| 1066 |
% \begin{macrocode} |
| 1067 |
\newlength\@venn@intersect@i@x |
| 1068 |
% \end{macrocode} |
| 1069 |
%\end{macro} |
| 1070 |
% |
| 1071 |
%\begin{macro}{\@venn@intersect@i@y} |
| 1072 |
%\changes{1.1}{2016-03-16}{new} |
| 1073 |
% \begin{macrocode} |
| 1074 |
\newlength\@venn@intersect@i@y |
| 1075 |
% \end{macrocode} |
| 1076 |
%\end{macro} |
| 1077 |
% |
| 1078 |
%\begin{macro}{\@venn@intersect@ii@x} |
| 1079 |
%\changes{1.1}{2016-03-16}{new} |
| 1080 |
% \begin{macrocode} |
| 1081 |
\newlength\@venn@intersect@ii@x |
| 1082 |
% \end{macrocode} |
| 1083 |
%\end{macro} |
| 1084 |
% |
| 1085 |
%\begin{macro}{\@venn@intersect@ii@y} |
| 1086 |
%\changes{1.1}{2016-03-16}{new} |
| 1087 |
% \begin{macrocode} |
| 1088 |
\newlength\@venn@intersect@ii@y |
| 1089 |
% \end{macrocode} |
| 1090 |
%\end{macro} |
| 1091 |
% |
| 1092 |
%\subsection{Environment Definitions} |
| 1093 |
% |
| 1094 |
%\begin{environment}{venndiagram3sets} |
| 1095 |
% Environment to draw Venn diagram with three sets. |
| 1096 |
% \begin{macrocode} |
| 1097 |
\newenvironment{venndiagram3sets}[1][]% |
| 1098 |
{% |
| 1099 |
% \end{macrocode} |
| 1100 |
% Disable the keys that aren't applicable. |
| 1101 |
% \begin{macrocode} |
| 1102 |
\disable@keys{venn}{labelAB,labelNotAB}% |
| 1103 |
% \end{macrocode} |
| 1104 |
% Set the key values given in the optional argument. |
| 1105 |
% \begin{macrocode} |
| 1106 |
\setkeys{venn}{#1}% |
| 1107 |
% \end{macrocode} |
| 1108 |
% Calculate centre of set $C$ |
| 1109 |
% \begin{macrocode} |
| 1110 |
\pgfmathsetlength{\@venn@Cx}{\@venn@hgap + 2*\@venn@radius |
| 1111 |
-0.5*\@venn@overlap}% |
| 1112 |
\pgfmathsetlength{\@venn@Cy}{\@venn@vgap+\@venn@radius}% |
| 1113 |
% \end{macrocode} |
| 1114 |
% Calculate centre of set $A$ |
| 1115 |
% \begin{macrocode} |
| 1116 |
\pgfmathsetlength{\@venn@Ax}{\@venn@hgap+\@venn@radius}% |
| 1117 |
\pgfmathsetlength{\@venn@Ay}{\@venn@Cy |
| 1118 |
+ (\@venn@radius - 0.5*\@venn@overlap)*1.73205}% |
| 1119 |
% \end{macrocode} |
| 1120 |
% Calculate centre of set $B$ |
| 1121 |
% \begin{macrocode} |
| 1122 |
\pgfmathsetlength{\@venn@Bx}{\@venn@hgap+3*\@venn@radius |
| 1123 |
-\@venn@overlap}% |
| 1124 |
\setlength{\@venn@By}{\@venn@Ay}% |
| 1125 |
% \end{macrocode} |
| 1126 |
% Compute dimensions of entire diagram |
| 1127 |
% \begin{macrocode} |
| 1128 |
\pgfmathsetlength{\@venn@w}{2*\@venn@hgap+4*\@venn@radius |
| 1129 |
-\@venn@overlap}% |
| 1130 |
\pgfmathsetlength{\@venn@h}{2*\@venn@vgap+4*\@venn@radius |
| 1131 |
-\@venn@overlap}% |
| 1132 |
% \end{macrocode} |
| 1133 |
% Define filling commands. |
| 1134 |
% Fill all of set $A$: |
| 1135 |
% \begin{macrocode} |
| 1136 |
\def\fillA{\path[fill=\@venn@shade] (\@venn@Ax,\@venn@Ay) |
| 1137 |
circle (\@venn@radius);}% |
| 1138 |
% \end{macrocode} |
| 1139 |
% Fill all of set $B$: |
| 1140 |
% \begin{macrocode} |
| 1141 |
\def\fillB{\path[fill=\@venn@shade] (\@venn@Bx,\@venn@By) |
| 1142 |
circle (\@venn@radius);}% |
| 1143 |
% \end{macrocode} |
| 1144 |
% Fill all of set $C$: |
| 1145 |
% \begin{macrocode} |
| 1146 |
\def\fillC{\path[fill=\@venn@shade] (\@venn@Cx,\@venn@Cy) |
| 1147 |
circle (\@venn@radius);}% |
| 1148 |
% \end{macrocode} |
| 1149 |
% Fill everything: |
| 1150 |
% \begin{macrocode} |
| 1151 |
\def\fillAll{\path[fill=\@venn@shade] (0,0) |
| 1152 |
rectangle (\@venn@w,\@venn@h);}% |
| 1153 |
% \end{macrocode} |
| 1154 |
% Fill everything except set $A$: |
| 1155 |
% \begin{macrocode} |
| 1156 |
\def\fillNotA{\path[fill=\@venn@shade,even odd rule] |
| 1157 |
(0,0) rectangle (\@venn@w,\@venn@h) |
| 1158 |
(\@venn@Ax,\@venn@Ay) circle (\@venn@radius);}% |
| 1159 |
% \end{macrocode} |
| 1160 |
% Fill everything except set $B$: |
| 1161 |
% \begin{macrocode} |
| 1162 |
\def\fillNotB{\path[fill=\@venn@shade,even odd rule] |
| 1163 |
(0,0) rectangle (\@venn@w,\@venn@h) |
| 1164 |
(\@venn@Bx,\@venn@By) circle (\@venn@radius);}% |
| 1165 |
% \end{macrocode} |
| 1166 |
% Fill everything except set $C$: |
| 1167 |
% \begin{macrocode} |
| 1168 |
\def\fillNotC{\path[fill=\@venn@shade,even odd rule] |
| 1169 |
(0,0) rectangle (\@venn@w,\@venn@h) |
| 1170 |
(\@venn@Cx,\@venn@Cy) circle (\@venn@radius);}% |
| 1171 |
% \end{macrocode} |
| 1172 |
% Fill only set $A$. |
| 1173 |
% \begin{macrocode} |
| 1174 |
\let\fillOnlyA\@venn@fillOnlyA@threesets |
| 1175 |
% \end{macrocode} |
| 1176 |
% Fill only set $B$: |
| 1177 |
% \begin{macrocode} |
| 1178 |
\let\fillOnlyB\@venn@fillOnlyB@threesets |
| 1179 |
% \end{macrocode} |
| 1180 |
% Fill only set $C$: |
| 1181 |
% \begin{macrocode} |
| 1182 |
\let\fillOnlyC\@venn@fillOnlyC@threesets |
| 1183 |
% \end{macrocode} |
| 1184 |
% Fill everything except $A$, $B$ or $C$. |
| 1185 |
% \begin{macrocode} |
| 1186 |
\let\fillNotABC\@venn@fillNotABC@threesets |
| 1187 |
% \end{macrocode} |
| 1188 |
% Fill $A$ but not $B$ |
| 1189 |
% \begin{macrocode} |
| 1190 |
\def\fillANotB{% |
| 1191 |
\begin{scope} |
| 1192 |
\clip (\@venn@Ax,\@venn@Ay) circle (\@venn@radius); |
| 1193 |
\path[fill=\@venn@shade,even odd rule] |
| 1194 |
(\@venn@Ax,\@venn@Ay) circle (\@venn@radius) |
| 1195 |
(\@venn@Bx,\@venn@By) circle (\@venn@radius); |
| 1196 |
\end{scope} |
| 1197 |
}% |
| 1198 |
% \end{macrocode} |
| 1199 |
% Fill $B$ but not $A$ |
| 1200 |
% \begin{macrocode} |
| 1201 |
\def\fillBNotA{% |
| 1202 |
\begin{scope} |
| 1203 |
\clip (\@venn@Bx,\@venn@By) circle (\@venn@radius); |
| 1204 |
\path[fill=\@venn@shade,even odd rule] |
| 1205 |
(\@venn@Bx,\@venn@By) circle (\@venn@radius) |
| 1206 |
(\@venn@Ax,\@venn@Ay) circle (\@venn@radius); |
| 1207 |
\end{scope} |
| 1208 |
}% |
| 1209 |
% \end{macrocode} |
| 1210 |
% Fill $A$ but not $C$ |
| 1211 |
% \begin{macrocode} |
| 1212 |
\def\fillANotC{% |
| 1213 |
\begin{scope} |
| 1214 |
\clip (\@venn@Ax,\@venn@Ay) circle (\@venn@radius); |
| 1215 |
\path[fill=\@venn@shade,even odd rule] |
| 1216 |
(\@venn@Ax,\@venn@Ay) circle (\@venn@radius) |
| 1217 |
(\@venn@Cx,\@venn@Cy) circle (\@venn@radius); |
| 1218 |
\end{scope} |
| 1219 |
}% |
| 1220 |
% \end{macrocode} |
| 1221 |
% Fill $C$ but not $A$ |
| 1222 |
% \begin{macrocode} |
| 1223 |
\def\fillCNotA{% |
| 1224 |
\begin{scope} |
| 1225 |
\clip (\@venn@Cx,\@venn@Cy) circle (\@venn@radius); |
| 1226 |
\path[fill=\@venn@shade,even odd rule] |
| 1227 |
(\@venn@Cx,\@venn@Cy) circle (\@venn@radius) |
| 1228 |
(\@venn@Ax,\@venn@Ay) circle (\@venn@radius); |
| 1229 |
\end{scope} |
| 1230 |
}% |
| 1231 |
% \end{macrocode} |
| 1232 |
% Fill $B$ but not $C$ |
| 1233 |
% \begin{macrocode} |
| 1234 |
\def\fillBNotC{% |
| 1235 |
\begin{scope} |
| 1236 |
\clip (\@venn@Bx,\@venn@By) circle (\@venn@radius); |
| 1237 |
\path[fill=\@venn@shade,even odd rule] |
| 1238 |
(\@venn@Bx,\@venn@By) circle (\@venn@radius) |
| 1239 |
(\@venn@Cx,\@venn@Cy) circle (\@venn@radius); |
| 1240 |
\end{scope} |
| 1241 |
}% |
| 1242 |
% \end{macrocode} |
| 1243 |
% Fill $C$ but not $B$ |
| 1244 |
% \begin{macrocode} |
| 1245 |
\def\fillCNotB{% |
| 1246 |
\begin{scope} |
| 1247 |
\clip (\@venn@Cx,\@venn@Cy) circle (\@venn@radius); |
| 1248 |
\path[fill=\@venn@shade,even odd rule] |
| 1249 |
(\@venn@Cx,\@venn@Cy) circle (\@venn@radius) |
| 1250 |
(\@venn@Bx,\@venn@By) circle (\@venn@radius); |
| 1251 |
\end{scope} |
| 1252 |
}% |
| 1253 |
% \end{macrocode} |
| 1254 |
% Fill $A$ intersect $B$ |
| 1255 |
% \begin{macrocode} |
| 1256 |
\def\fillACapB{% |
| 1257 |
\begin{scope} |
| 1258 |
\clip (\@venn@Ax,\@venn@Ay) circle (\@venn@radius); |
| 1259 |
\path[fill=\@venn@shade] |
| 1260 |
(\@venn@Bx,\@venn@By) circle (\@venn@radius); |
| 1261 |
\end{scope} |
| 1262 |
}% |
| 1263 |
% \end{macrocode} |
| 1264 |
% Define a synonym: |
| 1265 |
% \begin{macrocode} |
| 1266 |
\let\fillBCapA\fillACapB |
| 1267 |
% \end{macrocode} |
| 1268 |
% Fill $A$ intersect $C$ |
| 1269 |
% \begin{macrocode} |
| 1270 |
\def\fillACapC{% |
| 1271 |
\begin{scope} |
| 1272 |
\clip (\@venn@Ax,\@venn@Ay) circle (\@venn@radius); |
| 1273 |
\path[fill=\@venn@shade] |
| 1274 |
(\@venn@Cx,\@venn@Cy) circle (\@venn@radius); |
| 1275 |
\end{scope} |
| 1276 |
}% |
| 1277 |
% \end{macrocode} |
| 1278 |
% Define a synonym: |
| 1279 |
% \begin{macrocode} |
| 1280 |
\let\fillCCapA\fillACapC |
| 1281 |
% \end{macrocode} |
| 1282 |
% Fill $B$ intersect $C$ |
| 1283 |
% \begin{macrocode} |
| 1284 |
\def\fillBCapC{% |
| 1285 |
\begin{scope} |
| 1286 |
\clip (\@venn@Bx,\@venn@By) circle (\@venn@radius); |
| 1287 |
\path[fill=\@venn@shade] |
| 1288 |
(\@venn@Cx,\@venn@Cy) circle (\@venn@radius); |
| 1289 |
\end{scope} |
| 1290 |
}% |
| 1291 |
% \end{macrocode} |
| 1292 |
% Define a synonym: |
| 1293 |
% \begin{macrocode} |
| 1294 |
\let\fillCCapB\fillBCapC |
| 1295 |
% \end{macrocode} |
| 1296 |
% Fill $A$ intersect $B$ but not $C$ |
| 1297 |
% \begin{macrocode} |
| 1298 |
\def\fillACapBNotC{% |
| 1299 |
\begin{scope} |
| 1300 |
\clip (\@venn@Ax,\@venn@Ay) circle (\@venn@radius); |
| 1301 |
\clip (\@venn@Bx,\@venn@By) circle (\@venn@radius); |
| 1302 |
\path[fill=\@venn@shade,even odd rule] |
| 1303 |
(\@venn@Bx,\@venn@By) circle (\@venn@radius) |
| 1304 |
(\@venn@Cx,\@venn@Cy) circle (\@venn@radius); |
| 1305 |
\end{scope} |
| 1306 |
}% |
| 1307 |
% \end{macrocode} |
| 1308 |
% Define a synonym: |
| 1309 |
% \begin{macrocode} |
| 1310 |
\let\fillBCapANotC\fillACapBNotC |
| 1311 |
% \end{macrocode} |
| 1312 |
% Fill $A$ intersect $C$ but not $B$ |
| 1313 |
% \begin{macrocode} |
| 1314 |
\def\fillACapCNotB{% |
| 1315 |
\begin{scope} |
| 1316 |
\clip (\@venn@Ax,\@venn@Ay) circle (\@venn@radius); |
| 1317 |
\clip (\@venn@Cx,\@venn@Cy) circle (\@venn@radius); |
| 1318 |
\path[fill=\@venn@shade,even odd rule] |
| 1319 |
(\@venn@Cx,\@venn@Cy) circle (\@venn@radius) |
| 1320 |
(\@venn@Bx,\@venn@By) circle (\@venn@radius); |
| 1321 |
\end{scope} |
| 1322 |
}% |
| 1323 |
% \end{macrocode} |
| 1324 |
% Define a synonym: |
| 1325 |
% \begin{macrocode} |
| 1326 |
\let\fillCCapANotB\fillACapCNotB |
| 1327 |
% \end{macrocode} |
| 1328 |
% Fill $B$ intersect $C$ but not $A$ |
| 1329 |
% \begin{macrocode} |
| 1330 |
\def\fillBCapCNotA{% |
| 1331 |
\begin{scope} |
| 1332 |
\clip (\@venn@Bx,\@venn@By) circle (\@venn@radius); |
| 1333 |
\clip (\@venn@Cx,\@venn@Cy) circle (\@venn@radius); |
| 1334 |
\path[fill=\@venn@shade,even odd rule] |
| 1335 |
(\@venn@Cx,\@venn@Cy) circle (\@venn@radius) |
| 1336 |
(\@venn@Ax,\@venn@Ay) circle (\@venn@radius); |
| 1337 |
\end{scope} |
| 1338 |
}% |
| 1339 |
% \end{macrocode} |
| 1340 |
% Define a synonym: |
| 1341 |
% \begin{macrocode} |
| 1342 |
\let\fillCCapBNotA\fillBCapCNotA |
| 1343 |
% \end{macrocode} |
| 1344 |
% Fill the intersection of all three sets |
| 1345 |
% \begin{macrocode} |
| 1346 |
\def\fillACapBCapC{% |
| 1347 |
\begin{scope} |
| 1348 |
\clip (\@venn@Ax,\@venn@Ay) circle (\@venn@radius); |
| 1349 |
\clip (\@venn@Cx,\@venn@Cy) circle (\@venn@radius); |
| 1350 |
\path[fill=\@venn@shade] |
| 1351 |
(\@venn@Bx,\@venn@By) circle (\@venn@radius); |
| 1352 |
\end{scope} |
| 1353 |
}% |
| 1354 |
% \end{macrocode} |
| 1355 |
% Define synonyms: |
| 1356 |
% \begin{macrocode} |
| 1357 |
\let\fillACapCCapB\fillACapBCapC |
| 1358 |
\let\fillBCapACapC\fillACapBCapC |
| 1359 |
\let\fillBCapCCapA\fillACapBCapC |
| 1360 |
\let\fillCCapACapB\fillACapBCapC |
| 1361 |
\let\fillCCapBCapA\fillACapBCapC |
| 1362 |
% \end{macrocode} |
| 1363 |
% Start the \env{tikzpicture} environment. |
| 1364 |
% \begin{macrocode} |
| 1365 |
\ifdefempty{\@venn@tikzoptions}% |
| 1366 |
{% |
| 1367 |
\def\@venn@dobegin{\begin{tikzpicture}}% |
| 1368 |
}% |
| 1369 |
{% |
| 1370 |
\edef\@venn@dobegin{\noexpand\begin{tikzpicture}% |
| 1371 |
[\expandonce\@venn@tikzoptions]}% |
| 1372 |
}% |
| 1373 |
\@venn@dobegin |
| 1374 |
% \end{macrocode} |
| 1375 |
% coordinates of the Venn diagram corners |
| 1376 |
% \begin{macrocode} |
| 1377 |
\path (0,0) coordinate (venn bottom left) |
| 1378 |
(0,\@venn@h) coordinate (venn top left) |
| 1379 |
(\@venn@w,\@venn@h) coordinate (venn top right) |
| 1380 |
(\@venn@w,0) coordinate (venn bottom right); |
| 1381 |
}% |
| 1382 |
% \end{macrocode} |
| 1383 |
% End environment code: |
| 1384 |
% \begin{macrocode} |
| 1385 |
{% |
| 1386 |
% \end{macrocode} |
| 1387 |
% Draw outlines |
| 1388 |
% \begin{macrocode} |
| 1389 |
\ifvennshowframe |
| 1390 |
\draw (0,0) rectangle (\@venn@w,\@venn@h); |
| 1391 |
\else |
| 1392 |
\path (0,0) rectangle (\@venn@w,\@venn@h); |
| 1393 |
\fi |
| 1394 |
\draw (\@venn@Ax,\@venn@Ay) circle (\@venn@radius); |
| 1395 |
\draw (\@venn@Bx,\@venn@By) circle (\@venn@radius); |
| 1396 |
\draw (\@venn@Cx,\@venn@Cy) circle (\@venn@radius); |
| 1397 |
% \end{macrocode} |
| 1398 |
% Draw labels |
| 1399 |
% \begin{macrocode} |
| 1400 |
\draw (\@venn@Ax,\@venn@Ay) node[above,left] (labelOnlyA) {\@venn@label@OnlyA}; |
| 1401 |
\draw (\@venn@Bx,\@venn@By) node[above,right] (labelOnlyB) {\@venn@label@OnlyB}; |
| 1402 |
\draw (\@venn@Cx,\@venn@Cy) node[below] (labelOnlyC) {\@venn@label@OnlyC}; |
| 1403 |
% \end{macrocode} |
| 1404 |
% Region labels |
| 1405 |
% \begin{macrocode} |
| 1406 |
\draw (\@venn@vgap,\@venn@hgap) node (labelNotABC) {\@venn@label@NotABC}; |
| 1407 |
\draw (\@venn@Ax,\@venn@Ay+\@venn@radius) |
| 1408 |
node[below] (labelA) {\@venn@label@A}; |
| 1409 |
\draw (\@venn@Bx,\@venn@By+\@venn@radius) |
| 1410 |
node[below] (labelB) {\@venn@label@B}; |
| 1411 |
\draw (\@venn@Cx,\@venn@vgap) node[above] (labelC) {\@venn@label@C}; |
| 1412 |
\draw (\@venn@Cx,0.5*\@venn@h) node (labelABC) {\@venn@label@ABC}; |
| 1413 |
\draw (\@venn@Cx,\@venn@Ay) node[above] (labelOnlyAB) {\@venn@label@OnlyAB}; |
| 1414 |
\draw (\@venn@Ax,\@venn@Ay) ++(-60:\@[email protected]*\@venn@overlap) |
| 1415 |
node[below left] (labelOnlyAC) {\@venn@label@OnlyAC}; |
| 1416 |
\draw (\@venn@Bx,\@venn@By) ++(-120:\@[email protected]*\@venn@overlap) |
| 1417 |
node[below right] (labelOnlyBC) {\@venn@label@OnlyBC}; |
| 1418 |
\@postvennhook |
| 1419 |
\end{tikzpicture} |
| 1420 |
} |
| 1421 |
% \end{macrocode} |
| 1422 |
%\end{environment} |
| 1423 |
% |
| 1424 |
%\begin{macro}{\@postvennhook} |
| 1425 |
% Hook called just before the end of the \env{tikzpicture} |
| 1426 |
% environment. |
| 1427 |
% \begin{macrocode} |
| 1428 |
\newcommand*{\@postvennhook}{} |
| 1429 |
% \end{macrocode} |
| 1430 |
%\end{macro} |
| 1431 |
%\begin{macro}{\setpostvennhook} |
| 1432 |
% User interface to set the post hook. |
| 1433 |
% \begin{macrocode} |
| 1434 |
\newcommand*{\setpostvennhook}[1]{\def\@postvennhook{#1}} |
| 1435 |
% \end{macrocode} |
| 1436 |
%\end{macro} |
| 1437 |
% |
| 1438 |
%\begin{macro}{\@venn@fillOnlyA@threesets} |
| 1439 |
%\changes{1.1}{2016-03-16}{new} |
| 1440 |
%\cs{fillOnlyA} is set to this for the three set version. |
| 1441 |
% Reimplemented in v1.1 to use new circle intersect code. |
| 1442 |
% \begin{macrocode} |
| 1443 |
\newcommand*\@venn@fillOnlyA@threesets{% |
| 1444 |
% \end{macrocode} |
| 1445 |
% Get the intersection points between $A$ and $B$. |
| 1446 |
% \begin{macrocode} |
| 1447 |
\@venn@computecircleintersects{\@venn@Ax}{\@venn@Ay}{\@venn@Bx}{\@venn@By}% |
| 1448 |
% \end{macrocode} |
| 1449 |
% If there aren't two points of intersection, then the circles don't |
| 1450 |
% overlap. |
| 1451 |
% \begin{macrocode} |
| 1452 |
\ifnum\@venn@intersect@n=2\relax |
| 1453 |
% \end{macrocode} |
| 1454 |
% We need the point that's furthest from $C$. |
| 1455 |
% \begin{macrocode} |
| 1456 |
\pgfmathsetlength{\dimen@i}{\@venn@Cx-\@venn@intersect@i@x}% |
| 1457 |
\pgfmathsetlength{\dimen@ii}{\@venn@Cy-\@venn@intersect@i@y}% |
| 1458 |
\pgfmathsetlength{\dimen@}{\dimen@i*\dimen@i+\dimen@ii*\dimen@ii}% |
| 1459 |
\pgfmathsetlength{\dimen@i}{\@venn@Cx-\@venn@intersect@ii@x}% |
| 1460 |
\pgfmathsetlength{\dimen@ii}{\@venn@Cy-\@venn@intersect@ii@y}% |
| 1461 |
\pgfmathsetlength{\dimen@i}{\dimen@i*\dimen@i+\dimen@ii*\dimen@ii}% |
| 1462 |
\ifdim\dimen@>\dimen@i |
| 1463 |
\pgfmathsetlength{\dimen@i}{\@venn@intersect@i@x-\@venn@Ax}% |
| 1464 |
\pgfmathsetlength{\dimen@ii}{\@venn@intersect@i@y-\@venn@Ay}% |
| 1465 |
\edef\@venn@start@pt@x{\the\@venn@intersect@i@x}% |
| 1466 |
\edef\@venn@start@pt@y{\the\@venn@intersect@i@y}% |
| 1467 |
\else |
| 1468 |
\pgfmathsetlength{\dimen@i}{\@venn@intersect@ii@x-\@venn@Ax}% |
| 1469 |
\pgfmathsetlength{\dimen@ii}{\@venn@intersect@ii@y-\@venn@Ay}% |
| 1470 |
\edef\@venn@start@pt@x{\the\@venn@intersect@ii@x}% |
| 1471 |
\edef\@venn@start@pt@y{\the\@venn@intersect@ii@y}% |
| 1472 |
\fi |
| 1473 |
% \end{macrocode} |
| 1474 |
% Compute the initial angle of the first arc. |
| 1475 |
% \begin{macrocode} |
| 1476 |
\ifvennoldpgf |
| 1477 |
\pgfmathatantwo{\dimen@i}{\dimen@ii}% |
| 1478 |
\else |
| 1479 |
\pgfmathatantwo{\dimen@ii}{\dimen@i}% |
| 1480 |
\fi |
| 1481 |
\let\@venn@start@i@angle\pgfmathresult |
| 1482 |
% \end{macrocode} |
| 1483 |
% Compute the intersection between $A$ and $C$. |
| 1484 |
% \begin{macrocode} |
| 1485 |
\@venn@computecircleintersects{\@venn@Ax}{\@venn@Ay}{\@venn@Cx}{\@venn@Cy}% |
| 1486 |
% \end{macrocode} |
| 1487 |
% Need the point furthest from $B$. |
| 1488 |
% \begin{macrocode} |
| 1489 |
\pgfmathsetlength{\dimen@i}{\@venn@Bx-\@venn@intersect@i@x}% |
| 1490 |
\pgfmathsetlength{\dimen@ii}{\@venn@By-\@venn@intersect@i@y}% |
| 1491 |
\pgfmathsetlength{\dimen@}{\dimen@i*\dimen@i+\dimen@ii*\dimen@ii}% |
| 1492 |
\pgfmathsetlength{\dimen@i}{\@venn@Bx-\@venn@intersect@ii@x}% |
| 1493 |
\pgfmathsetlength{\dimen@ii}{\@venn@By-\@venn@intersect@ii@y}% |
| 1494 |
\pgfmathsetlength{\dimen@i}{\dimen@i*\dimen@i+\dimen@ii*\dimen@ii}% |
| 1495 |
\ifdim\dimen@>\dimen@i |
| 1496 |
\pgfmathsetlength{\dimen@i}{\@venn@intersect@i@x-\@venn@Ax}% |
| 1497 |
\pgfmathsetlength{\dimen@ii}{\@venn@intersect@i@y-\@venn@Ay}% |
| 1498 |
\edef\@venn@end@pt@i@x{\the\@venn@intersect@i@x}% |
| 1499 |
\edef\@venn@end@pt@i@y{\the\@venn@intersect@i@y}% |
| 1500 |
\else |
| 1501 |
\pgfmathsetlength{\dimen@i}{\@venn@intersect@ii@x-\@venn@Ax}% |
| 1502 |
\pgfmathsetlength{\dimen@ii}{\@venn@intersect@ii@y-\@venn@Ay}% |
| 1503 |
\edef\@venn@end@pt@i@x{\the\@venn@intersect@ii@x}% |
| 1504 |
\edef\@venn@end@pt@i@y{\the\@venn@intersect@ii@y}% |
| 1505 |
\fi |
| 1506 |
% \end{macrocode} |
| 1507 |
% Compute the end angle of the first arc. |
| 1508 |
% \begin{macrocode} |
| 1509 |
\ifvennoldpgf |
| 1510 |
\pgfmathatantwo{\dimen@i}{\dimen@ii}% |
| 1511 |
\else |
| 1512 |
\pgfmathatantwo{\dimen@ii}{\dimen@i}% |
| 1513 |
\fi |
| 1514 |
\let\@venn@end@i@angle\pgfmathresult |
| 1515 |
\pgfmathadd{\@venn@end@i@angle}{360}% |
| 1516 |
\let\@venn@end@i@angle\pgfmathresult |
| 1517 |
% \end{macrocode} |
| 1518 |
% Compute the start angle of the second arc. |
| 1519 |
% \begin{macrocode} |
| 1520 |
\pgfmathsetlength{\dimen@i}{\@venn@end@pt@i@x-\@venn@Cx}% |
| 1521 |
\pgfmathsetlength{\dimen@ii}{\@venn@end@pt@i@y-\@venn@Cy}% |
| 1522 |
\ifvennoldpgf |
| 1523 |
\pgfmathatantwo{\dimen@i}{\dimen@ii}% |
| 1524 |
\else |
| 1525 |
\pgfmathatantwo{\dimen@ii}{\dimen@i}% |
| 1526 |
\fi |
| 1527 |
\let\@venn@start@ii@angle\pgfmathresult |
| 1528 |
% \end{macrocode} |
| 1529 |
% Compute the intersection between $B$ and $C$. |
| 1530 |
% \begin{macrocode} |
| 1531 |
\@venn@computecircleintersects{\@venn@Bx}{\@venn@By}{\@venn@Cx}{\@venn@Cy}% |
| 1532 |
% \end{macrocode} |
| 1533 |
% Need the point closest to $A$. |
| 1534 |
% \begin{macrocode} |
| 1535 |
\pgfmathsetlength{\dimen@i}{\@venn@Ax-\@venn@intersect@i@x}% |
| 1536 |
\pgfmathsetlength{\dimen@ii}{\@venn@Ay-\@venn@intersect@i@y}% |
| 1537 |
\pgfmathsetlength{\dimen@}{\dimen@i*\dimen@i+\dimen@ii*\dimen@ii}% |
| 1538 |
\pgfmathsetlength{\dimen@i}{\@venn@Ax-\@venn@intersect@ii@x}% |
| 1539 |
\pgfmathsetlength{\dimen@ii}{\@venn@Ay-\@venn@intersect@ii@y}% |
| 1540 |
\pgfmathsetlength{\dimen@i}{\dimen@i*\dimen@i+\dimen@ii*\dimen@ii}% |
| 1541 |
\ifdim\dimen@<\dimen@i |
| 1542 |
\pgfmathsetlength{\dimen@i}{\@venn@intersect@i@x-\@venn@Cx}% |
| 1543 |
\pgfmathsetlength{\dimen@ii}{\@venn@intersect@i@y-\@venn@Cy}% |
| 1544 |
\edef\@venn@end@pt@ii@x{\the\@venn@intersect@i@x}% |
| 1545 |
\edef\@venn@end@pt@ii@y{\the\@venn@intersect@i@y}% |
| 1546 |
\else |
| 1547 |
\pgfmathsetlength{\dimen@i}{\@venn@intersect@ii@x-\@venn@Cx}% |
| 1548 |
\pgfmathsetlength{\dimen@ii}{\@venn@intersect@ii@y-\@venn@Cy}% |
| 1549 |
\edef\@venn@end@pt@ii@x{\the\@venn@intersect@ii@x}% |
| 1550 |
\edef\@venn@end@pt@ii@y{\the\@venn@intersect@ii@y}% |
| 1551 |
\fi |
| 1552 |
% \end{macrocode} |
| 1553 |
% Compute the end angle of the second arc. |
| 1554 |
% \begin{macrocode} |
| 1555 |
\ifvennoldpgf |
| 1556 |
\pgfmathatantwo{\dimen@i}{\dimen@ii}% |
| 1557 |
\else |
| 1558 |
\pgfmathatantwo{\dimen@ii}{\dimen@i}% |
| 1559 |
\fi |
| 1560 |
\let\@venn@end@ii@angle\pgfmathresult |
| 1561 |
% \end{macrocode} |
| 1562 |
% Compute the start angle of the third arc. |
| 1563 |
% \begin{macrocode} |
| 1564 |
\pgfmathsetlength{\dimen@i}{\@venn@end@pt@ii@x-\@venn@Bx}% |
| 1565 |
\pgfmathsetlength{\dimen@ii}{\@venn@end@pt@ii@y-\@venn@By}% |
| 1566 |
\ifvennoldpgf |
| 1567 |
\pgfmathatantwo{\dimen@i}{\dimen@ii}% |
| 1568 |
\else |
| 1569 |
\pgfmathatantwo{\dimen@ii}{\dimen@i}% |
| 1570 |
\fi |
| 1571 |
\let\@venn@start@iii@angle\pgfmathresult |
| 1572 |
% \end{macrocode} |
| 1573 |
% Compute the end angle of the third arc. |
| 1574 |
% \begin{macrocode} |
| 1575 |
\pgfmathsetlength{\dimen@i}{\@venn@start@pt@x-\@venn@Bx}% |
| 1576 |
\pgfmathsetlength{\dimen@ii}{\@venn@start@pt@y-\@venn@By}% |
| 1577 |
\ifvennoldpgf |
| 1578 |
\pgfmathatantwo{\dimen@i}{\dimen@ii}% |
| 1579 |
\else |
| 1580 |
\pgfmathatantwo{\dimen@ii}{\dimen@i}% |
| 1581 |
\fi |
| 1582 |
\let\@venn@end@iii@angle\pgfmathresult |
| 1583 |
\pgfmathsubtract{\@venn@end@iii@angle}{360}% |
| 1584 |
\let\@venn@end@iii@angle\pgfmathresult |
| 1585 |
% \end{macrocode} |
| 1586 |
% Fill path |
| 1587 |
% \begin{macrocode} |
| 1588 |
\path[fill=\@venn@shade] (\@venn@start@pt@x,\@venn@start@pt@y) |
| 1589 |
arc[radius=\@venn@radius,start angle=\@venn@start@i@angle, |
| 1590 |
end angle=\@venn@end@i@angle] |
| 1591 |
arc[radius=\@venn@radius,start angle=\@venn@start@ii@angle, |
| 1592 |
end angle=\@venn@end@ii@angle] |
| 1593 |
arc[radius=\@venn@radius,start angle=\@venn@start@iii@angle, |
| 1594 |
end angle=\@venn@end@iii@angle] -- cycle; |
| 1595 |
\else |
| 1596 |
\fillOnlyA |
| 1597 |
\fi |
| 1598 |
}% |
| 1599 |
% \end{macrocode} |
| 1600 |
%\end{macro} |
| 1601 |
% |
| 1602 |
%\begin{macro}{\@venn@fillOnlyB@threesets} |
| 1603 |
%\changes{1.1}{2016-03-16}{new} |
| 1604 |
%\cs{fillOnlyB} is set to this for the three set version. |
| 1605 |
% Reimplemented in v1.1 to use new circle intersect code. |
| 1606 |
% \begin{macrocode} |
| 1607 |
\newcommand*\@venn@fillOnlyB@threesets{% |
| 1608 |
% \end{macrocode} |
| 1609 |
% Get the intersection points between $B$ and $A$. |
| 1610 |
% \begin{macrocode} |
| 1611 |
\@venn@computecircleintersects{\@venn@Bx}{\@venn@By}{\@venn@Ax}{\@venn@Ay}% |
| 1612 |
% \end{macrocode} |
| 1613 |
% If there aren't two points of intersection, then the circles don't |
| 1614 |
% overlap. |
| 1615 |
% \begin{macrocode} |
| 1616 |
\ifnum\@venn@intersect@n=2\relax |
| 1617 |
% \end{macrocode} |
| 1618 |
% We need the point that's furthest from $C$. |
| 1619 |
% \begin{macrocode} |
| 1620 |
\pgfmathsetlength{\dimen@i}{\@venn@Cx-\@venn@intersect@i@x}% |
| 1621 |
\pgfmathsetlength{\dimen@ii}{\@venn@Cy-\@venn@intersect@i@y}% |
| 1622 |
\pgfmathsetlength{\dimen@}{\dimen@i*\dimen@i+\dimen@ii*\dimen@ii}% |
| 1623 |
\pgfmathsetlength{\dimen@i}{\@venn@Cx-\@venn@intersect@ii@x}% |
| 1624 |
\pgfmathsetlength{\dimen@ii}{\@venn@Cy-\@venn@intersect@ii@y}% |
| 1625 |
\pgfmathsetlength{\dimen@i}{\dimen@i*\dimen@i+\dimen@ii*\dimen@ii}% |
| 1626 |
\ifdim\dimen@>\dimen@i |
| 1627 |
\pgfmathsetlength{\dimen@i}{\@venn@intersect@i@x-\@venn@Bx}% |
| 1628 |
\pgfmathsetlength{\dimen@ii}{\@venn@intersect@i@y-\@venn@By}% |
| 1629 |
\edef\@venn@start@pt@x{\the\@venn@intersect@i@x}% |
| 1630 |
\edef\@venn@start@pt@y{\the\@venn@intersect@i@y}% |
| 1631 |
\else |
| 1632 |
\pgfmathsetlength{\dimen@i}{\@venn@intersect@ii@x-\@venn@Bx}% |
| 1633 |
\pgfmathsetlength{\dimen@ii}{\@venn@intersect@ii@y-\@venn@By}% |
| 1634 |
\edef\@venn@start@pt@x{\the\@venn@intersect@ii@x}% |
| 1635 |
\edef\@venn@start@pt@y{\the\@venn@intersect@ii@y}% |
| 1636 |
\fi |
| 1637 |
% \end{macrocode} |
| 1638 |
% Compute the initial angle of the first arc. |
| 1639 |
% \begin{macrocode} |
| 1640 |
\ifvennoldpgf |
| 1641 |
\pgfmathatantwo{\dimen@i}{\dimen@ii}% |
| 1642 |
\else |
| 1643 |
\pgfmathatantwo{\dimen@ii}{\dimen@i}% |
| 1644 |
\fi |
| 1645 |
\let\@venn@start@i@angle\pgfmathresult |
| 1646 |
% \end{macrocode} |
| 1647 |
% Compute the intersection between $B$ and $C$. |
| 1648 |
% \begin{macrocode} |
| 1649 |
\@venn@computecircleintersects{\@venn@Bx}{\@venn@By}{\@venn@Cx}{\@venn@Cy}% |
| 1650 |
% \end{macrocode} |
| 1651 |
% Need the point furthest from $A$. |
| 1652 |
% \begin{macrocode} |
| 1653 |
\pgfmathsetlength{\dimen@i}{\@venn@Ax-\@venn@intersect@i@x}% |
| 1654 |
\pgfmathsetlength{\dimen@ii}{\@venn@Ay-\@venn@intersect@i@y}% |
| 1655 |
\pgfmathsetlength{\dimen@}{\dimen@i*\dimen@i+\dimen@ii*\dimen@ii}% |
| 1656 |
\pgfmathsetlength{\dimen@i}{\@venn@Ax-\@venn@intersect@ii@x}% |
| 1657 |
\pgfmathsetlength{\dimen@ii}{\@venn@Ay-\@venn@intersect@ii@y}% |
| 1658 |
\pgfmathsetlength{\dimen@i}{\dimen@i*\dimen@i+\dimen@ii*\dimen@ii}% |
| 1659 |
\ifdim\dimen@>\dimen@i |
| 1660 |
\pgfmathsetlength{\dimen@i}{\@venn@intersect@i@x-\@venn@Bx}% |
| 1661 |
\pgfmathsetlength{\dimen@ii}{\@venn@intersect@i@y-\@venn@By}% |
| 1662 |
\edef\@venn@end@pt@i@x{\the\@venn@intersect@i@x}% |
| 1663 |
\edef\@venn@end@pt@i@y{\the\@venn@intersect@i@y}% |
| 1664 |
\else |
| 1665 |
\pgfmathsetlength{\dimen@i}{\@venn@intersect@ii@x-\@venn@Bx}% |
| 1666 |
\pgfmathsetlength{\dimen@ii}{\@venn@intersect@ii@y-\@venn@By}% |
| 1667 |
\edef\@venn@end@pt@i@x{\the\@venn@intersect@ii@x}% |
| 1668 |
\edef\@venn@end@pt@i@y{\the\@venn@intersect@ii@y}% |
| 1669 |
\fi |
| 1670 |
% \end{macrocode} |
| 1671 |
% Compute the end angle of the first arc. |
| 1672 |
% \begin{macrocode} |
| 1673 |
\ifvennoldpgf |
| 1674 |
\pgfmathatantwo{\dimen@i}{\dimen@ii}% |
| 1675 |
\else |
| 1676 |
\pgfmathatantwo{\dimen@ii}{\dimen@i}% |
| 1677 |
\fi |
| 1678 |
\let\@venn@end@i@angle\pgfmathresult |
| 1679 |
% \end{macrocode} |
| 1680 |
% Compute the start angle of the second arc. |
| 1681 |
% \begin{macrocode} |
| 1682 |
\pgfmathsetlength{\dimen@i}{\@venn@end@pt@i@x-\@venn@Cx}% |
| 1683 |
\pgfmathsetlength{\dimen@ii}{\@venn@end@pt@i@y-\@venn@Cy}% |
| 1684 |
\ifvennoldpgf |
| 1685 |
\pgfmathatantwo{\dimen@i}{\dimen@ii}% |
| 1686 |
\else |
| 1687 |
\pgfmathatantwo{\dimen@ii}{\dimen@i}% |
| 1688 |
\fi |
| 1689 |
\let\@venn@start@ii@angle\pgfmathresult |
| 1690 |
% \end{macrocode} |
| 1691 |
% Compute the intersection between $A$ and $C$. |
| 1692 |
% \begin{macrocode} |
| 1693 |
\@venn@computecircleintersects{\@venn@Ax}{\@venn@Ay}{\@venn@Cx}{\@venn@Cy}% |
| 1694 |
% \end{macrocode} |
| 1695 |
% Need the point closest to $A$. |
| 1696 |
% \begin{macrocode} |
| 1697 |
\pgfmathsetlength{\dimen@i}{\@venn@Bx-\@venn@intersect@i@x}% |
| 1698 |
\pgfmathsetlength{\dimen@ii}{\@venn@By-\@venn@intersect@i@y}% |
| 1699 |
\pgfmathsetlength{\dimen@}{\dimen@i*\dimen@i+\dimen@ii*\dimen@ii}% |
| 1700 |
\pgfmathsetlength{\dimen@i}{\@venn@Bx-\@venn@intersect@ii@x}% |
| 1701 |
\pgfmathsetlength{\dimen@ii}{\@venn@By-\@venn@intersect@ii@y}% |
| 1702 |
\pgfmathsetlength{\dimen@i}{\dimen@i*\dimen@i+\dimen@ii*\dimen@ii}% |
| 1703 |
\ifdim\dimen@<\dimen@i |
| 1704 |
\pgfmathsetlength{\dimen@i}{\@venn@intersect@i@x-\@venn@Cx}% |
| 1705 |
\pgfmathsetlength{\dimen@ii}{\@venn@intersect@i@y-\@venn@Cy}% |
| 1706 |
\edef\@venn@end@pt@ii@x{\the\@venn@intersect@i@x}% |
| 1707 |
\edef\@venn@end@pt@ii@y{\the\@venn@intersect@i@y}% |
| 1708 |
\else |
| 1709 |
\pgfmathsetlength{\dimen@i}{\@venn@intersect@ii@x-\@venn@Cx}% |
| 1710 |
\pgfmathsetlength{\dimen@ii}{\@venn@intersect@ii@y-\@venn@Cy}% |
| 1711 |
\edef\@venn@end@pt@ii@x{\the\@venn@intersect@ii@x}% |
| 1712 |
\edef\@venn@end@pt@ii@y{\the\@venn@intersect@ii@y}% |
| 1713 |
\fi |
| 1714 |
% \end{macrocode} |
| 1715 |
% Compute the end angle of the second arc. |
| 1716 |
% \begin{macrocode} |
| 1717 |
\ifvennoldpgf |
| 1718 |
\pgfmathatantwo{\dimen@i}{\dimen@ii}% |
| 1719 |
\else |
| 1720 |
\pgfmathatantwo{\dimen@ii}{\dimen@i}% |
| 1721 |
\fi |
| 1722 |
\let\@venn@end@ii@angle\pgfmathresult |
| 1723 |
% \end{macrocode} |
| 1724 |
% Compute the start angle of the third arc. |
| 1725 |
% \begin{macrocode} |
| 1726 |
\pgfmathsetlength{\dimen@i}{\@venn@end@pt@ii@x-\@venn@Ax}% |
| 1727 |
\pgfmathsetlength{\dimen@ii}{\@venn@end@pt@ii@y-\@venn@Ay}% |
| 1728 |
\ifvennoldpgf |
| 1729 |
\pgfmathatantwo{\dimen@i}{\dimen@ii}% |
| 1730 |
\else |
| 1731 |
\pgfmathatantwo{\dimen@ii}{\dimen@i}% |
| 1732 |
\fi |
| 1733 |
\let\@venn@start@iii@angle\pgfmathresult |
| 1734 |
% \end{macrocode} |
| 1735 |
% Compute the end angle of the third arc. |
| 1736 |
% \begin{macrocode} |
| 1737 |
\pgfmathsetlength{\dimen@i}{\@venn@start@pt@x-\@venn@Ax}% |
| 1738 |
\pgfmathsetlength{\dimen@ii}{\@venn@start@pt@y-\@venn@Ay}% |
| 1739 |
\ifvennoldpgf |
| 1740 |
\pgfmathatantwo{\dimen@i}{\dimen@ii}% |
| 1741 |
\else |
| 1742 |
\pgfmathatantwo{\dimen@ii}{\dimen@i}% |
| 1743 |
\fi |
| 1744 |
\let\@venn@end@iii@angle\pgfmathresult |
| 1745 |
% \end{macrocode} |
| 1746 |
% Fill path |
| 1747 |
% \begin{macrocode} |
| 1748 |
\path[fill=\@venn@shade] |
| 1749 |
(\@venn@start@pt@x,\@venn@start@pt@y) |
| 1750 |
arc[radius=\@venn@radius,start angle=\@venn@start@i@angle, |
| 1751 |
end angle=\@venn@end@i@angle] |
| 1752 |
arc[radius=\@venn@radius,start angle=\@venn@start@ii@angle, |
| 1753 |
end angle=\@venn@end@ii@angle] |
| 1754 |
arc[radius=\@venn@radius,start angle=\@venn@start@iii@angle, |
| 1755 |
end angle=\@venn@end@iii@angle] -- cycle; |
| 1756 |
\else |
| 1757 |
\fillOnlyB |
| 1758 |
\fi |
| 1759 |
}% |
| 1760 |
% \end{macrocode} |
| 1761 |
%\end{macro} |
| 1762 |
% |
| 1763 |
%\begin{macro}{\@venn@fillOnlyC@threesets} |
| 1764 |
%\changes{1.1}{2016-03-16}{new} |
| 1765 |
%\cs{fillOnlyC} is set to this for the three set version. |
| 1766 |
% Reimplemented in v1.1 to use new circle intersect code. |
| 1767 |
% \begin{macrocode} |
| 1768 |
\newcommand*\@venn@fillOnlyC@threesets{% |
| 1769 |
% \end{macrocode} |
| 1770 |
% Get the intersection points between $C$ and $B$. |
| 1771 |
% \begin{macrocode} |
| 1772 |
\@venn@computecircleintersects{\@venn@Cx}{\@venn@Cy}{\@venn@Bx}{\@venn@By}% |
| 1773 |
% \end{macrocode} |
| 1774 |
% If there aren't two points of intersection, then the circles don't |
| 1775 |
% overlap. |
| 1776 |
% \begin{macrocode} |
| 1777 |
\ifnum\@venn@intersect@n=2\relax |
| 1778 |
% \end{macrocode} |
| 1779 |
% We need the point that's furthest from $A$. |
| 1780 |
% \begin{macrocode} |
| 1781 |
\pgfmathsetlength{\dimen@i}{\@venn@Ax-\@venn@intersect@i@x}% |
| 1782 |
\pgfmathsetlength{\dimen@ii}{\@venn@Ay-\@venn@intersect@i@y}% |
| 1783 |
\pgfmathsetlength{\dimen@}{\dimen@i*\dimen@i+\dimen@ii*\dimen@ii}% |
| 1784 |
\pgfmathsetlength{\dimen@i}{\@venn@Ax-\@venn@intersect@ii@x}% |
| 1785 |
\pgfmathsetlength{\dimen@ii}{\@venn@Ay-\@venn@intersect@ii@y}% |
| 1786 |
\pgfmathsetlength{\dimen@i}{\dimen@i*\dimen@i+\dimen@ii*\dimen@ii}% |
| 1787 |
\ifdim\dimen@>\dimen@i |
| 1788 |
\pgfmathsetlength{\dimen@i}{\@venn@intersect@i@x-\@venn@Cx}% |
| 1789 |
\pgfmathsetlength{\dimen@ii}{\@venn@intersect@i@y-\@venn@Cy}% |
| 1790 |
\edef\@venn@start@pt@x{\the\@venn@intersect@i@x}% |
| 1791 |
\edef\@venn@start@pt@y{\the\@venn@intersect@i@y}% |
| 1792 |
\else |
| 1793 |
\pgfmathsetlength{\dimen@i}{\@venn@intersect@ii@x-\@venn@Cx}% |
| 1794 |
\pgfmathsetlength{\dimen@ii}{\@venn@intersect@ii@y-\@venn@Cy}% |
| 1795 |
\edef\@venn@start@pt@x{\the\@venn@intersect@ii@x}% |
| 1796 |
\edef\@venn@start@pt@y{\the\@venn@intersect@ii@y}% |
| 1797 |
\fi |
| 1798 |
% \end{macrocode} |
| 1799 |
% Compute the initial angle of the first arc. |
| 1800 |
% \begin{macrocode} |
| 1801 |
\ifvennoldpgf |
| 1802 |
\pgfmathatantwo{\dimen@i}{\dimen@ii}% |
| 1803 |
\else |
| 1804 |
\pgfmathatantwo{\dimen@ii}{\dimen@i}% |
| 1805 |
\fi |
| 1806 |
\let\@venn@start@i@angle\pgfmathresult |
| 1807 |
% \end{macrocode} |
| 1808 |
% Compute the intersection between $C$ and $A$. |
| 1809 |
% \begin{macrocode} |
| 1810 |
\@venn@computecircleintersects{\@venn@Cx}{\@venn@Cy}{\@venn@Ax}{\@venn@Ay}% |
| 1811 |
% \end{macrocode} |
| 1812 |
% Need the point furthest from $B$. |
| 1813 |
% \begin{macrocode} |
| 1814 |
\pgfmathsetlength{\dimen@i}{\@venn@Bx-\@venn@intersect@i@x}% |
| 1815 |
\pgfmathsetlength{\dimen@ii}{\@venn@By-\@venn@intersect@i@y}% |
| 1816 |
\pgfmathsetlength{\dimen@}{\dimen@i*\dimen@i+\dimen@ii*\dimen@ii}% |
| 1817 |
\pgfmathsetlength{\dimen@i}{\@venn@Bx-\@venn@intersect@ii@x}% |
| 1818 |
\pgfmathsetlength{\dimen@ii}{\@venn@By-\@venn@intersect@ii@y}% |
| 1819 |
\pgfmathsetlength{\dimen@i}{\dimen@i*\dimen@i+\dimen@ii*\dimen@ii}% |
| 1820 |
\ifdim\dimen@>\dimen@i |
| 1821 |
\pgfmathsetlength{\dimen@i}{\@venn@intersect@i@x-\@venn@Cx}% |
| 1822 |
\pgfmathsetlength{\dimen@ii}{\@venn@intersect@i@y-\@venn@Cy}% |
| 1823 |
\edef\@venn@end@pt@i@x{\the\@venn@intersect@i@x}% |
| 1824 |
\edef\@venn@end@pt@i@y{\the\@venn@intersect@i@y}% |
| 1825 |
\else |
| 1826 |
\pgfmathsetlength{\dimen@i}{\@venn@intersect@ii@x-\@venn@Cx}% |
| 1827 |
\pgfmathsetlength{\dimen@ii}{\@venn@intersect@ii@y-\@venn@Cy}% |
| 1828 |
\edef\@venn@end@pt@i@x{\the\@venn@intersect@ii@x}% |
| 1829 |
\edef\@venn@end@pt@i@y{\the\@venn@intersect@ii@y}% |
| 1830 |
\fi |
| 1831 |
% \end{macrocode} |
| 1832 |
% Compute the end angle of the first arc. |
| 1833 |
% \begin{macrocode} |
| 1834 |
\ifvennoldpgf |
| 1835 |
\pgfmathatantwo{\dimen@i}{\dimen@ii}% |
| 1836 |
\else |
| 1837 |
\pgfmathatantwo{\dimen@ii}{\dimen@i}% |
| 1838 |
\fi |
| 1839 |
\let\@venn@end@i@angle\pgfmathresult |
| 1840 |
\pgfmathsubtract{\@venn@end@i@angle}{360}% |
| 1841 |
\let\@venn@end@i@angle\pgfmathresult |
| 1842 |
% \end{macrocode} |
| 1843 |
% Compute the start angle of the second arc. |
| 1844 |
% \begin{macrocode} |
| 1845 |
\pgfmathsetlength{\dimen@i}{\@venn@end@pt@i@x-\@venn@Ax}% |
| 1846 |
\pgfmathsetlength{\dimen@ii}{\@venn@end@pt@i@y-\@venn@Ay}% |
| 1847 |
\ifvennoldpgf |
| 1848 |
\pgfmathatantwo{\dimen@i}{\dimen@ii}% |
| 1849 |
\else |
| 1850 |
\pgfmathatantwo{\dimen@ii}{\dimen@i}% |
| 1851 |
\fi |
| 1852 |
\let\@venn@start@ii@angle\pgfmathresult |
| 1853 |
% \end{macrocode} |
| 1854 |
% Compute the intersection between $B$ and $A$. |
| 1855 |
% \begin{macrocode} |
| 1856 |
\@venn@computecircleintersects{\@venn@Bx}{\@venn@By}{\@venn@Ax}{\@venn@Ay}% |
| 1857 |
% \end{macrocode} |
| 1858 |
% Need the point closest to $C$. |
| 1859 |
% \begin{macrocode} |
| 1860 |
\pgfmathsetlength{\dimen@i}{\@venn@Cx-\@venn@intersect@i@x}% |
| 1861 |
\pgfmathsetlength{\dimen@ii}{\@venn@Cy-\@venn@intersect@i@y}% |
| 1862 |
\pgfmathsetlength{\dimen@}{\dimen@i*\dimen@i+\dimen@ii*\dimen@ii}% |
| 1863 |
\pgfmathsetlength{\dimen@i}{\@venn@Cx-\@venn@intersect@ii@x}% |
| 1864 |
\pgfmathsetlength{\dimen@ii}{\@venn@Cy-\@venn@intersect@ii@y}% |
| 1865 |
\pgfmathsetlength{\dimen@i}{\dimen@i*\dimen@i+\dimen@ii*\dimen@ii}% |
| 1866 |
\ifdim\dimen@<\dimen@i |
| 1867 |
\pgfmathsetlength{\dimen@i}{\@venn@intersect@i@x-\@venn@Ax}% |
| 1868 |
\pgfmathsetlength{\dimen@ii}{\@venn@intersect@i@y-\@venn@Ay}% |
| 1869 |
\edef\@venn@end@pt@ii@x{\the\@venn@intersect@i@x}% |
| 1870 |
\edef\@venn@end@pt@ii@y{\the\@venn@intersect@i@y}% |
| 1871 |
\else |
| 1872 |
\pgfmathsetlength{\dimen@i}{\@venn@intersect@ii@x-\@venn@Ax}% |
| 1873 |
\pgfmathsetlength{\dimen@ii}{\@venn@intersect@ii@y-\@venn@Ay}% |
| 1874 |
\edef\@venn@end@pt@ii@x{\the\@venn@intersect@ii@x}% |
| 1875 |
\edef\@venn@end@pt@ii@y{\the\@venn@intersect@ii@y}% |
| 1876 |
\fi |
| 1877 |
% \end{macrocode} |
| 1878 |
% Compute the end angle of the second arc. |
| 1879 |
% \begin{macrocode} |
| 1880 |
\ifvennoldpgf |
| 1881 |
\pgfmathatantwo{\dimen@i}{\dimen@ii}% |
| 1882 |
\else |
| 1883 |
\pgfmathatantwo{\dimen@ii}{\dimen@i}% |
| 1884 |
\fi |
| 1885 |
\let\@venn@end@ii@angle\pgfmathresult |
| 1886 |
% \end{macrocode} |
| 1887 |
% Compute the start angle of the third arc. |
| 1888 |
% \begin{macrocode} |
| 1889 |
\pgfmathsetlength{\dimen@i}{\@venn@end@pt@ii@x-\@venn@Bx}% |
| 1890 |
\pgfmathsetlength{\dimen@ii}{\@venn@end@pt@ii@y-\@venn@By}% |
| 1891 |
\ifvennoldpgf |
| 1892 |
\pgfmathatantwo{\dimen@i}{\dimen@ii}% |
| 1893 |
\else |
| 1894 |
\pgfmathatantwo{\dimen@ii}{\dimen@i}% |
| 1895 |
\fi |
| 1896 |
\let\@venn@start@iii@angle\pgfmathresult |
| 1897 |
% \end{macrocode} |
| 1898 |
% Compute the end angle of the third arc. |
| 1899 |
% \begin{macrocode} |
| 1900 |
\pgfmathsetlength{\dimen@i}{\@venn@start@pt@x-\@venn@Bx}% |
| 1901 |
\pgfmathsetlength{\dimen@ii}{\@venn@start@pt@y-\@venn@By}% |
| 1902 |
\ifvennoldpgf |
| 1903 |
\pgfmathatantwo{\dimen@i}{\dimen@ii}% |
| 1904 |
\else |
| 1905 |
\pgfmathatantwo{\dimen@ii}{\dimen@i}% |
| 1906 |
\fi |
| 1907 |
\let\@venn@end@iii@angle\pgfmathresult |
| 1908 |
% \end{macrocode} |
| 1909 |
% Fill path |
| 1910 |
% \begin{macrocode} |
| 1911 |
\path[fill=\@venn@shade] (\@venn@start@pt@x,\@venn@start@pt@y) |
| 1912 |
arc[radius=\@venn@radius,start angle=\@venn@start@i@angle, |
| 1913 |
end angle=\@venn@end@i@angle] |
| 1914 |
arc[radius=\@venn@radius,start angle=\@venn@start@ii@angle, |
| 1915 |
end angle=\@venn@end@ii@angle] |
| 1916 |
arc[radius=\@venn@radius,start angle=\@venn@start@iii@angle, |
| 1917 |
end angle=\@venn@end@iii@angle] -- cycle; |
| 1918 |
\else |
| 1919 |
\fillOnlyC |
| 1920 |
\fi |
| 1921 |
}% |
| 1922 |
% \end{macrocode} |
| 1923 |
%\end{macro} |
| 1924 |
% |
| 1925 |
%\begin{macro}{\@venn@fillNotABC@threesets} |
| 1926 |
%\changes{1.1}{2016-03-16}{new} |
| 1927 |
%\cs{fillNotABC} is set to this for the three set version. |
| 1928 |
% Reimplemented in v1.1 to use new circle intersect code. |
| 1929 |
% \begin{macrocode} |
| 1930 |
\newcommand*\@venn@fillNotABC@threesets{% |
| 1931 |
% \end{macrocode} |
| 1932 |
% Get the intersection points between $A$ and $B$. |
| 1933 |
% \begin{macrocode} |
| 1934 |
\@venn@computecircleintersects{\@venn@Ax}{\@venn@Ay}{\@venn@Bx}{\@venn@By}% |
| 1935 |
% \end{macrocode} |
| 1936 |
% If there aren't two points of intersection, then the circles don't |
| 1937 |
% overlap. |
| 1938 |
% \begin{macrocode} |
| 1939 |
\ifnum\@venn@intersect@n=2\relax |
| 1940 |
% \end{macrocode} |
| 1941 |
% We need the point that's furthest from $C$. |
| 1942 |
% \begin{macrocode} |
| 1943 |
\pgfmathsetlength{\dimen@i}{\@venn@Cx-\@venn@intersect@i@x}% |
| 1944 |
\pgfmathsetlength{\dimen@ii}{\@venn@Cy-\@venn@intersect@i@y}% |
| 1945 |
\pgfmathsetlength{\dimen@}{\dimen@i*\dimen@i+\dimen@ii*\dimen@ii}% |
| 1946 |
\pgfmathsetlength{\dimen@i}{\@venn@Cx-\@venn@intersect@ii@x}% |
| 1947 |
\pgfmathsetlength{\dimen@ii}{\@venn@Cy-\@venn@intersect@ii@y}% |
| 1948 |
\pgfmathsetlength{\dimen@i}{\dimen@i*\dimen@i+\dimen@ii*\dimen@ii}% |
| 1949 |
\ifdim\dimen@>\dimen@i |
| 1950 |
\pgfmathsetlength{\dimen@i}{\@venn@intersect@i@x-\@venn@Ax}% |
| 1951 |
\pgfmathsetlength{\dimen@ii}{\@venn@intersect@i@y-\@venn@Ay}% |
| 1952 |
\edef\@venn@start@pt@x{\the\@venn@intersect@i@x}% |
| 1953 |
\edef\@venn@start@pt@y{\the\@venn@intersect@i@y}% |
| 1954 |
\else |
| 1955 |
\pgfmathsetlength{\dimen@i}{\@venn@intersect@ii@x-\@venn@Ax}% |
| 1956 |
\pgfmathsetlength{\dimen@ii}{\@venn@intersect@ii@y-\@venn@Ay}% |
| 1957 |
\edef\@venn@start@pt@x{\the\@venn@intersect@ii@x}% |
| 1958 |
\edef\@venn@start@pt@y{\the\@venn@intersect@ii@y}% |
| 1959 |
\fi |
| 1960 |
% \end{macrocode} |
| 1961 |
% Compute the initial angle of the first arc. |
| 1962 |
% \begin{macrocode} |
| 1963 |
\ifvennoldpgf |
| 1964 |
\pgfmathatantwo{\dimen@i}{\dimen@ii}% |
| 1965 |
\else |
| 1966 |
\pgfmathatantwo{\dimen@ii}{\dimen@i}% |
| 1967 |
\fi |
| 1968 |
\let\@venn@start@i@angle\pgfmathresult |
| 1969 |
% \end{macrocode} |
| 1970 |
% Compute the intersection between $A$ and $C$. |
| 1971 |
% \begin{macrocode} |
| 1972 |
\@venn@computecircleintersects{\@venn@Ax}{\@venn@Ay}{\@venn@Cx}{\@venn@Cy}% |
| 1973 |
% \end{macrocode} |
| 1974 |
% We need the point that's furthest from $B$. |
| 1975 |
% \begin{macrocode} |
| 1976 |
\pgfmathsetlength{\dimen@i}{\@venn@Bx-\@venn@intersect@i@x}% |
| 1977 |
\pgfmathsetlength{\dimen@ii}{\@venn@By-\@venn@intersect@i@y}% |
| 1978 |
\pgfmathsetlength{\dimen@}{\dimen@i*\dimen@i+\dimen@ii*\dimen@ii}% |
| 1979 |
\pgfmathsetlength{\dimen@i}{\@venn@Bx-\@venn@intersect@ii@x}% |
| 1980 |
\pgfmathsetlength{\dimen@ii}{\@venn@By-\@venn@intersect@ii@y}% |
| 1981 |
\pgfmathsetlength{\dimen@i}{\dimen@i*\dimen@i+\dimen@ii*\dimen@ii}% |
| 1982 |
\ifdim\dimen@>\dimen@i |
| 1983 |
\pgfmathsetlength{\dimen@i}{\@venn@intersect@i@x-\@venn@Ax}% |
| 1984 |
\pgfmathsetlength{\dimen@ii}{\@venn@intersect@i@y-\@venn@Ay}% |
| 1985 |
\edef\@venn@end@pt@i@x{\the\@venn@intersect@i@x}% |
| 1986 |
\edef\@venn@end@pt@i@y{\the\@venn@intersect@i@y}% |
| 1987 |
\else |
| 1988 |
\pgfmathsetlength{\dimen@i}{\@venn@intersect@ii@x-\@venn@Ax}% |
| 1989 |
\pgfmathsetlength{\dimen@ii}{\@venn@intersect@ii@y-\@venn@Ay}% |
| 1990 |
\edef\@venn@end@pt@i@x{\the\@venn@intersect@ii@x}% |
| 1991 |
\edef\@venn@end@pt@i@y{\the\@venn@intersect@ii@y}% |
| 1992 |
\fi |
| 1993 |
% \end{macrocode} |
| 1994 |
% Compute the end angle of the first arc. |
| 1995 |
% \begin{macrocode} |
| 1996 |
\ifvennoldpgf |
| 1997 |
\pgfmathatantwo{\dimen@i}{\dimen@ii}% |
| 1998 |
\else |
| 1999 |
\pgfmathatantwo{\dimen@ii}{\dimen@i}% |
| 2000 |
\fi |
| 2001 |
\let\@venn@end@i@angle\pgfmathresult |
| 2002 |
\pgfmathadd{\@venn@end@i@angle}{360}% |
| 2003 |
\let\@venn@end@i@angle\pgfmathresult |
| 2004 |
% \end{macrocode} |
| 2005 |
% Compute the start angle of the second arc. |
| 2006 |
% \begin{macrocode} |
| 2007 |
\pgfmathsetlength{\dimen@i}{\@venn@end@pt@i@x-\@venn@Cx}% |
| 2008 |
\pgfmathsetlength{\dimen@ii}{\@venn@end@pt@i@y-\@venn@Cy}% |
| 2009 |
\ifvennoldpgf |
| 2010 |
\pgfmathatantwo{\dimen@i}{\dimen@ii}% |
| 2011 |
\else |
| 2012 |
\pgfmathatantwo{\dimen@ii}{\dimen@i}% |
| 2013 |
\fi |
| 2014 |
\let\@venn@start@ii@angle\pgfmathresult |
| 2015 |
% \end{macrocode} |
| 2016 |
% Compute the intersection between $C$ and $B$. |
| 2017 |
% \begin{macrocode} |
| 2018 |
\@venn@computecircleintersects{\@venn@Cx}{\@venn@Cy}{\@venn@Bx}{\@venn@By}% |
| 2019 |
% \end{macrocode} |
| 2020 |
% We need the point that's furthest from $A$. |
| 2021 |
% \begin{macrocode} |
| 2022 |
\pgfmathsetlength{\dimen@i}{\@venn@Ax-\@venn@intersect@i@x}% |
| 2023 |
\pgfmathsetlength{\dimen@ii}{\@venn@Ay-\@venn@intersect@i@y}% |
| 2024 |
\pgfmathsetlength{\dimen@}{\dimen@i*\dimen@i+\dimen@ii*\dimen@ii}% |
| 2025 |
\pgfmathsetlength{\dimen@i}{\@venn@Ax-\@venn@intersect@ii@x}% |
| 2026 |
\pgfmathsetlength{\dimen@ii}{\@venn@Ay-\@venn@intersect@ii@y}% |
| 2027 |
\pgfmathsetlength{\dimen@i}{\dimen@i*\dimen@i+\dimen@ii*\dimen@ii}% |
| 2028 |
\ifdim\dimen@>\dimen@i |
| 2029 |
\pgfmathsetlength{\dimen@i}{\@venn@intersect@i@x-\@venn@Cx}% |
| 2030 |
\pgfmathsetlength{\dimen@ii}{\@venn@intersect@i@y-\@venn@Cy}% |
| 2031 |
\edef\@venn@end@pt@ii@x{\the\@venn@intersect@i@x}% |
| 2032 |
\edef\@venn@end@pt@ii@y{\the\@venn@intersect@i@y}% |
| 2033 |
\else |
| 2034 |
\pgfmathsetlength{\dimen@i}{\@venn@intersect@ii@x-\@venn@Cx}% |
| 2035 |
\pgfmathsetlength{\dimen@ii}{\@venn@intersect@ii@y-\@venn@Cy}% |
| 2036 |
\edef\@venn@end@pt@ii@x{\the\@venn@intersect@ii@x}% |
| 2037 |
\edef\@venn@end@pt@ii@y{\the\@venn@intersect@ii@y}% |
| 2038 |
\fi |
| 2039 |
% \end{macrocode} |
| 2040 |
% Compute the end angle of the second arc. |
| 2041 |
% \begin{macrocode} |
| 2042 |
\ifvennoldpgf |
| 2043 |
\pgfmathatantwo{\dimen@i}{\dimen@ii}% |
| 2044 |
\else |
| 2045 |
\pgfmathatantwo{\dimen@ii}{\dimen@i}% |
| 2046 |
\fi |
| 2047 |
\let\@venn@end@ii@angle\pgfmathresult |
| 2048 |
\pgfmathadd{\@venn@end@ii@angle}{360}% |
| 2049 |
\let\@venn@end@ii@angle\pgfmathresult |
| 2050 |
% \end{macrocode} |
| 2051 |
% Compute the start angle of the third arc. |
| 2052 |
% \begin{macrocode} |
| 2053 |
\pgfmathsetlength{\dimen@i}{\@venn@end@pt@ii@x-\@venn@Bx}% |
| 2054 |
\pgfmathsetlength{\dimen@ii}{\@venn@end@pt@ii@y-\@venn@By}% |
| 2055 |
\ifvennoldpgf |
| 2056 |
\pgfmathatantwo{\dimen@i}{\dimen@ii}% |
| 2057 |
\else |
| 2058 |
\pgfmathatantwo{\dimen@ii}{\dimen@i}% |
| 2059 |
\fi |
| 2060 |
\let\@venn@start@iii@angle\pgfmathresult |
| 2061 |
% \end{macrocode} |
| 2062 |
% Compute the end angle of the third arc. |
| 2063 |
% \begin{macrocode} |
| 2064 |
\pgfmathsetlength{\dimen@i}{\@venn@start@pt@x-\@venn@Bx}% |
| 2065 |
\pgfmathsetlength{\dimen@ii}{\@venn@start@pt@y-\@venn@By}% |
| 2066 |
\ifvennoldpgf |
| 2067 |
\pgfmathatantwo{\dimen@i}{\dimen@ii}% |
| 2068 |
\else |
| 2069 |
\pgfmathatantwo{\dimen@ii}{\dimen@i}% |
| 2070 |
\fi |
| 2071 |
\let\@venn@end@iii@angle\pgfmathresult |
| 2072 |
% \end{macrocode} |
| 2073 |
% Fill path |
| 2074 |
% \begin{macrocode} |
| 2075 |
\path[fill=\@venn@shade,even odd rule] |
| 2076 |
(0,0) rectangle (\@venn@w,\@venn@h) |
| 2077 |
(\@venn@start@pt@x,\@venn@start@pt@y) |
| 2078 |
arc[radius=\@venn@radius,start angle=\@venn@start@i@angle, |
| 2079 |
end angle=\@venn@end@i@angle] |
| 2080 |
arc[radius=\@venn@radius,start angle=\@venn@start@ii@angle, |
| 2081 |
end angle=\@venn@end@ii@angle] |
| 2082 |
arc[radius=\@venn@radius,start angle=\@venn@start@iii@angle, |
| 2083 |
end angle=\@venn@end@iii@angle] |
| 2084 |
-- cycle; |
| 2085 |
\else |
| 2086 |
\path[fill=\@venn@shade,even odd rule] |
| 2087 |
(0,0) rectangle (\@venn@w,\@venn@h) |
| 2088 |
(\@venn@Ax,\@venn@Ay) circle (\@venn@radius) |
| 2089 |
(\@venn@Bx,\@venn@By) circle (\@venn@radius) |
| 2090 |
(\@venn@Cx,\@venn@Cy) circle (\@venn@radius);% |
| 2091 |
\fi |
| 2092 |
}% |
| 2093 |
% \end{macrocode} |
| 2094 |
%\end{macro} |
| 2095 |
% |
| 2096 |
%\begin{environment}{venndiagram2sets} |
| 2097 |
% \begin{macrocode} |
| 2098 |
\newenvironment{venndiagram2sets}[1][]% |
| 2099 |
{% |
| 2100 |
% \end{macrocode} |
| 2101 |
% Disable the keys that aren't applicable. |
| 2102 |
% \begin{macrocode} |
| 2103 |
\disable@keys{venn}{labelABC,labelOnlyC,labelOnlyAC,labelOnlyBC,% |
| 2104 |
labelNotABC,labelC,labelOnlyAB}% |
| 2105 |
% \end{macrocode} |
| 2106 |
% Set the key values given in the optional argument. |
| 2107 |
% \begin{macrocode} |
| 2108 |
\setkeys{venn}{#1}% |
| 2109 |
% \end{macrocode} |
| 2110 |
% Calculate centre of A |
| 2111 |
% \begin{macrocode} |
| 2112 |
\pgfmathsetlength{\@venn@Ax}{\@venn@hgap+\@venn@radius}% |
| 2113 |
\pgfmathsetlength{\@venn@Ay}{\@venn@vgap+\@venn@radius}% |
| 2114 |
% \end{macrocode} |
| 2115 |
% Calculate centre of B |
| 2116 |
% \begin{macrocode} |
| 2117 |
\pgfmathsetlength{\@venn@Bx}{\@venn@hgap+3*\@venn@radius |
| 2118 |
-\@venn@overlap}% |
| 2119 |
\setlength{\@venn@By}{\@venn@Ay}% |
| 2120 |
% \end{macrocode} |
| 2121 |
% Compute dimensions of entire diagram |
| 2122 |
% \begin{macrocode} |
| 2123 |
\pgfmathsetlength{\@venn@w}{2*\@venn@hgap+4*\@venn@radius |
| 2124 |
-\@venn@overlap}% |
| 2125 |
\pgfmathsetlength{\@venn@h}{2*\@venn@vgap+2*\@venn@radius}% |
| 2126 |
% \end{macrocode} |
| 2127 |
% Define filling commands |
| 2128 |
% \begin{macrocode} |
| 2129 |
\def\fillA{\path[fill=\@venn@shade] (\@venn@Ax,\@venn@Ay) |
| 2130 |
circle (\@venn@radius);}% |
| 2131 |
\def\fillB{\path[fill=\@venn@shade] (\@venn@Bx,\@venn@By) |
| 2132 |
circle (\@venn@radius);}% |
| 2133 |
\def\fillAll{\path[fill=\@venn@shade] (0,0) |
| 2134 |
rectangle (\@venn@w,\@venn@h);}% |
| 2135 |
% \end{macrocode} |
| 2136 |
% Fill only set $A$ |
| 2137 |
% \begin{macrocode} |
| 2138 |
\let\fillOnlyA\@venn@fillOnlyA@twosets |
| 2139 |
% \end{macrocode} |
| 2140 |
% Fill only set $B$ |
| 2141 |
% \begin{macrocode} |
| 2142 |
\let\fillOnlyB\@venn@fillOnlyB@twosets |
| 2143 |
% \end{macrocode} |
| 2144 |
% Fill everything except $A$ |
| 2145 |
% \begin{macrocode} |
| 2146 |
\def\fillNotA{\path[fill=\@venn@shade,even odd rule] |
| 2147 |
(0,0) rectangle (\@venn@w,\@venn@h) |
| 2148 |
(\@venn@Ax,\@venn@Ay) circle (\@venn@radius);}% |
| 2149 |
% \end{macrocode} |
| 2150 |
% Fill everything except $B$ |
| 2151 |
% \begin{macrocode} |
| 2152 |
\def\fillNotB{\path[fill=\@venn@shade,even odd rule] |
| 2153 |
(0,0) rectangle (\@venn@w,\@venn@h) |
| 2154 |
(\@venn@Bx,\@venn@By) circle (\@venn@radius);}% |
| 2155 |
% \end{macrocode} |
| 2156 |
% Fill everything except $A$ or $B$ ($(A\cup B)^c$) |
| 2157 |
% \begin{macrocode} |
| 2158 |
\def\fillNotAorB{% |
| 2159 |
\begin{scope} |
| 2160 |
\path[clip] |
| 2161 |
(0,0) rectangle (\@venn@w,\@venn@h) |
| 2162 |
(\@venn@Bx,\@venn@By) circle (\@venn@radius) |
| 2163 |
; |
| 2164 |
\path[fill=\@venn@shade,even odd rule] |
| 2165 |
(0,0) rectangle (\@venn@w,\@venn@h) |
| 2166 |
(\@venn@Ax,\@venn@Ay) circle (\@venn@radius) |
| 2167 |
; |
| 2168 |
\end{scope} |
| 2169 |
}% |
| 2170 |
% \end{macrocode} |
| 2171 |
% Fill not $A$ or not $B$ ($(A\cap B)^c$) |
| 2172 |
% \begin{macrocode} |
| 2173 |
\def\fillNotAorNotB{% |
| 2174 |
\path[fill=\@venn@shade,nonzero rule] |
| 2175 |
(0,0) rectangle (\@venn@w,\@venn@h) |
| 2176 |
(\@venn@Ax,\@venn@Ay) circle (\@venn@radius) |
| 2177 |
(0,0) rectangle (\@venn@w,\@venn@h) |
| 2178 |
(\@venn@Bx,\@venn@By) circle (\@venn@radius) |
| 2179 |
; |
| 2180 |
}% |
| 2181 |
% \end{macrocode} |
| 2182 |
% Fill $A$ but not $B$ (same as only $A$ for two sets). |
| 2183 |
%\changes{1.1}{2016-03-16}{made \cs{fillANotB} a synonym for |
| 2184 |
%\cs{fillOnlyA}} |
| 2185 |
% \begin{macrocode} |
| 2186 |
\let\fillANotB\fillOnlyA |
| 2187 |
% \end{macrocode} |
| 2188 |
% Fill $B$ but not $A$ (same as only $B$ for two sets). |
| 2189 |
%\changes{1.1}{2016-03-16}{made \cs{fillBNotA} a synonym for |
| 2190 |
%\cs{fillOnlyB}} |
| 2191 |
% \begin{macrocode} |
| 2192 |
\let\fillBNotA\fillOnlyB |
| 2193 |
% \end{macrocode} |
| 2194 |
% Fill $A$ intersect $B$ |
| 2195 |
% \begin{macrocode} |
| 2196 |
\def\fillACapB{% |
| 2197 |
\begin{scope} |
| 2198 |
\clip (\@venn@Ax,\@venn@Ay) circle (\@venn@radius); |
| 2199 |
\path[fill=\@venn@shade] |
| 2200 |
(\@venn@Bx,\@venn@By) circle (\@venn@radius); |
| 2201 |
\end{scope} |
| 2202 |
}% |
| 2203 |
% \end{macrocode} |
| 2204 |
% Define synonym: |
| 2205 |
% \begin{macrocode} |
| 2206 |
\let\fillBCapA\fillACapB |
| 2207 |
% \end{macrocode} |
| 2208 |
% Start the \env{tikzpicture} environment. |
| 2209 |
% \begin{macrocode} |
| 2210 |
\ifdefempty{\@venn@tikzoptions}% |
| 2211 |
{% |
| 2212 |
\def\@venn@dobegin{\begin{tikzpicture}}% |
| 2213 |
}% |
| 2214 |
{% |
| 2215 |
\edef\@venn@dobegin{\noexpand\begin{tikzpicture}% |
| 2216 |
[\expandonce\@venn@tikzoptions]}% |
| 2217 |
}% |
| 2218 |
\@venn@dobegin |
| 2219 |
% \end{macrocode} |
| 2220 |
% coordinates of the Venn diagram corners |
| 2221 |
% \begin{macrocode} |
| 2222 |
\path (0,0) coordinate (venn bottom left) |
| 2223 |
(0,\@venn@h) coordinate (venn top left) |
| 2224 |
(\@venn@w,\@venn@h) coordinate (venn top right) |
| 2225 |
(\@venn@w,0) coordinate (venn bottom right); |
| 2226 |
}% |
| 2227 |
% \end{macrocode} |
| 2228 |
% End environment code |
| 2229 |
% \begin{macrocode} |
| 2230 |
{% |
| 2231 |
% \end{macrocode} |
| 2232 |
% Draw outlines |
| 2233 |
% \begin{macrocode} |
| 2234 |
\ifvennshowframe |
| 2235 |
\draw (venn bottom left) rectangle (\@venn@w,\@venn@h); |
| 2236 |
\else |
| 2237 |
\path (venn bottom left) rectangle (\@venn@w,\@venn@h); |
| 2238 |
\fi |
| 2239 |
\draw (\@venn@Ax,\@venn@Ay) circle (\@venn@radius); |
| 2240 |
\draw (\@venn@Bx,\@venn@By) circle (\@venn@radius); |
| 2241 |
% \end{macrocode} |
| 2242 |
% Draw labels |
| 2243 |
% \begin{macrocode} |
| 2244 |
\draw (\@venn@Ax,\@venn@Ay) node[above,left] (labelOnlyA) |
| 2245 |
{\@venn@label@OnlyA}; |
| 2246 |
\draw (\@venn@Bx,\@venn@By) node[above,right] (labelOnlyB) |
| 2247 |
{\@venn@label@OnlyB}; |
| 2248 |
% \end{macrocode} |
| 2249 |
% Region labels |
| 2250 |
% \begin{macrocode} |
| 2251 |
\draw (\@venn@vgap,\@venn@hgap) node (labelNotAB) {\@venn@label@NotAB}; |
| 2252 |
\draw (\@venn@Ax,\@venn@Ay+\@venn@radius) |
| 2253 |
node[below] (labelA) {\@venn@label@A}; |
| 2254 |
\draw (\@venn@Bx,\@venn@By+\@venn@radius) |
| 2255 |
node[below] (labelB) {\@venn@label@B}; |
| 2256 |
\draw (0.5*\@venn@w,0.5*\@venn@h) node (labelAB) {\@venn@label@AB}; |
| 2257 |
\@postvennhook |
| 2258 |
\end{tikzpicture} |
| 2259 |
} |
| 2260 |
% \end{macrocode} |
| 2261 |
%\end{environment} |
| 2262 |
% |
| 2263 |
%\begin{macro}{\@venn@fillOnlyA@twosets} |
| 2264 |
%\changes{1.1}{2016-03-16}{new} |
| 2265 |
%\cs{fillOnlyA} is set to this for the two set version. |
| 2266 |
% Reimplemented in v1.1 to use new circle intersect code. |
| 2267 |
% \begin{macrocode} |
| 2268 |
\newcommand*\@venn@fillOnlyA@twosets{% |
| 2269 |
% \end{macrocode} |
| 2270 |
% Get the intersection points between $A$ and $B$. |
| 2271 |
% \begin{macrocode} |
| 2272 |
\@venn@computecircleintersects{\@venn@Ax}{\@venn@Ay}{\@venn@Bx}{\@venn@By}% |
| 2273 |
% \end{macrocode} |
| 2274 |
% If there aren't two points of intersection, then the circles don't |
| 2275 |
% overlap. |
| 2276 |
% \begin{macrocode} |
| 2277 |
\ifnum\@venn@intersect@n=2\relax |
| 2278 |
% \end{macrocode} |
| 2279 |
% Compute the start angle for the first arc. |
| 2280 |
% \begin{macrocode} |
| 2281 |
\pgfmathsetlength{\dimen@i}{\@venn@intersect@i@x-\@venn@Ax}% |
| 2282 |
\pgfmathsetlength{\dimen@ii}{\@venn@intersect@i@y-\@venn@Ay}% |
| 2283 |
\ifvennoldpgf |
| 2284 |
\pgfmathatantwo{\dimen@i}{\dimen@ii}% |
| 2285 |
\else |
| 2286 |
\pgfmathatantwo{\dimen@ii}{\dimen@i}% |
| 2287 |
\fi |
| 2288 |
\let\@venn@start@i@angle\pgfmathresult |
| 2289 |
% \end{macrocode} |
| 2290 |
% Compute the end angle for the first arc. |
| 2291 |
% \begin{macrocode} |
| 2292 |
\pgfmathsetlength{\dimen@i}{\@venn@intersect@ii@x-\@venn@Ax}% |
| 2293 |
\pgfmathsetlength{\dimen@ii}{\@venn@intersect@ii@y-\@venn@Ay}% |
| 2294 |
\ifvennoldpgf |
| 2295 |
\pgfmathatantwo{\dimen@i}{\dimen@ii}% |
| 2296 |
\else |
| 2297 |
\pgfmathatantwo{\dimen@ii}{\dimen@i}% |
| 2298 |
\fi |
| 2299 |
\let\@venn@end@i@angle\pgfmathresult |
| 2300 |
\pgfmathadd{\@venn@end@i@angle}{360}% |
| 2301 |
\let\@venn@end@i@angle\pgfmathresult |
| 2302 |
% \end{macrocode} |
| 2303 |
% Compute the start angle for the second arc. |
| 2304 |
% \begin{macrocode} |
| 2305 |
\pgfmathsetlength{\dimen@i}{\@venn@intersect@ii@x-\@venn@Bx}% |
| 2306 |
\pgfmathsetlength{\dimen@ii}{\@venn@intersect@ii@y-\@venn@By}% |
| 2307 |
\ifvennoldpgf |
| 2308 |
\pgfmathatantwo{\dimen@i}{\dimen@ii}% |
| 2309 |
\else |
| 2310 |
\pgfmathatantwo{\dimen@ii}{\dimen@i}% |
| 2311 |
\fi |
| 2312 |
\let\@venn@start@ii@angle\pgfmathresult |
| 2313 |
% \end{macrocode} |
| 2314 |
% Compute the end angle for the second arc. |
| 2315 |
% \begin{macrocode} |
| 2316 |
\pgfmathsetlength{\dimen@i}{\@venn@intersect@i@x-\@venn@Bx}% |
| 2317 |
\pgfmathsetlength{\dimen@ii}{\@venn@intersect@i@y-\@venn@By}% |
| 2318 |
\ifvennoldpgf |
| 2319 |
\pgfmathatantwo{\dimen@i}{\dimen@ii}% |
| 2320 |
\else |
| 2321 |
\pgfmathatantwo{\dimen@ii}{\dimen@i}% |
| 2322 |
\fi |
| 2323 |
\let\@venn@end@ii@angle\pgfmathresult |
| 2324 |
\pgfmathadd{\@venn@start@ii@angle}{360}% |
| 2325 |
\let\@venn@start@ii@angle\pgfmathresult |
| 2326 |
% \end{macrocode} |
| 2327 |
% Fill the path |
| 2328 |
% \begin{macrocode} |
| 2329 |
\path[fill=\@venn@shade] |
| 2330 |
(\@venn@intersect@i@x,\@venn@intersect@i@y) |
| 2331 |
arc[radius=\@venn@radius,start angle=\@venn@start@i@angle, |
| 2332 |
end angle=\@venn@end@i@angle] |
| 2333 |
arc[radius=\@venn@radius,start angle=\@venn@start@ii@angle, |
| 2334 |
end angle=\@venn@end@ii@angle] |
| 2335 |
-- cycle; |
| 2336 |
\else |
| 2337 |
\fillOnlyA |
| 2338 |
\fi |
| 2339 |
}% |
| 2340 |
% \end{macrocode} |
| 2341 |
%\end{macro} |
| 2342 |
% |
| 2343 |
%\begin{macro}{\@venn@fillOnlyB@twosets} |
| 2344 |
%\changes{1.1}{2016-03-16}{new} |
| 2345 |
%\cs{fillOnlyB} is set to this for the two set version. |
| 2346 |
% Reimplemented in v1.1 to use new circle intersect code. |
| 2347 |
% \begin{macrocode} |
| 2348 |
\newcommand*\@venn@fillOnlyB@twosets{% |
| 2349 |
% \end{macrocode} |
| 2350 |
% Get the intersection points between $A$ and $B$. |
| 2351 |
% \begin{macrocode} |
| 2352 |
\@venn@computecircleintersects{\@venn@Ax}{\@venn@Ay}{\@venn@Bx}{\@venn@By}% |
| 2353 |
% \end{macrocode} |
| 2354 |
% If there aren't two points of intersection, then the circles don't |
| 2355 |
% overlap. |
| 2356 |
% \begin{macrocode} |
| 2357 |
\ifnum\@venn@intersect@n=2\relax |
| 2358 |
% \end{macrocode} |
| 2359 |
% Compute the start angle for the first arc. |
| 2360 |
% \begin{macrocode} |
| 2361 |
\pgfmathsetlength{\dimen@i}{\@venn@intersect@i@x-\@venn@Bx}% |
| 2362 |
\pgfmathsetlength{\dimen@ii}{\@venn@intersect@i@y-\@venn@By}% |
| 2363 |
\ifvennoldpgf |
| 2364 |
\pgfmathatantwo{\dimen@i}{\dimen@ii}% |
| 2365 |
\else |
| 2366 |
\pgfmathatantwo{\dimen@ii}{\dimen@i}% |
| 2367 |
\fi |
| 2368 |
\let\@venn@start@i@angle\pgfmathresult |
| 2369 |
% \end{macrocode} |
| 2370 |
% Compute the end angle for the first arc. |
| 2371 |
% \begin{macrocode} |
| 2372 |
\pgfmathsetlength{\dimen@i}{\@venn@intersect@ii@x-\@venn@Bx}% |
| 2373 |
\pgfmathsetlength{\dimen@ii}{\@venn@intersect@ii@y-\@venn@By}% |
| 2374 |
\ifvennoldpgf |
| 2375 |
\pgfmathatantwo{\dimen@i}{\dimen@ii}% |
| 2376 |
\else |
| 2377 |
\pgfmathatantwo{\dimen@ii}{\dimen@i}% |
| 2378 |
\fi |
| 2379 |
\let\@venn@end@i@angle\pgfmathresult |
| 2380 |
% \pgfmathadd{\@venn@end@i@angle}{360}% |
| 2381 |
% \let\@venn@end@i@angle\pgfmathresult |
| 2382 |
% \end{macrocode} |
| 2383 |
% Compute the start angle for the second arc. |
| 2384 |
% \begin{macrocode} |
| 2385 |
\pgfmathsetlength{\dimen@i}{\@venn@intersect@ii@x-\@venn@Ax}% |
| 2386 |
\pgfmathsetlength{\dimen@ii}{\@venn@intersect@ii@y-\@venn@Ay}% |
| 2387 |
\ifvennoldpgf |
| 2388 |
\pgfmathatantwo{\dimen@i}{\dimen@ii}% |
| 2389 |
\else |
| 2390 |
\pgfmathatantwo{\dimen@ii}{\dimen@i}% |
| 2391 |
\fi |
| 2392 |
\let\@venn@start@ii@angle\pgfmathresult |
| 2393 |
% \end{macrocode} |
| 2394 |
% Compute the end angle for the second arc. |
| 2395 |
% \begin{macrocode} |
| 2396 |
\pgfmathsetlength{\dimen@i}{\@venn@intersect@i@x-\@venn@Ax}% |
| 2397 |
\pgfmathsetlength{\dimen@ii}{\@venn@intersect@i@y-\@venn@Ay}% |
| 2398 |
\ifvennoldpgf |
| 2399 |
\pgfmathatantwo{\dimen@i}{\dimen@ii}% |
| 2400 |
\else |
| 2401 |
\pgfmathatantwo{\dimen@ii}{\dimen@i}% |
| 2402 |
\fi |
| 2403 |
\let\@venn@end@ii@angle\pgfmathresult |
| 2404 |
% \pgfmathadd{\@venn@start@ii@angle}{360}% |
| 2405 |
% \let\@venn@start@ii@angle\pgfmathresult |
| 2406 |
% \end{macrocode} |
| 2407 |
% Fill the path |
| 2408 |
% \begin{macrocode} |
| 2409 |
\path[fill=\@venn@shade] |
| 2410 |
(\@venn@intersect@i@x,\@venn@intersect@i@y) |
| 2411 |
arc[radius=\@venn@radius,start angle=\@venn@start@i@angle, |
| 2412 |
end angle=\@venn@end@i@angle] |
| 2413 |
arc[radius=\@venn@radius,start angle=\@venn@start@ii@angle, |
| 2414 |
end angle=\@venn@end@ii@angle] |
| 2415 |
-- cycle; |
| 2416 |
\else |
| 2417 |
\fillOnlyB |
| 2418 |
\fi |
| 2419 |
}% |
| 2420 |
% \end{macrocode} |
| 2421 |
%\end{macro} |
| 2422 |
%\iffalse |
| 2423 |
% \begin{macrocode} |
| 2424 |
%</venndiagram.sty> |
| 2425 |
% \end{macrocode} |
| 2426 |
%\fi |
| 2427 |
%\Finale |
| 2428 |
\endinput |