% Figures by Thomas Hull and Inna Zakharevich

\documentclass{amsart}
% Comment the following line to NOT allow the usage of umlauts
\usepackage[utf8]{inputenc}
\usepackage{fullpage}
\usepackage{tikz}
\usepackage{amssymb}
\usepackage{caption}
\usepackage{xcolor}
\usepackage{lscape}
\usepackage{tabularray}
\usepackage{subfig}
\usepackage[utf8]{inputenc}
\usepackage{fullpage}
\usepackage{tikz}
\usepackage{xcolor}
\usepackage{ifthen}

\tikzset{
  mountain/.style = {thick},
  valley/.style = {thick, densely dashed},
  mountain_opt/.style = {thick, color=blue!70!black},
  valley_opt/.style = {thick, densely dashed, color=blue!70!black},
  opt/.style = {thick, color=green!70!black},
  flow/.style = {mountain,decorate, decoration={markings, mark= between positions 0 and 1 step 10pt with {\arrow{stealth}}}},
  gridline/.style = {color=gray!50!white},
  logic/.style = {line width=1.73205080757cm},
}

\usetikzlibrary{calc}

\colorlet{A}{blue!60!white}
\colorlet{notA}{blue!30!white}
\colorlet{jA}{blue!20!gray!30!white}
\colorlet{B}{red!65!white}
\colorlet{notB}{red!30!white}
\colorlet{jB}{red!20!gray!30!white}
\colorlet{C}{green!60!gray}
\colorlet{notC}{green!42!white!70}
\colorlet{jC}{green!20!gray!30!white}
\colorlet{info}{orange!60!white}
\colorlet{jinfo}{orange!20!gray!30!white}
\colorlet{OUT}{purple!60!white}
\colorlet{notOUT}{purple!30!white}
\colorlet{jOUT}{purple!20!gray!30!white}
\colorlet{annotation}{green!40!black}
\colorlet{junk}{gray!30!white}
\colorlet{twist}{yellow!40!white}

%%%% LABELING

\newcommand{\yeslabelnodes}{\def\labelnodes{1}}
\newcommand{\nolabelnodes}{\def\labelnodes{0}}
\def\labelnodes{0} % default is off

