%%
%% This is file `ptolemaicastronomy.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% ptolemaicastronomy.dtx  (with options: `package')
%% 
%% ptolemaicastronomy
%% ==================
%% 
%% Diagrams of sphere models for variably strict conditionals (Lewis
%% counterfactuals)
%% 
%% Author: Richard Zach
%% E-mail: rzach@ucalgary.ca
%% License: Released under the LaTeX Project Public License v1.3c or later
%% See: http://www.latex-project.org/lppl.txt
%% 
%% David K. Lewis (Counterfactuals, Blackwell 1973) introduced a sphere
%% semantics for counterfactual conditionals. He jokingly referred to the
%% diagrams depicting such sphere models as Ptolemaic astronomy, hence
%% the name of this package. It has nothing to do with Ptolemy or with
%% astronomy, sorry.
%% 
%% The macros provided in this package aid in the construction of
%% sphere model diagrams in the style of Lewis. The macros all make use
%% of TikZ.
%% 
%% for documentation and source code see
%% https://github.com/rzach/ptolemaic-astronomy
%% 
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{ptolemaicastronomy}
    [2018/04/08 v1.00 Diagrams of sphere models for variably strict conditionals (Lewis counterfactuals)]














\RequirePackage{tikz}

\tikzset{
  sphere/.style = {dotted},
  sphere intersection/.style = {fill=lightgray},
  sphere layer/.style = {fill=lightgray},
  proposition/.style={smooth,tension=1.7},
}
\pgfkeyssetvalue{/tikz/layerwidth}{.5}
\pgfkeyssetvalue{/tikz/innerfactor}{.4}
\newcommand{\sphereplot}[1]{
  circle
    [radius=(#1)*\pgfkeysvalueof{/tikz/layerwidth}-
      \pgfkeysvalueof{/tikz/layerwidth}*\pgfkeysvalueof{/tikz/innerfactor}]
}
\newcommand{\spheresystem}[2][]{
  \foreach \i in {1,...,#2}{
    \draw[sphere,#1] \sphereplot{\i} ;
  }
}

\newcommand{\spherelayer}[2][]{
  \begin{scope}[even odd rule]
    \fill[#1,sphere layer]
    \sphereplot{#2-1} \sphereplot{#2} ;
  \end{scope}
}
\newcommand{\spherefill}[2][]{
    \fill[sphere intersection,#1]
    \sphereplot{#2} ;
}
\newcommand{\sphereintersect}[3][]{
  \begin{scope}[even odd rule]
    \path[clip] #3;
    \spherefill[#1]{#2}
  \end{scope}
}
\newcommand{\propositionplot}[4]{
  plot [proposition]
  coordinates {+(#1+#3/2:#4)
    +(#1:#2*\pgfkeysvalueof{/tikz/layerwidth}-
    \pgfkeysvalueof{/tikz/layerwidth}*.9
    -\pgfkeysvalueof{/tikz/layerwidth}*\pgfkeysvalueof{/tikz/innerfactor})
    +(#1-#3/2:#4)}
}
\newcommand{\proposition}[5][]{
  \draw[proposition,#1] \propositionplot {#2}{#3}{#4}{#5} ;
  }
\newcommand{\propositionintersect}[5][]{
  \begin{scope}
  \path[clip] \propositionplot{#2}{#3}{#4}{#5};
  \spherefill[#1]{#3}
  \end{scope}
  \draw[proposition,#1] \propositionplot{#2}{#3}{#4}{#5};
}
\newcommand{\spherepos}[4][]{
  \begin{scope}[shift=(#2:#3*\pgfkeysvalueof{/tikz/layerwidth}-
      \pgfkeysvalueof{/tikz/layerwidth}/2-
        \pgfkeysvalueof{/tikz/layerwidth}*\pgfkeysvalueof{/tikz/innerfactor})]
    \path[#1] #4 ;
  \end{scope}
}
\endinput
%%
%% End of file `ptolemaicastronomy.sty'.