\newcommand{\labelthis}[1]{\ifthenelse{\equal{\labelnodes}{1}}{\node[fill=white]
    at #1 { #1};}{}}

%%%% WIRES
\newcommand{\wire}[3][white]{\draw[logic, color=#1] #2 -- #3; \draw[flow] #2 --
  #3;}
\newcommand{\jwire}[3][junk]{\draw[logic, color=#1] #2 -- #3;}


%%%% GADGETS
\newcommand{\hexagon}{+(1,0.5) -- +(0,1) -- +(-1,0.5) -- +(-1,-0.5) -- +(0,-1) --
  +(1,-0.5) -- cycle}

\newcommand{\hextwist}[1]{\draw[fill=twist] #1 \hexagon; \draw[valley_opt] #1
  +(1,0.5) -- +(1,1.5) -- +(0,1) -- +(-1,1.5) -- +(-1,0.5) -- +(-2,0) --
  +(-1,-0.5) -- +(-1,-1.5) -- +(0,-1) -- +(1,-1.5) -- +(1,-0.5) -- +(2,0) --
  cycle; \labelthis{#1}}
\newcommand{\eaterUp}[1]{\draw[valley_opt, fill=white] #1 \hexagon; \draw #1 +(0,1) --
  +(-1,-0.5) -- +(1,-0.5) -- cycle; \node at #1 {E}; \labelthis{#1}}
\newcommand{\eaterDown}[1]{\draw[valley_opt, fill=white] #1 \hexagon; \draw #1 +(1,0.5) --
  +(-1,0.5) -- +(0,-1) -- cycle; \node at #1 {E}; \labelthis{#1}}
\newcommand{\triUp}[1]{\draw[valley_opt, fill=white] #1 \hexagon; \draw[fill=twist] #1 +(0,1) --
  +(-1,-0.5) -- +(1,-0.5) -- cycle; \labelthis{#1}}
\newcommand{\triDown}[1]{\draw[valley_opt, fill=white] #1 \hexagon; \draw[fill=twist] #1 +(1,0.5) --
  +(-1,0.5) -- +(0,-1) -- cycle; \labelthis{#1}}
\newcommand{\intersect}[2]{ \draw[fill=white] #1 \hexagon #2 \hexagon;
  \draw[thick] #1 \hexagon; \draw[thick] #2 \hexagon; \labelthis{#1} \labelthis{#2}}

\newcommand{\nand}[1]{\draw [fill=white] #1 \hexagon; \node at #1 {NAND}; \labelthis{#1}}
\newcommand{\nor}[1]{\draw [fill=white] #1 \hexagon; \node at #1 {NOR};
  \labelthis{#1}}
\newcommand{\orgate}[1]{\draw [fill=white] #1 \hexagon; \node at #1 {OR};
  \labelthis{#1}}
\newcommand{\andgate}[1]{\draw [fill=white] #1 \hexagon; \node at #1 {AND};
  \labelthis{#1}}


\newcommand{\qgate}[1]{\draw [fill=white] #1 \hexagon; \node at #1 {???}; \labelthis{#1}}


%%% formulas

\newcommand{\scnand}{\mathrel{\textsc{nand}}}
\newcommand{\scnor}{\mathrel{\textsc{nor}}}
\newcommand{\scor}{\mathrel{\textsc{or}}}


\usetikzlibrary{decorations}
\usetikzlibrary{decorations.pathmorphing}
\usetikzlibrary{ decorations.markings}
\usetikzlibrary{calc}

\def\gridsize{60}
\def\topEnd{26}
\def\bottomEnd{-36}


\tikzset{
  mountain/.style = {thick},
  valley/.style = {thick, densely dashed},
  mountain_opt/.style = {thick, color=blue!70!black},
  valley_opt/.style = {thick, densely dashed, color=blue!70!black},
  opt/.style = {thick, color=green!70!black}
}

\title{Origami Logic Gadgets}
\author[Hull]{Thomas C. Hull}
\address{Franklin \& Marshall College}
\curraddr{}
\email{thomas.hull@fandm.edu}
\thanks{}

\author[Zakharevich]{Inna Zakharevich}
\address{Cornell University}
\curraddr{}
\email{zakh@math.cornell.edu}
\thanks{}


\begin{document}

\maketitle
\section*{Key}

\begin{center}
\begin{tikzpicture}[yscale=0.5]  % key
\draw[mountain] (0,0) -- (0.5,0) node[right] {mountain};
\draw[valley] (0,-1) -- (0.5,-1) node[right] {valley};
\draw[mountain_opt] (0,-2) -- (0.5,-2) node[right] {optional mountain};
\draw[valley_opt] (0,-3) -- (0.5,-3) node[right] {optional valley};

\draw[mountain] (5,0) -- (7.5,-2);
\draw[valley_opt] (6,0) -- (8.5,-2);
\draw[valley_opt] (4,0) -- (6.5,-2);
\draw [-stealth](7,-.2) -- (8.5,-1.4);
\node at (6.5,-2.5){a wire};
\end{tikzpicture}
\end{center}

\section*{Notes}

The important gates (OR, AND, NOR, NAND, and NOT) each get a page; each gadget
is repeated 4 times, to aid in printing and experimentation.  The intersectors,
twists, and eaters are important if you're trying to construct large patterns
(such as Rule 110) but are not necessary for just experimenting with gates
independently.  They are each repeated twice.

\textbf{It is important to remember that none of the creases are bidirectional:
  each black crease MUST be folded, and each blue crease can either be flat, or
  folded in the specified direction.}

The last page contains the map for how to place gates to make an XOR pattern.
If the TRUE side of wires is colored one color and the FALSE side another, a
tiling of these should produce a Sierpinski triangle (if the folder is
determined enough and the paper is large enough).

If you come up with other gadgets, or just want to show us something you folded,
we'd love to see them!  In particular, a simpler XOR pattern (or an XOR gadget!)
would be very exciting.  Email is at \verb|thull1@fandm.edu| or
\verb|zakh@math.cornell.edu|.

\tableofcontents

\newpage

\section*{OR}

\vfill

\begin{tikzpicture}
% first draw the bidirectional twist
\draw[mountain] (30:0) -- (30:3.5)
                (150:0) -- (150:3.5)
                (0,0) -- (0,-3.5);
\draw[valley_opt] (30:1) -- +(0,-4)
                  (30:1) -- +(150:4)
                  (150:1) -- +(30:4)
                  (150:1) -- +(0,-4)
                  (0,-1) -- +(30:4)
                  (0,-1) -- +(150:4);
% then add control folds
\draw [valley_opt] (0,0) -- (0,1)
                   (0,0) -- (-30:1)
                   (30:0.5) -- (-30:1)
                   (30:2) -- (-30:1)
                   (0,0) -- (-150:1);
\draw[mountain_opt] (150:1) -- (-150:1)                   
                    (30:1) -- (-30:1)
                    (30:0.5) -- (0,1)
                    (30:2) -- (0,1)
                    (-30:1) -- (0,-1);


                    
%input/output labels
\path (0,0.5) +(150:3) node[rotate=-30] (Fin1) {FALSE};
\draw[->] (Fin1) -- +(-30:1);
\path (0,-0.5) +(150:3.5) node[rotate=-30] (Tin1) {TRUE};
\draw[->] (Tin1) -- +(-30:1);
\path (0,-0.5) +(30:3.5) node[rotate=30] (Fin2) {FALSE};
\draw[->] (Fin2) -- +(-150:1);
\path (0,0.5) +(30:3) node[rotate=30] (Fin2) {TRUE};
\draw[->] (Fin2) -- +(-150:1);
\path (-30:0.5) -- +(0,-3) node[rotate=-90] (Tout) {FALSE};
\path (-150:0.5) -- +(0,-3) node[rotate=-90] (Fout) {TRUE};
\draw[->] (Fout) -- +(0,-1);
\draw[->] (Tout) -- +(0,-1);


\end{tikzpicture}
\hfill
\begin{tikzpicture}
% first draw the bidirectional twist
\draw[mountain] (30:0) -- (30:3.5)
                (150:0) -- (150:3.5)
                (0,0) -- (0,-3.5);
\draw[valley_opt] (30:1) -- +(0,-4)
                  (30:1) -- +(150:4)
                  (150:1) -- +(30:4)
                  (150:1) -- +(0,-4)
                  (0,-1) -- +(30:4)
                  (0,-1) -- +(150:4);
% then add control folds
\draw [valley_opt] (0,0) -- (0,1)
                   (0,0) -- (-30:1)
                   (30:0.5) -- (-30:1)
                   (30:2) -- (-30:1)
                   (0,0) -- (-150:1);
\draw[mountain_opt] (150:1) -- (-150:1)                   
                    (30:1) -- (-30:1)
                    (30:0.5) -- (0,1)
                    (30:2) -- (0,1)
                    (-30:1) -- (0,-1);


                    
%input/output labels
\path (0,0.5) +(150:3) node[rotate=-30] (Fin1) {FALSE};
\draw[->] (Fin1) -- +(-30:1);
\path (0,-0.5) +(150:3.5) node[rotate=-30] (Tin1) {TRUE};
\draw[->] (Tin1) -- +(-30:1);
\path (0,-0.5) +(30:3.5) node[rotate=30] (Fin2) {FALSE};
\draw[->] (Fin2) -- +(-150:1);
\path (0,0.5) +(30:3) node[rotate=30] (Fin2) {TRUE};
\draw[->] (Fin2) -- +(-150:1);
\path (-30:0.5) -- +(0,-3) node[rotate=-90] (Tout) {FALSE};
\path (-150:0.5) -- +(0,-3) node[rotate=-90] (Fout) {TRUE};
\draw[->] (Fout) -- +(0,-1);
\draw[->] (Tout) -- +(0,-1);


\end{tikzpicture}

\vfill
\begin{tikzpicture}
% first draw the bidirectional twist
\draw[mountain] (30:0) -- (30:3.5)
                (150:0) -- (150:3.5)
                (0,0) -- (0,-3.5);
\draw[valley_opt] (30:1) -- +(0,-4)
                  (30:1) -- +(150:4)
                  (150:1) -- +(30:4)
                  (150:1) -- +(0,-4)
                  (0,-1) -- +(30:4)
                  (0,-1) -- +(150:4);
% then add control folds
\draw [valley_opt] (0,0) -- (0,1)
                   (0,0) -- (-30:1)
                   (30:0.5) -- (-30:1)
                   (30:2) -- (-30:1)
                   (0,0) -- (-150:1);
\draw[mountain_opt] (150:1) -- (-150:1)                   
                    (30:1) -- (-30:1)
                    (30:0.5) -- (0,1)
                    (30:2) -- (0,1)
                    (-30:1) -- (0,-1);


                    
%input/output labels
\path (0,0.5) +(150:3) node[rotate=-30] (Fin1) {FALSE};
\draw[->] (Fin1) -- +(-30:1);
\path (0,-0.5) +(150:3.5) node[rotate=-30] (Tin1) {TRUE};
\draw[->] (Tin1) -- +(-30:1);
\path (0,-0.5) +(30:3.5) node[rotate=30] (Fin2) {FALSE};
\draw[->] (Fin2) -- +(-150:1);
\path (0,0.5) +(30:3) node[rotate=30] (Fin2) {TRUE};
\draw[->] (Fin2) -- +(-150:1);
\path (-30:0.5) -- +(0,-3) node[rotate=-90] (Tout) {FALSE};
\path (-150:0.5) -- +(0,-3) node[rotate=-90] (Fout) {TRUE};
\draw[->] (Fout) -- +(0,-1);
\draw[->] (Tout) -- +(0,-1);


\end{tikzpicture}
\hfill
\begin{tikzpicture}
% first draw the bidirectional twist
\draw[mountain] (30:0) -- (30:3.5)
                (150:0) -- (150:3.5)
                (0,0) -- (0,-3.5);
\draw[valley_opt] (30:1) -- +(0,-4)
                  (30:1) -- +(150:4)
                  (150:1) -- +(30:4)
                  (150:1) -- +(0,-4)
                  (0,-1) -- +(30:4)
                  (0,-1) -- +(150:4);
% then add control folds
\draw [valley_opt] (0,0) -- (0,1)
                   (0,0) -- (-30:1)
                   (30:0.5) -- (-30:1)
                   (30:2) -- (-30:1)
                   (0,0) -- (-150:1);
\draw[mountain_opt] (150:1) -- (-150:1)                   
                    (30:1) -- (-30:1)
                    (30:0.5) -- (0,1)
                    (30:2) -- (0,1)
                    (-30:1) -- (0,-1);


                    
%input/output labels
\path (0,0.5) +(150:3) node[rotate=-30] (Fin1) {FALSE};
\draw[->] (Fin1) -- +(-30:1);
\path (0,-0.5) +(150:3.5) node[rotate=-30] (Tin1) {TRUE};
\draw[->] (Tin1) -- +(-30:1);
\path (0,-0.5) +(30:3.5) node[rotate=30] (Fin2) {FALSE};
\draw[->] (Fin2) -- +(-150:1);
\path (0,0.5) +(30:3) node[rotate=30] (Fin2) {TRUE};
\draw[->] (Fin2) -- +(-150:1);
\path (-30:0.5) -- +(0,-3) node[rotate=-90] (Tout) {FALSE};
\path (-150:0.5) -- +(0,-3) node[rotate=-90] (Fout) {TRUE};
\draw[->] (Fout) -- +(0,-1);
\draw[->] (Tout) -- +(0,-1);


\end{tikzpicture}

\newpage

\section*{AND}

\vfill

\begin{tikzpicture}
% first draw the bidirectional twist
\draw[mountain] (30:0) -- (30:3.5)
                (150:0) -- (150:3.5)
                (0,0) -- (0,-3.5);
\draw[valley_opt] (30:1) -- +(0,-4)
                  (30:1) -- +(150:4)
                  (150:1) -- +(30:4)
                  (150:1) -- +(0,-4)
                  (0,-1) -- +(30:4)
                  (0,-1) -- +(150:4);
% then add control folds
\draw [valley_opt] (0,0) -- (0,1)
                   (0,0) -- (-30:1)
                   (150:0.5) -- (-150:1)
                   (150:2) -- (-150:1)
                   (0,0) -- (-150:1);
\draw[mountain_opt] (30:1) -- (-30:1)                   
                    (-150:1) -- (0,-1)
                    (-150:1) -- (150:1)
                    (150:0.5) -- (0,1)
                    (150:2) -- (0,1);

                    
%input/output labels
\path (0,0.5) +(150:3) node[rotate=-30] (Fin1) {FALSE};
\draw[->] (Fin1) -- +(-30:1);
\path (0,-0.5) +(150:3.5) node[rotate=-30] (Tin1) {TRUE};
\draw[->] (Tin1) -- +(-30:1);
\path (0,-0.5) +(30:3.5) node[rotate=30] (Fin2) {FALSE};
\draw[->] (Fin2) -- +(-150:1);
\path (0,0.5) +(30:3) node[rotate=30] (Fin2) {TRUE};
\draw[->] (Fin2) -- +(-150:1);
\path (-30:0.5) -- +(0,-3) node[rotate=-90] (Tout) {FALSE};
\path (-150:0.5) -- +(0,-3) node[rotate=-90] (Fout) {TRUE};
\draw[->] (Fout) -- +(0,-1);
\draw[->] (Tout) -- +(0,-1);



\end{tikzpicture}
\hfill
\begin{tikzpicture}
% first draw the bidirectional twist
\draw[mountain] (30:0) -- (30:3.5)
                (150:0) -- (150:3.5)
                (0,0) -- (0,-3.5);
\draw[valley_opt] (30:1) -- +(0,-4)
                  (30:1) -- +(150:4)
                  (150:1) -- +(30:4)
                  (150:1) -- +(0,-4)
                  (0,-1) -- +(30:4)
                  (0,-1) -- +(150:4);
% then add control folds
\draw [valley_opt] (0,0) -- (0,1)
                   (0,0) -- (-30:1)
                   (150:0.5) -- (-150:1)
                   (150:2) -- (-150:1)
                   (0,0) -- (-150:1);
\draw[mountain_opt] (30:1) -- (-30:1)                   
                    (-150:1) -- (0,-1)
                    (-150:1) -- (150:1)
                    (150:0.5) -- (0,1)
                    (150:2) -- (0,1);

                    
%input/output labels
\path (0,0.5) +(150:3) node[rotate=-30] (Fin1) {FALSE};
\draw[->] (Fin1) -- +(-30:1);
\path (0,-0.5) +(150:3.5) node[rotate=-30] (Tin1) {TRUE};
\draw[->] (Tin1) -- +(-30:1);
\path (0,-0.5) +(30:3.5) node[rotate=30] (Fin2) {FALSE};
\draw[->] (Fin2) -- +(-150:1);
\path (0,0.5) +(30:3) node[rotate=30] (Fin2) {TRUE};
\draw[->] (Fin2) -- +(-150:1);
\path (-30:0.5) -- +(0,-3) node[rotate=-90] (Tout) {FALSE};
\path (-150:0.5) -- +(0,-3) node[rotate=-90] (Fout) {TRUE};
\draw[->] (Fout) -- +(0,-1);
\draw[->] (Tout) -- +(0,-1);



\end{tikzpicture}

\vfill

\begin{tikzpicture}
% first draw the bidirectional twist
\draw[mountain] (30:0) -- (30:3.5)
                (150:0) -- (150:3.5)
                (0,0) -- (0,-3.5);
\draw[valley_opt] (30:1) -- +(0,-4)
                  (30:1) -- +(150:4)
                  (150:1) -- +(30:4)
                  (150:1) -- +(0,-4)
                  (0,-1) -- +(30:4)
                  (0,-1) -- +(150:4);
% then add control folds
\draw [valley_opt] (0,0) -- (0,1)
                   (0,0) -- (-30:1)
                   (150:0.5) -- (-150:1)
                   (150:2) -- (-150:1)
                   (0,0) -- (-150:1);
\draw[mountain_opt] (30:1) -- (-30:1)                   
                    (-150:1) -- (0,-1)
                    (-150:1) -- (150:1)
                    (150:0.5) -- (0,1)
                    (150:2) -- (0,1);

                    
%input/output labels
\path (0,0.5) +(150:3) node[rotate=-30] (Fin1) {FALSE};
\draw[->] (Fin1) -- +(-30:1);
\path (0,-0.5) +(150:3.5) node[rotate=-30] (Tin1) {TRUE};
\draw[->] (Tin1) -- +(-30:1);
\path (0,-0.5) +(30:3.5) node[rotate=30] (Fin2) {FALSE};
\draw[->] (Fin2) -- +(-150:1);
\path (0,0.5) +(30:3) node[rotate=30] (Fin2) {TRUE};
\draw[->] (Fin2) -- +(-150:1);
\path (-30:0.5) -- +(0,-3) node[rotate=-90] (Tout) {FALSE};
\path (-150:0.5) -- +(0,-3) node[rotate=-90] (Fout) {TRUE};
\draw[->] (Fout) -- +(0,-1);
\draw[->] (Tout) -- +(0,-1);



\end{tikzpicture}
\hfill
\begin{tikzpicture}
% first draw the bidirectional twist
\draw[mountain] (30:0) -- (30:3.5)
                (150:0) -- (150:3.5)
                (0,0) -- (0,-3.5);
\draw[valley_opt] (30:1) -- +(0,-4)
                  (30:1) -- +(150:4)
                  (150:1) -- +(30:4)
                  (150:1) -- +(0,-4)
                  (0,-1) -- +(30:4)
                  (0,-1) -- +(150:4);
% then add control folds
\draw [valley_opt] (0,0) -- (0,1)
                   (0,0) -- (-30:1)
                   (150:0.5) -- (-150:1)
                   (150:2) -- (-150:1)
                   (0,0) -- (-150:1);
\draw[mountain_opt] (30:1) -- (-30:1)                   
                    (-150:1) -- (0,-1)
                    (-150:1) -- (150:1)
                    (150:0.5) -- (0,1)
                    (150:2) -- (0,1);

                    
%input/output labels
\path (0,0.5) +(150:3) node[rotate=-30] (Fin1) {FALSE};
\draw[->] (Fin1) -- +(-30:1);
\path (0,-0.5) +(150:3.5) node[rotate=-30] (Tin1) {TRUE};
\draw[->] (Tin1) -- +(-30:1);
\path (0,-0.5) +(30:3.5) node[rotate=30] (Fin2) {FALSE};
\draw[->] (Fin2) -- +(-150:1);
\path (0,0.5) +(30:3) node[rotate=30] (Fin2) {TRUE};
\draw[->] (Fin2) -- +(-150:1);
\path (-30:0.5) -- +(0,-3) node[rotate=-90] (Tout) {FALSE};
\path (-150:0.5) -- +(0,-3) node[rotate=-90] (Fout) {TRUE};
\draw[->] (Fout) -- +(0,-1);
\draw[->] (Tout) -- +(0,-1);



\end{tikzpicture}



\section*{NOT}

\vfill

\begin{tikzpicture}
  \draw [mountain] (0,1) -- (0,3) (0,-1) -- (0,-3);
  \draw [mountain] (-3,.5) -- (-.5,.5) (-.5,-.5) -- (-3,-.5) (3,.5) -- (.5,.5) (.5,-.5) -- (3,.-.5);
  \draw [mountain] (0,1) -- (-.5,.5) -- (-.5,-.5) -- (0,-1) -- (.5,-.5) -- (.5,.5) -- cycle;
  \draw [valley] (-3,1) -- (-1,1) (1,1) -- (3,1) (-3,-1) -- (-1,-1) (1,-1) -- (3,-1);
  \draw [valley_opt] (1,3) -- (1,1) (1,-1) -- (1,-3) (-1,3) -- (-1,1) (-1,-1) -- (-1,-3) (-1,1) -- (1,1) (-1,-1) -- (1,-1);
  \draw [valley_opt] (.5,.5) -- (1.5,-.5) (.5,-.5) -- (1.5,.5) (-.5,.5) -- (-1.5,-.5) (-.5,-.5) -- (-1.5,.5);
  \draw [valley_opt] (.5,.5) -- (1,1) (.5,-.5) -- (1,-1) (-.5,.5) -- (-1,1) (-.5,-.5) -- (-1,-1);
  \draw [mountain_opt] (1,1) -- (1.5,.5) (1,-1) -- (1.5,-.5) (-1,1) -- (-1.5,.5) (-1,-1) -- (-1.5,-.5);
  %\draw [opt] (-1,1) -- (1,1);

  %input/output labels
  \node[rotate=-90] at  (0.5,3)  (Fin) {FALSE};
  \draw[->] (Fin) -- +(0,-1);
  \node[rotate=-90] at (-0.5,3) (Tin) {TRUE};
  \draw[->] (Tin) -- +(0,-1);
  \path (-30:0.5) -- +(0,-3) node[rotate=-90] (Tout) {FALSE};
  \path (-150:0.5) -- +(0,-3) node[rotate=-90] (Fout) {TRUE};
  \draw[->] (Fout) -- +(0,-1);
  \draw[->] (Tout) -- +(0,-1);


\end{tikzpicture}
\hfill
\begin{tikzpicture}
  \draw [mountain] (0,1) -- (0,3) (0,-1) -- (0,-3);
  \draw [mountain] (-3,.5) -- (-.5,.5) (-.5,-.5) -- (-3,-.5) (3,.5) -- (.5,.5) (.5,-.5) -- (3,.-.5);
  \draw [mountain] (0,1) -- (-.5,.5) -- (-.5,-.5) -- (0,-1) -- (.5,-.5) -- (.5,.5) -- cycle;
  \draw [valley] (-3,1) -- (-1,1) (1,1) -- (3,1) (-3,-1) -- (-1,-1) (1,-1) -- (3,-1);
  \draw [valley_opt] (1,3) -- (1,1) (1,-1) -- (1,-3) (-1,3) -- (-1,1) (-1,-1) -- (-1,-3) (-1,1) -- (1,1) (-1,-1) -- (1,-1);
  \draw [valley_opt] (.5,.5) -- (1.5,-.5) (.5,-.5) -- (1.5,.5) (-.5,.5) -- (-1.5,-.5) (-.5,-.5) -- (-1.5,.5);
  \draw [valley_opt] (.5,.5) -- (1,1) (.5,-.5) -- (1,-1) (-.5,.5) -- (-1,1) (-.5,-.5) -- (-1,-1);
  \draw [mountain_opt] (1,1) -- (1.5,.5) (1,-1) -- (1.5,-.5) (-1,1) -- (-1.5,.5) (-1,-1) -- (-1.5,-.5);
  %\draw [opt] (-1,1) -- (1,1);

  %input/output labels
  \node[rotate=-90] at  (0.5,3)  (Fin) {FALSE};
  \draw[->] (Fin) -- +(0,-1);
  \node[rotate=-90] at (-0.5,3) (Tin) {TRUE};
  \draw[->] (Tin) -- +(0,-1);
  \path (-30:0.5) -- +(0,-3) node[rotate=-90] (Tout) {FALSE};
  \path (-150:0.5) -- +(0,-3) node[rotate=-90] (Fout) {TRUE};
  \draw[->] (Fout) -- +(0,-1);
  \draw[->] (Tout) -- +(0,-1);


  \end{tikzpicture}

  \vfill
  \begin{tikzpicture}
  \draw [mountain] (0,1) -- (0,3) (0,-1) -- (0,-3);
  \draw [mountain] (-3,.5) -- (-.5,.5) (-.5,-.5) -- (-3,-.5) (3,.5) -- (.5,.5) (.5,-.5) -- (3,.-.5);
  \draw [mountain] (0,1) -- (-.5,.5) -- (-.5,-.5) -- (0,-1) -- (.5,-.5) -- (.5,.5) -- cycle;
  \draw [valley] (-3,1) -- (-1,1) (1,1) -- (3,1) (-3,-1) -- (-1,-1) (1,-1) -- (3,-1);
  \draw [valley_opt] (1,3) -- (1,1) (1,-1) -- (1,-3) (-1,3) -- (-1,1) (-1,-1) -- (-1,-3) (-1,1) -- (1,1) (-1,-1) -- (1,-1);
  \draw [valley_opt] (.5,.5) -- (1.5,-.5) (.5,-.5) -- (1.5,.5) (-.5,.5) -- (-1.5,-.5) (-.5,-.5) -- (-1.5,.5);
  \draw [valley_opt] (.5,.5) -- (1,1) (.5,-.5) -- (1,-1) (-.5,.5) -- (-1,1) (-.5,-.5) -- (-1,-1);
  \draw [mountain_opt] (1,1) -- (1.5,.5) (1,-1) -- (1.5,-.5) (-1,1) -- (-1.5,.5) (-1,-1) -- (-1.5,-.5);
  %\draw [opt] (-1,1) -- (1,1);

  %input/output labels
  \node[rotate=-90] at  (0.5,3)  (Fin) {FALSE};
  \draw[->] (Fin) -- +(0,-1);
  \node[rotate=-90] at (-0.5,3) (Tin) {TRUE};
  \draw[->] (Tin) -- +(0,-1);
  \path (-30:0.5) -- +(0,-3) node[rotate=-90] (Tout) {FALSE};
  \path (-150:0.5) -- +(0,-3) node[rotate=-90] (Fout) {TRUE};
  \draw[->] (Fout) -- +(0,-1);
  \draw[->] (Tout) -- +(0,-1);


  \end{tikzpicture}
  \hfill
  \begin{tikzpicture}
  \draw [mountain] (0,1) -- (0,3) (0,-1) -- (0,-3);
  \draw [mountain] (-3,.5) -- (-.5,.5) (-.5,-.5) -- (-3,-.5) (3,.5) -- (.5,.5) (.5,-.5) -- (3,.-.5);
  \draw [mountain] (0,1) -- (-.5,.5) -- (-.5,-.5) -- (0,-1) -- (.5,-.5) -- (.5,.5) -- cycle;
  \draw [valley] (-3,1) -- (-1,1) (1,1) -- (3,1) (-3,-1) -- (-1,-1) (1,-1) -- (3,-1);
  \draw [valley_opt] (1,3) -- (1,1) (1,-1) -- (1,-3) (-1,3) -- (-1,1) (-1,-1) -- (-1,-3) (-1,1) -- (1,1) (-1,-1) -- (1,-1);
  \draw [valley_opt] (.5,.5) -- (1.5,-.5) (.5,-.5) -- (1.5,.5) (-.5,.5) -- (-1.5,-.5) (-.5,-.5) -- (-1.5,.5);
  \draw [valley_opt] (.5,.5) -- (1,1) (.5,-.5) -- (1,-1) (-.5,.5) -- (-1,1) (-.5,-.5) -- (-1,-1);
  \draw [mountain_opt] (1,1) -- (1.5,.5) (1,-1) -- (1.5,-.5) (-1,1) -- (-1.5,.5) (-1,-1) -- (-1.5,-.5);
  %\draw [opt] (-1,1) -- (1,1);

  %input/output labels
  \node[rotate=-90] at  (0.5,3)  (Fin) {FALSE};
  \draw[->] (Fin) -- +(0,-1);
  \node[rotate=-90] at (-0.5,3) (Tin) {TRUE};
  \draw[->] (Tin) -- +(0,-1);
  \path (-30:0.5) -- +(0,-3) node[rotate=-90] (Tout) {FALSE};
  \path (-150:0.5) -- +(0,-3) node[rotate=-90] (Fout) {TRUE};
  \draw[->] (Fout) -- +(0,-1);
  \draw[->] (Tout) -- +(0,-1);


  \end{tikzpicture}



\newpage

\section*{NOR}
\vfill

\begin{tikzpicture}
% first draw the bidirectional twist
\draw[mountain] (30:1) -- (30:3.5)
                (150:1) -- (150:3.5)
                (0,-1) -- (0,-3.5)
                (30:1) -- (150:1) -- (0,-1) -- cycle;
\draw[valley_opt] (30:1) -- +(0,-4)
                  (30:1) -- +(150:4)
                  (150:1) -- +(30:4)
                  (150:1) -- +(0,-4)
                  (0,-1) -- +(30:4)
                  (0,-1) -- +(150:4);
% then add control folds 
                  
\draw[valley_opt] (0,0) -- (30:1)
                  (0,0) -- (150:1)
                  (0,0) -- (0,-1)
                  (60:{sqrt(3)/3}) -- (0,1)
                  (0,0) -- (120:{sqrt(3)/3})
                  (0,0) -- (-120:{sqrt(3)/3})
                  (-{sqrt(3)/3},0) -- (-150:1);
\draw[mountain_opt] (120:{sqrt(3)/3}) -- (0,1)
                    (0,0) -- (60:{sqrt(3)/3})
                    (0,0) -- ({-sqrt(3)/3},0)
                    (-150:1) -- (-120:{sqrt(3)/3})
                    ;

%input/output labels
\path (0,0.5) +(150:3) node[rotate=-30] (Fin1) {FALSE};
\draw[->] (Fin1) -- +(-30:1);
\path (0,-0.5) +(150:3.5) node[rotate=-30] (Tin1) {TRUE};
\draw[->] (Tin1) -- +(-30:1);
\path (0,-0.5) +(30:3.5) node[rotate=30] (Fin2) {FALSE};
\draw[->] (Fin2) -- +(-150:1);
\path (0,0.5) +(30:3) node[rotate=30] (Fin2) {TRUE};
\draw[->] (Fin2) -- +(-150:1);
\path (-30:0.5) -- +(0,-3) node[rotate=-90] (Fout) {FALSE};
\path (-150:0.5) -- +(0,-3) node[rotate=-90] (Tout) {TRUE};
\draw[->] (Fout) -- +(0,-1);
\draw[->] (Tout) -- +(0,-1);


\end{tikzpicture}\hfill
\begin{tikzpicture}
% first draw the bidirectional twist
\draw[mountain] (30:1) -- (30:3.5)
                (150:1) -- (150:3.5)
                (0,-1) -- (0,-3.5)
                (30:1) -- (150:1) -- (0,-1) -- cycle;
\draw[valley_opt] (30:1) -- +(0,-4)
                  (30:1) -- +(150:4)
                  (150:1) -- +(30:4)
                  (150:1) -- +(0,-4)
                  (0,-1) -- +(30:4)
                  (0,-1) -- +(150:4);
% then add control folds 
                  
\draw[valley_opt] (0,0) -- (30:1)
                  (0,0) -- (150:1)
                  (0,0) -- (0,-1)
                  (60:{sqrt(3)/3}) -- (0,1)
                  (0,0) -- (120:{sqrt(3)/3})
                  (0,0) -- (-120:{sqrt(3)/3})
                  (-{sqrt(3)/3},0) -- (-150:1);
\draw[mountain_opt] (120:{sqrt(3)/3}) -- (0,1)
                    (0,0) -- (60:{sqrt(3)/3})
                    (0,0) -- ({-sqrt(3)/3},0)
                    (-150:1) -- (-120:{sqrt(3)/3})
                    ;

%input/output labels
\path (0,0.5) +(150:3) node[rotate=-30] (Fin1) {FALSE};
\draw[->] (Fin1) -- +(-30:1);
\path (0,-0.5) +(150:3.5) node[rotate=-30] (Tin1) {TRUE};
\draw[->] (Tin1) -- +(-30:1);
\path (0,-0.5) +(30:3.5) node[rotate=30] (Fin2) {FALSE};
\draw[->] (Fin2) -- +(-150:1);
\path (0,0.5) +(30:3) node[rotate=30] (Fin2) {TRUE};
\draw[->] (Fin2) -- +(-150:1);
\path (-30:0.5) -- +(0,-3) node[rotate=-90] (Fout) {FALSE};
\path (-150:0.5) -- +(0,-3) node[rotate=-90] (Tout) {TRUE};
\draw[->] (Fout) -- +(0,-1);
\draw[->] (Tout) -- +(0,-1);
\end{tikzpicture}

\vfill

\begin{tikzpicture}
% first draw the bidirectional twist
\draw[mountain] (30:1) -- (30:3.5)
                (150:1) -- (150:3.5)
                (0,-1) -- (0,-3.5)
                (30:1) -- (150:1) -- (0,-1) -- cycle;
\draw[valley_opt] (30:1) -- +(0,-4)
                  (30:1) -- +(150:4)
                  (150:1) -- +(30:4)
                  (150:1) -- +(0,-4)
                  (0,-1) -- +(30:4)
                  (0,-1) -- +(150:4);
% then add control folds 
                  
\draw[valley_opt] (0,0) -- (30:1)
                  (0,0) -- (150:1)
                  (0,0) -- (0,-1)
                  (60:{sqrt(3)/3}) -- (0,1)
                  (0,0) -- (120:{sqrt(3)/3})
                  (0,0) -- (-120:{sqrt(3)/3})
                  (-{sqrt(3)/3},0) -- (-150:1);
\draw[mountain_opt] (120:{sqrt(3)/3}) -- (0,1)
                    (0,0) -- (60:{sqrt(3)/3})
                    (0,0) -- ({-sqrt(3)/3},0)
                    (-150:1) -- (-120:{sqrt(3)/3})
                    ;

%input/output labels
\path (0,0.5) +(150:3) node[rotate=-30] (Fin1) {FALSE};
\draw[->] (Fin1) -- +(-30:1);
\path (0,-0.5) +(150:3.5) node[rotate=-30] (Tin1) {TRUE};
\draw[->] (Tin1) -- +(-30:1);
\path (0,-0.5) +(30:3.5) node[rotate=30] (Fin2) {FALSE};
\draw[->] (Fin2) -- +(-150:1);
\path (0,0.5) +(30:3) node[rotate=30] (Fin2) {TRUE};
\draw[->] (Fin2) -- +(-150:1);
\path (-30:0.5) -- +(0,-3) node[rotate=-90] (Fout) {FALSE};
\path (-150:0.5) -- +(0,-3) node[rotate=-90] (Tout) {TRUE};
\draw[->] (Fout) -- +(0,-1);
\draw[->] (Tout) -- +(0,-1);


\end{tikzpicture}\hfill
\begin{tikzpicture}
% first draw the bidirectional twist
\draw[mountain] (30:1) -- (30:3.5)
                (150:1) -- (150:3.5)
                (0,-1) -- (0,-3.5)
                (30:1) -- (150:1) -- (0,-1) -- cycle;
\draw[valley_opt] (30:1) -- +(0,-4)
                  (30:1) -- +(150:4)
                  (150:1) -- +(30:4)
                  (150:1) -- +(0,-4)
                  (0,-1) -- +(30:4)
                  (0,-1) -- +(150:4);
% then add control folds 
                  
\draw[valley_opt] (0,0) -- (30:1)
                  (0,0) -- (150:1)
                  (0,0) -- (0,-1)
                  (60:{sqrt(3)/3}) -- (0,1)
                  (0,0) -- (120:{sqrt(3)/3})
                  (0,0) -- (-120:{sqrt(3)/3})
                  (-{sqrt(3)/3},0) -- (-150:1);
\draw[mountain_opt] (120:{sqrt(3)/3}) -- (0,1)
                    (0,0) -- (60:{sqrt(3)/3})
                    (0,0) -- ({-sqrt(3)/3},0)
                    (-150:1) -- (-120:{sqrt(3)/3})
                    ;

%input/output labels
\path (0,0.5) +(150:3) node[rotate=-30] (Fin1) {FALSE};
\draw[->] (Fin1) -- +(-30:1);
\path (0,-0.5) +(150:3.5) node[rotate=-30] (Tin1) {TRUE};
\draw[->] (Tin1) -- +(-30:1);
\path (0,-0.5) +(30:3.5) node[rotate=30] (Fin2) {FALSE};
\draw[->] (Fin2) -- +(-150:1);
\path (0,0.5) +(30:3) node[rotate=30] (Fin2) {TRUE};
\draw[->] (Fin2) -- +(-150:1);
\path (-30:0.5) -- +(0,-3) node[rotate=-90] (Fout) {FALSE};
\path (-150:0.5) -- +(0,-3) node[rotate=-90] (Tout) {TRUE};
\draw[->] (Fout) -- +(0,-1);
\draw[->] (Tout) -- +(0,-1);


\end{tikzpicture}



\newpage
\section*{NAND}

\vfill

\begin{tikzpicture}
% first draw the bidirectional twist
\draw[mountain] (30:1) -- (30:3.5)
                (150:1) -- (150:3.5)
                (0,-1) -- (0,-3.5)
                (30:1) -- (150:1) -- (0,-1) -- cycle;
\draw[valley_opt] (30:1) -- +(0,-4)
                  (30:1) -- +(150:4)
                  (150:1) -- +(30:4)
                  (150:1) -- +(0,-4)
                  (0,-1) -- +(30:4)
                  (0,-1) -- +(150:4);

% then add control folds
\draw[valley_opt] (0,0) -- (30:1)
                  (0,0) -- (150:1)
                  (0,0) -- (0,-1)
                  (120:{sqrt(3)/3}) -- (0,1)
                  (0,0) -- (60:{sqrt(3)/3})
                  (0,0) -- (-60:{sqrt(3)/3})
                  ({sqrt(3)/3},0) -- (-30:1);
\draw[mountain_opt] (60:{sqrt(3)/3}) -- (0,1)
                    (0,0) -- (120:{sqrt(3)/3})
                    (0,0) -- ({sqrt(3)/3},0)
                    (-30:1) -- (-60:{sqrt(3)/3})
                    ;
                    

% input/output labels
\path (0,0.5) +(150:3) node[rotate=-30] (Fin1) {FALSE};
\draw[->] (Fin1) -- +(-30:1);
\path (0,-0.5) +(150:3.5) node[rotate=-30] (Tin1) {TRUE};
\draw[->] (Tin1) -- +(-30:1);
\path (0,-0.5) +(30:3.5) node[rotate=30] (Fin2) {FALSE};
\draw[->] (Fin2) -- +(-150:1);
\path (0,0.5) +(30:3) node[rotate=30] (Fin2) {TRUE};
\draw[->] (Fin2) -- +(-150:1);
\path (-30:0.5) -- +(0,-3) node[rotate=-90] (Tout) {FALSE};
\path (-150:0.5) -- +(0,-3) node[rotate=-90] (Fout) {TRUE};
\draw[->] (Fout) -- +(0,-1);
\draw[->] (Tout) -- +(0,-1);

\end{tikzpicture}\hfill
\begin{tikzpicture}
% first draw the bidirectional twist
\draw[mountain] (30:1) -- (30:3.5)
                (150:1) -- (150:3.5)
                (0,-1) -- (0,-3.5)
                (30:1) -- (150:1) -- (0,-1) -- cycle;
\draw[valley_opt] (30:1) -- +(0,-4)
                  (30:1) -- +(150:4)
                  (150:1) -- +(30:4)
                  (150:1) -- +(0,-4)
                  (0,-1) -- +(30:4)
                  (0,-1) -- +(150:4);

% then add control folds
\draw[valley_opt] (0,0) -- (30:1)
                  (0,0) -- (150:1)
                  (0,0) -- (0,-1)
                  (120:{sqrt(3)/3}) -- (0,1)
                  (0,0) -- (60:{sqrt(3)/3})
                  (0,0) -- (-60:{sqrt(3)/3})
                  ({sqrt(3)/3},0) -- (-30:1);
\draw[mountain_opt] (60:{sqrt(3)/3}) -- (0,1)
                    (0,0) -- (120:{sqrt(3)/3})
                    (0,0) -- ({sqrt(3)/3},0)
                    (-30:1) -- (-60:{sqrt(3)/3})
                    ;
                    

% input/output labels
\path (0,0.5) +(150:3) node[rotate=-30] (Fin1) {FALSE};
\draw[->] (Fin1) -- +(-30:1);
\path (0,-0.5) +(150:3.5) node[rotate=-30] (Tin1) {TRUE};
\draw[->] (Tin1) -- +(-30:1);
\path (0,-0.5) +(30:3.5) node[rotate=30] (Fin2) {FALSE};
\draw[->] (Fin2) -- +(-150:1);
\path (0,0.5) +(30:3) node[rotate=30] (Fin2) {TRUE};
\draw[->] (Fin2) -- +(-150:1);
\path (-30:0.5) -- +(0,-3) node[rotate=-90] (Tout) {FALSE};
\path (-150:0.5) -- +(0,-3) node[rotate=-90] (Fout) {TRUE};
\draw[->] (Fout) -- +(0,-1);
\draw[->] (Tout) -- +(0,-1);

\end{tikzpicture}

\vfill

\begin{tikzpicture}
% first draw the bidirectional twist
\draw[mountain] (30:1) -- (30:3.5)
                (150:1) -- (150:3.5)
                (0,-1) -- (0,-3.5)
                (30:1) -- (150:1) -- (0,-1) -- cycle;
\draw[valley_opt] (30:1) -- +(0,-4)
                  (30:1) -- +(150:4)
                  (150:1) -- +(30:4)
                  (150:1) -- +(0,-4)
                  (0,-1) -- +(30:4)
                  (0,-1) -- +(150:4);

% then add control folds
\draw[valley_opt] (0,0) -- (30:1)
                  (0,0) -- (150:1)
                  (0,0) -- (0,-1)
                  (120:{sqrt(3)/3}) -- (0,1)
                  (0,0) -- (60:{sqrt(3)/3})
                  (0,0) -- (-60:{sqrt(3)/3})
                  ({sqrt(3)/3},0) -- (-30:1);
\draw[mountain_opt] (60:{sqrt(3)/3}) -- (0,1)
                    (0,0) -- (120:{sqrt(3)/3})
                    (0,0) -- ({sqrt(3)/3},0)
                    (-30:1) -- (-60:{sqrt(3)/3})
                    ;
                    

% input/output labels
\path (0,0.5) +(150:3) node[rotate=-30] (Fin1) {FALSE};
\draw[->] (Fin1) -- +(-30:1);
\path (0,-0.5) +(150:3.5) node[rotate=-30] (Tin1) {TRUE};
\draw[->] (Tin1) -- +(-30:1);
\path (0,-0.5) +(30:3.5) node[rotate=30] (Fin2) {FALSE};
\draw[->] (Fin2) -- +(-150:1);
\path (0,0.5) +(30:3) node[rotate=30] (Fin2) {TRUE};
\draw[->] (Fin2) -- +(-150:1);
\path (-30:0.5) -- +(0,-3) node[rotate=-90] (Tout) {FALSE};
\path (-150:0.5) -- +(0,-3) node[rotate=-90] (Fout) {TRUE};
\draw[->] (Fout) -- +(0,-1);
\draw[->] (Tout) -- +(0,-1);

\end{tikzpicture}\hfill
\begin{tikzpicture}
% first draw the bidirectional twist
\draw[mountain] (30:1) -- (30:3.5)
                (150:1) -- (150:3.5)
                (0,-1) -- (0,-3.5)
                (30:1) -- (150:1) -- (0,-1) -- cycle;
\draw[valley_opt] (30:1) -- +(0,-4)
                  (30:1) -- +(150:4)
                  (150:1) -- +(30:4)
                  (150:1) -- +(0,-4)
                  (0,-1) -- +(30:4)
                  (0,-1) -- +(150:4);

% then add control folds
\draw[valley_opt] (0,0) -- (30:1)
                  (0,0) -- (150:1)
                  (0,0) -- (0,-1)
                  (120:{sqrt(3)/3}) -- (0,1)
                  (0,0) -- (60:{sqrt(3)/3})
                  (0,0) -- (-60:{sqrt(3)/3})
                  ({sqrt(3)/3},0) -- (-30:1);
\draw[mountain_opt] (60:{sqrt(3)/3}) -- (0,1)
                    (0,0) -- (120:{sqrt(3)/3})
                    (0,0) -- ({sqrt(3)/3},0)
                    (-30:1) -- (-60:{sqrt(3)/3})
                    ;
                    

% input/output labels
\path (0,0.5) +(150:3) node[rotate=-30] (Fin1) {FALSE};
\draw[->] (Fin1) -- +(-30:1);
\path (0,-0.5) +(150:3.5) node[rotate=-30] (Tin1) {TRUE};
\draw[->] (Tin1) -- +(-30:1);
\path (0,-0.5) +(30:3.5) node[rotate=30] (Fin2) {FALSE};
\draw[->] (Fin2) -- +(-150:1);
\path (0,0.5) +(30:3) node[rotate=30] (Fin2) {TRUE};
\draw[->] (Fin2) -- +(-150:1);
\path (-30:0.5) -- +(0,-3) node[rotate=-90] (Tout) {FALSE};
\path (-150:0.5) -- +(0,-3) node[rotate=-90] (Fout) {TRUE};
\draw[->] (Fout) -- +(0,-1);
\draw[->] (Tout) -- +(0,-1);

\end{tikzpicture}


\newpage



\section*{The intersectors}

\subsection*{$\pi/3$ intersector}$\hbox{ }$

\vfill

  \begin{tikzpicture}

  \draw[mountain] (120:4) -- (-60:3);
  \draw[valley_opt] (120:4)++(1,0) -- +(-60:6);
  \draw[valley_opt] (120:4)++(-120:1) -- +(-60:6);

  \draw[valley_opt] (0,0) -- (3,0);
  \draw[mountain] (60:1) -- +(3,0);
  \draw[valley_opt] (120:2) -- +(4,0);
  
  \draw[mountain] (-1,0) -- (-3.3,0);
  \draw[valley_opt] (-1,0) ++(120:1) -- +(-2,0);
  \draw[valley_opt] (-120:1) -- +(-3,0);

  \draw[mountain_opt] (120:2) -- +(-120:1);
  \draw[mountain_opt] (60:1) -- (120:1);
  \draw[valley_opt] (120:1) -- +(-120:1);
  \draw[mountain_opt] (0,0) -- (-120:1);
  \draw[valley_opt] (120:1) -- +(-1,0);
  \draw[mountain_opt] (0,0) -- (-1,0);
  \draw[mountain_opt] (120:1) -- +(60:1);
  \draw[valley_opt] (0,0) -- (60:1);
  \draw[valley_opt] (-120:1) -- (-60:1);
  \draw[mountain_opt] (-60:1) -- (1,0);
  % input/output labels

  \path (0.5,0) +(120:4)  node[rotate=-60] (Fin1) {FALSE};
  \path (-0.5,0) +(120:3.5)  node[rotate=-60] (Tin1) {TRUE};
  \draw[->] (Fin1) -- +(-60:1);
  \draw[->] (Tin1) -- +(-60:1);
  \path (0.5,0) +(120:-2.5)  node[rotate=-60] (Fout1) {FALSE};
  \path (-0.5,0) +(120:-2.5)  node[rotate=-60] (Tout1) {TRUE};
  \draw[->] (Fout1) -- +(-60:1);
  \draw[->] (Tout1) -- +(-60:1);

  \path (-3,0) +(120:0.5) node (Fin2) {FALSE};
  \path (-3.5,0) +(-60:0.5) node (Tin2) {TRUE};
  \draw[->] (Fin2) -- +(1,0);
  \draw[->] (Tin2) -- +(1,0);
  \path (2,0) +(60:1.5) node (Fout2) {FALSE};
  \path (2.5,0) +(60:0.5) node (Tout2) {TRUE};
  \draw[->] (Fout2) -- +(1,0);
  \draw[->] (Tout2) -- +(1,0);
  
  % important points
\end{tikzpicture}
\hfill
  \begin{tikzpicture}

  \draw[mountain] (120:4) -- (-60:3);
  \draw[valley_opt] (120:4)++(1,0) -- +(-60:6);
  \draw[valley_opt] (120:4)++(-120:1) -- +(-60:6);

  \draw[valley_opt] (0,0) -- (3,0);
  \draw[mountain] (60:1) -- +(3,0);
  \draw[valley_opt] (120:2) -- +(4,0);
  
  \draw[mountain] (-1,0) -- (-3.3,0);
  \draw[valley_opt] (-1,0) ++(120:1) -- +(-2,0);
  \draw[valley_opt] (-120:1) -- +(-3,0);

  \draw[mountain_opt] (120:2) -- +(-120:1);
  \draw[mountain_opt] (60:1) -- (120:1);
  \draw[valley_opt] (120:1) -- +(-120:1);
  \draw[mountain_opt] (0,0) -- (-120:1);
  \draw[valley_opt] (120:1) -- +(-1,0);
  \draw[mountain_opt] (0,0) -- (-1,0);
  \draw[mountain_opt] (120:1) -- +(60:1);
  \draw[valley_opt] (0,0) -- (60:1);
  \draw[valley_opt] (-120:1) -- (-60:1);
  \draw[mountain_opt] (-60:1) -- (1,0);
  % input/output labels

  \path (0.5,0) +(120:4)  node[rotate=-60] (Fin1) {FALSE};
  \path (-0.5,0) +(120:3.5)  node[rotate=-60] (Tin1) {TRUE};
  \draw[->] (Fin1) -- +(-60:1);
  \draw[->] (Tin1) -- +(-60:1);
  \path (0.5,0) +(120:-2.5)  node[rotate=-60] (Fout1) {FALSE};
  \path (-0.5,0) +(120:-2.5)  node[rotate=-60] (Tout1) {TRUE};
  \draw[->] (Fout1) -- +(-60:1);
  \draw[->] (Tout1) -- +(-60:1);

  \path (-3,0) +(120:0.5) node (Fin2) {FALSE};
  \path (-3.5,0) +(-60:0.5) node (Tin2) {TRUE};
  \draw[->] (Fin2) -- +(1,0);
  \draw[->] (Tin2) -- +(1,0);
  \path (2,0) +(60:1.5) node (Fout2) {FALSE};
  \path (2.5,0) +(60:0.5) node (Tout2) {TRUE};
  \draw[->] (Fout2) -- +(1,0);
  \draw[->] (Tout2) -- +(1,0);
  
  % important points
\end{tikzpicture}

\vfill

\subsection*{$2\pi/3$ intersector}$\hbox{ }$

\vfill


\begin{tikzpicture}[baseline=0, scale=0.85]
\begin{scope}[rotate=60]
  \draw[mountain] (120:4) -- (-60:3);
  \draw[valley_opt] (120:4)++(1,0) -- +(-60:6);
  \draw[valley_opt] (120:4)++(-120:1) -- +(-60:6);

  \draw[valley_opt] (0,0) -- (3,0);
  \draw[mountain] (60:1) -- +(3,0);
  \draw[valley_opt] (120:2) -- +(4,0);
  
  \draw[mountain] (-1,0) -- (-3.3,0);
  \draw[valley_opt] (-1,0) ++(120:1) -- +(-2,0);
  \draw[valley_opt] (-120:1) -- +(-3,0);

  \draw[mountain_opt] (120:2) -- +(-120:1);
  \draw[mountain_opt] (60:1) -- (120:1);
  \draw[valley_opt] (120:1) -- +(-120:1);
  \draw[mountain_opt] (0,0) -- (-120:1);
  \draw[valley_opt] (120:1) -- +(-1,0);
  \draw[mountain_opt] (0,0) -- (-1,0);
  \draw[mountain_opt] (120:1) -- +(60:1);
  \draw[valley_opt] (0,0) -- (60:1);
  \draw[valley_opt] (-120:1) -- (-60:1);
  \draw[mountain_opt] (-60:1) -- (1,0);
  % input/output labels
  \end{scope}

  \path (-0.5,0) +(60:3.5)  node[rotate=60] (Fin1) {FALSE};
  \path (-1.5,0) +(60:4)  node[rotate=60] (Tin1) {TRUE};
  \draw[->] (Fin1) -- +(-120:1);
  \draw[->] (Tin1) -- +(-120:1);
  \path (0.5,0) +(60:-3)  node[rotate=60] (Fout1) {FALSE};
  \path (-0.5,0) +(60:-3)  node[rotate=60] (Tout1) {TRUE};
  \draw[->] (Fout1) -- +(-120:1);
  \draw[->] (Tout1) -- +(-120:1);

  \path (-3,0) +(120:0.5) node (Fin2) {FALSE};
  \path (-3.5,0) +(-60:0.5) node (Tin2) {TRUE};
  \draw[->] (Fin2) -- +(1,0);
  \draw[->] (Tin2) -- +(1,0);
  \path (2,0) +(60:0.5)  node (Fout2) {FALSE};
  \path (2,0) +(-60:0.5) node (Tout2) {TRUE};
  \draw[->] (Fout2) -- +(1,0);
  \draw[->] (Tout2) -- +(1,0);
  

\end{tikzpicture}
\hfill
\begin{tikzpicture}[baseline=0, scale=0.85]
\begin{scope}[rotate=60]
  \draw[mountain] (120:4) -- (-60:3);
  \draw[valley_opt] (120:4)++(1,0) -- +(-60:6);
  \draw[valley_opt] (120:4)++(-120:1) -- +(-60:6);

  \draw[valley_opt] (0,0) -- (3,0);
  \draw[mountain] (60:1) -- +(3,0);
  \draw[valley_opt] (120:2) -- +(4,0);
  
  \draw[mountain] (-1,0) -- (-3.3,0);
  \draw[valley_opt] (-1,0) ++(120:1) -- +(-2,0);
  \draw[valley_opt] (-120:1) -- +(-3,0);

  \draw[mountain_opt] (120:2) -- +(-120:1);
  \draw[mountain_opt] (60:1) -- (120:1);
  \draw[valley_opt] (120:1) -- +(-120:1);
  \draw[mountain_opt] (0,0) -- (-120:1);
  \draw[valley_opt] (120:1) -- +(-1,0);
  \draw[mountain_opt] (0,0) -- (-1,0);
  \draw[mountain_opt] (120:1) -- +(60:1);
  \draw[valley_opt] (0,0) -- (60:1);
  \draw[valley_opt] (-120:1) -- (-60:1);
  \draw[mountain_opt] (-60:1) -- (1,0);
  % input/output labels
  \end{scope}

  \path (-0.5,0) +(60:3.5)  node[rotate=60] (Fin1) {FALSE};
  \path (-1.5,0) +(60:4)  node[rotate=60] (Tin1) {TRUE};
  \draw[->] (Fin1) -- +(-120:1);
  \draw[->] (Tin1) -- +(-120:1);
  \path (0.5,0) +(60:-3)  node[rotate=60] (Fout1) {FALSE};
  \path (-0.5,0) +(60:-3)  node[rotate=60] (Tout1) {TRUE};
  \draw[->] (Fout1) -- +(-120:1);
  \draw[->] (Tout1) -- +(-120:1);

  \path (-3,0) +(120:0.5) node (Fin2) {FALSE};
  \path (-3.5,0) +(-60:0.5) node (Tin2) {TRUE};
  \draw[->] (Fin2) -- +(1,0);
  \draw[->] (Tin2) -- +(1,0);
  \path (2,0) +(60:0.5)  node (Fout2) {FALSE};
  \path (2,0) +(-60:0.5) node (Tout2) {TRUE};
  \draw[->] (Fout2) -- +(1,0);
  \draw[->] (Tout2) -- +(1,0);
  

\end{tikzpicture}


\newpage

\section*{Twists}

\subsection*{Hexagonal twist}$\hbox{ }$

\vfill

\begin{tikzpicture}
  \draw[mountain] (30:1) -- (0,1) -- (150:1) -- (-150:1) -- (0,-1) -- (-30:1) --
  cycle;
  \draw[mountain] (30:1) -- +(30:2) (0,1) -- +(0,2) (150:1) -- +(150:2) (0,-1)
  -- +(0,-2) (-150:1) -- +(-150:2) (0,-1) -- +(0,-2) (-30:1) -- +(-30:2);
  \draw[valley_opt] (30:1) -- +(0,2) (30:1) -- +(-30:2)
                    (0,1) -- +(30:2) (0,1) -- +(150:2)
                    (150:1) -- +(0,2) (150:1) -- +(-150:2)
                    (-150:1) -- +(150:2) (-150:1) -- +(0,-2)
                    (0,-1) -- +(-150:2) (0,-1) -- +(-30:2)
                    (-30:1) -- +(30:2) (-30:1) -- +(0,-2);
                  \end{tikzpicture}
                  \hfill
                  \begin{tikzpicture}
  \draw[mountain] (30:1) -- (0,1) -- (150:1) -- (-150:1) -- (0,-1) -- (-30:1) --
  cycle;
  \draw[mountain] (30:1) -- +(30:2) (0,1) -- +(0,2) (150:1) -- +(150:2) (0,-1)
  -- +(0,-2) (-150:1) -- +(-150:2) (0,-1) -- +(0,-2) (-30:1) -- +(-30:2);
  \draw[valley_opt] (30:1) -- +(0,2) (30:1) -- +(-30:2)
                    (0,1) -- +(30:2) (0,1) -- +(150:2)
                    (150:1) -- +(0,2) (150:1) -- +(-150:2)
                    (-150:1) -- +(150:2) (-150:1) -- +(0,-2)
                    (0,-1) -- +(-150:2) (0,-1) -- +(-30:2)
                    (-30:1) -- +(30:2) (-30:1) -- +(0,-2);
                  \end{tikzpicture}

                  \vfill


                  \subsection*{Triangular Twist}$\hbox{ }$

                  \vfill

\begin{tikzpicture}[rotate=180]
  \draw[mountain] (30:1) -- (150:1) -- (0,-1) -- cycle;
  \draw[mountain] (30:1) -- +(30:2) (150:1) -- +(150:2) (0,-1) -- +(0,-2);
  \draw[valley_opt] (30:1) -- +(150:3) (30:1) -- +(0,-3)
                    (150:1) -- +(30:3) (150:1) -- +(0,-3)
                    (0,-1) -- +(30:3) (0,-1) -- +(150:3);
  
  

                  \end{tikzpicture}
                  \hfill
                  \begin{tikzpicture}[rotate=180]
  \draw[mountain] (30:1) -- (150:1) -- (0,-1) -- cycle;
  \draw[mountain] (30:1) -- +(30:2) (150:1) -- +(150:2) (0,-1) -- +(0,-2);
  \draw[valley_opt] (30:1) -- +(150:3) (30:1) -- +(0,-3)
                    (150:1) -- +(30:3) (150:1) -- +(0,-3)
                    (0,-1) -- +(30:3) (0,-1) -- +(150:3);
  
  

\end{tikzpicture}

\newpage

\section*{The Eater}

\begin{tikzpicture}
% first draw the bidirectional twist
\draw[mountain] (30:1) -- (30:3.5)
                (150:1) -- (150:3.5)
                (0,-1) -- (0,-3.5)
                (30:1) -- (150:1) -- (0,-1) -- cycle;
\draw[valley_opt] (30:1) -- +(0,-4)
                  (30:1) -- +(150:4)
                  (150:1) -- +(30:4)
                  (150:1) -- +(0,-4)
                  (0,-1) -- +(30:4)
                  (0,-1) -- +(150:4);
% then add control folds
\draw[valley_opt] (0,0) -- (30:1)
                  (0,0) -- (150:1)
                  (0,0) -- (0,-1);
\draw[valley_opt] (0,0) -- (0,0.5)
                  (0,0) -- (-150:0.5)
                  (0,0) -- (-30:0.5);

\draw[mountain_opt]   (0,0.5) -- (0,1)
                    (-150:0.5) -- (-150:1)
                    (-30:0.5) -- (-30:1);
%\draw[opt] (150:1) -- (0, 1) -- (30:1) -- (-30:1) -- (0,-1) -- (-150:1) -- cycle;


%input/output labels
% \path (0,0.5) +(150:3) node[rotate=-30] (Fin1) {FALSE};
% \draw[->] (Fin1) -- +(-30:1);
% \path (0,-0.5) +(150:3.5) node[rotate=-30] (Tin1) {TRUE};
% \draw[->] (Tin1) -- +(-30:1);
% \path (0,-0.5) +(30:3.5) node[rotate=30] (Fin2) {FALSE};
% \draw[->] (Fin2) -- +(-150:1);
% \path (0,0.5) +(30:3) node[rotate=30] (Fin2) {TRUE};
% \draw[->] (Fin2) -- +(-150:1);
% \path (-30:0.5) -- +(0,-3) node[rotate=-90] (Fout) {FALSE};
% \path (-150:0.5) -- +(0,-3) node[rotate=-90] (Tout) {TRUE};
% \draw[->] (Fout) -- +(0,-1);
% \draw[->] (Tout) -- +(0,-1);

                  \end{tikzpicture}
                  \hfill
                  \begin{tikzpicture}
% first draw the bidirectional twist
\draw[mountain] (30:1) -- (30:3.5)
                (150:1) -- (150:3.5)
                (0,-1) -- (0,-3.5)
                (30:1) -- (150:1) -- (0,-1) -- cycle;
\draw[valley_opt] (30:1) -- +(0,-4)
                  (30:1) -- +(150:4)
                  (150:1) -- +(30:4)
                  (150:1) -- +(0,-4)
                  (0,-1) -- +(30:4)
                  (0,-1) -- +(150:4);
% then add control folds
\draw[valley_opt] (0,0) -- (30:1)
                  (0,0) -- (150:1)
                  (0,0) -- (0,-1);
\draw[valley_opt] (0,0) -- (0,0.5)
                  (0,0) -- (-150:0.5)
                  (0,0) -- (-30:0.5);

\draw[mountain_opt]   (0,0.5) -- (0,1)
                    (-150:0.5) -- (-150:1)
                    (-30:0.5) -- (-30:1);
%\draw[opt] (150:1) -- (0, 1) -- (30:1) -- (-30:1) -- (0,-1) -- (-150:1) -- cycle;


%input/output labels
% \path (0,0.5) +(150:3) node[rotate=-30] (Fin1) {FALSE};
% \draw[->] (Fin1) -- +(-30:1);
% \path (0,-0.5) +(150:3.5) node[rotate=-30] (Tin1) {TRUE};
% \draw[->] (Tin1) -- +(-30:1);
% \path (0,-0.5) +(30:3.5) node[rotate=30] (Fin2) {FALSE};
% \draw[->] (Fin2) -- +(-150:1);
% \path (0,0.5) +(30:3) node[rotate=30] (Fin2) {TRUE};
% \draw[->] (Fin2) -- +(-150:1);
% \path (-30:0.5) -- +(0,-3) node[rotate=-90] (Fout) {FALSE};
% \path (-150:0.5) -- +(0,-3) node[rotate=-90] (Tout) {TRUE};
% \draw[->] (Fout) -- +(0,-1);
% \draw[->] (Tout) -- +(0,-1);

\end{tikzpicture}

\newpage


\section*{The XOR pattern}
\thispagestyle{empty} The colored stripes are wires carrying information.  The
yellow shapes are appropriately-chosen twists.  The triangles labeled ``E'' are
eaters; the gates are labeled with their names.  To tessellate this is it
imporant to note that the left-hand and right-hand side are not aligned, so
adjascent cells need to be reflected (but keeping the gates both NAND).  (Since
the output is symmetric in $A$ and $B$, the reflection does not affect the
output of the cell.)


\begin{center}
  \scalebox{0.9}{
  \begin{tikzpicture}[xscale=0.86602540378]
  % base grid
  \clip (-3.5,0) rectangle (19.5,-21);

  \foreach \x in {-4,-3,...,\gridsize} {
    \draw[gridline] (\x,2) -- (\x,-\gridsize);
  }
  \foreach \y in {\gridsize,...,-\gridsize} {
    \draw[gridline] (-4,\y-1) -- +(\gridsize+2,{(\gridsize+2)/2});
    \draw[gridline] (-4,\y+1) -- +(\gridsize+2,{(-\gridsize-2)/2});
  }

  %%%%%%% WIRES

  % junk wires
  \jwire{(0,-5)}{(6,-2)}
  \jwire{(6,-2)}{(6,5)}
  \jwire{(10,-2)}{(10,5)}
  \jwire{(8,-3)}{(6,-2)}
  \jwire{(8,-3)}{(10,-2)}
  \jwire{(16,-5)}{(10,-2)}
  \jwire{(8,-3)}{(8,-5)}
  \jwire{(8,-5)}{(4,-7)}
  \jwire{(8,-5)}{(12,-7)}
  \jwire{(0,-5)}{(-4,-3)}
  \jwire{(16,-5)}{(20,-3)}
  \jwire{(0,-11)}{(0,-15)}
  \jwire{(16,-11)}{(16,-16)}
  \jwire{(0,-15)}{(2,-16)}
  \jwire{(0,-15)}{(-2,-16)}
  \jwire{(2,-16)}{(4,-15)}
  \jwire{(2,-16)}{(2,-24)}
  \jwire{(-2,-16)}{(-2,-24)}
  \jwire{(16,-16)}{(14,-17)}
  \jwire{(16,-16)}{(18,-17)}
  \jwire{(11,-15.5)}{(14,-17)}
  \jwire{(14,-17)}{(14,-24)}
  \jwire{(18,-17)}{(18,-24)}
  \jwire{(18,-17)}{(20,-16)}
  \jwire{(-2,-16)}{(-4,-15)}

  % info wires
  \wire[notA]{(0,-5)}{(0,-11)}
  \wire[notA]{(0,-5)}{(4,-7)}
  \wire[notA]{(0,-5)}{(-4,-7)}
  \wire[A]{(0,5)}{(0,-5)}
  \wire[notB]{(16,-5)}{(20,-7)}
  \wire[notB]{(16,-5)}{(12,-7)}
  \wire[notB]{(16,-5)}{(16,-11)}
  \wire[B]{(16,5)}{(16,-5)}
  \wire[A]{(4,-7)}{(4,-9)}
  \wire[B]{(12,-7)}{(12,-9)}
  \wire[notA]{(4,-9)}{(0,-11)}
  \wire[notA]{(4,-9)}{(8,-11)}
  \wire[notA]{(-4,-9)}{(0,-11)}
  \wire[notA]{(7,-11.5)}{(11,-13.5)}
  \wire[notB]{(12,-9)}{(16,-11)}
  \wire[notB]{(20,-9)}{(16,-11)}
  \wire[notB]{(12,-9)}{(4,-13)}
  \wire[A]{(0,-11)}{(4,-13)}
  \wire[A]{(0,-11)}{(-4,-13)}
  \wire[B]{(16,-11)}{(11,-13.5)}
  \wire[B]{(16,-11)}{(21,-13.5)}
  \wire[info]{(4,-13)}{(4,-15)}
  \wire[info]{(4,-15)}{(8,-17)}
  \wire[info]{(11,-13.5)}{(11,-15.5)}
  \wire[info]{(11,-15.5)}{(8,-17)}
  \wire[OUT]{(8,-17)}{(8,-24)}

  %%%%%%% GATES

  \hextwist{(0,-5)}
  \hextwist{(0,-11)}
  \hextwist{(16,-5)}
  \hextwist{(16,-11)}
  \triDown{(4,-7)}
  \triUp{(4,-9)}
  \triDown{(12,-7)}
  \triUp{(12,-9)}
  \eaterUp{(8,-5)}
  \eaterDown{(8,-3)}
  \eaterUp{(6,-2)}
  \eaterUp{(10,-2)}
  \intersect{(8,-11)}{(7,-11.5)}
  \nand{(4,-13)}
  \triUp{(4,-15)}
  \eaterDown{(2,-16)}
  \eaterUp{(0,-15)}
  \eaterDown{(-2,-16)}
  \nand{(11,-13.5)}
  \triUp{(11,-15.5)}
  \nor{(8,-17)}
  \eaterDown{(14,-17)}
  \eaterUp{(16,-16)}
  \eaterDown{(18,-17)}

  %%%%%%%%%%%%%% ANNOTATIONS
  %\draw[very thick, color=annotation] (2.5,-11.5) rectangle (5.5,-16.5);
  %\node[annotation, fill=white, draw] at (4,-16.5) {A and !B};
  %\draw[very thick, color=annotation] (9.5,-12) rectangle (12.5,-17);
  %\node[annotation, fill=white, draw] at (11,-17) {!A and B};

  \node[annotation, fill=white, align=center] at (8, -20) {A == B};
  \draw[line width=0.5mm, color=green!60!black, dashed] (0,-1) rectangle (16,-18);
  \node[annotation, circle, fill=white] at (0,-1) {A};
  \node[annotation, circle, fill=white] at (16,-1) {B};

  %\draw[very thick, color=annotation] (12.5,-14.5) rectangle (19.5,-18.5);
  %\node[annotation, fill=white, align=center, draw] at (16,-18.5) {0.5 offset \\ need to reflect \\
  %  consecutive units};

  
\end{tikzpicture}}

\end{center}

\end{document}
