From 6dd01829674e94f8b6b4829e703e6e0686f07a25 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Fri, 5 Feb 2021 03:01:00 +0000 Subject: CTAN sync 202102050301 --- graphics/pgf/contrib/kblocks/README.md | 14 +- graphics/pgf/contrib/kblocks/intro.png | Bin 0 -> 63539 bytes graphics/pgf/contrib/kblocks/kblocks-doc.pdf | Bin 164718 -> 303841 bytes graphics/pgf/contrib/kblocks/kblocks-doc.tex | 784 ++++++--- graphics/pgf/contrib/kblocks/kblocks.sty | 2265 +++++++++++++++++++++++++- 5 files changed, 2725 insertions(+), 338 deletions(-) create mode 100644 graphics/pgf/contrib/kblocks/intro.png (limited to 'graphics') diff --git a/graphics/pgf/contrib/kblocks/README.md b/graphics/pgf/contrib/kblocks/README.md index ea3b8b1263..659be0e4f6 100644 --- a/graphics/pgf/contrib/kblocks/README.md +++ b/graphics/pgf/contrib/kblocks/README.md @@ -1,7 +1,10 @@ -This is the file README for the kblocks package, v.1.0. +kblocks package, v.2.0. +![kblocks example demo diagram](/intro.png) -Description: Easily typeset Control Block Diagrams and Signal Flow Graphs with TikZ/PGF +## Description +A Macro Package to Easily typeset Control Block Diagrams and Signal Flow Graphs with TikZ/PGF +## Statement of Need Desiring to typeset control block diagrams in LaTeX and dissatisfied with the other LaTeX macro packages that can be found online, I thought: why not write my own macro package for this purpose. @@ -13,19 +16,20 @@ using TikZ/ PGF more structured and easier. This macro reduces the length of this learning curve and serves as a frontend, by focusing the theme on control block diagrams only. +## Getting Started You will find a demo and an introduction in kblocks-doc.pdf file. Fortunately this documentation in kblocks-doc.pdf as it grows and gets to be improved, will come with a number of slowly-paced tutorials, which will guide you on creating control block diagrams with the kblocks macro. +## Licensing Licensing of this package is covered by the MIT Licence. -Any feedback is welcome: oasomefun@futa.edu.ng +## Issues and Feedback My wish is that you find it helpful. Don’t forget to share and like. Please feel free to e-mail me for any improvement or suggestion with respect to using kblocks and making it useful for researchers, students and others involved in the applications and field of control theory. - -Author: Oluwasegun Somefun +Any feedback is welcome: oasomefun@futa.edu.ng. diff --git a/graphics/pgf/contrib/kblocks/intro.png b/graphics/pgf/contrib/kblocks/intro.png new file mode 100644 index 0000000000..393c4e8d65 Binary files /dev/null and b/graphics/pgf/contrib/kblocks/intro.png differ diff --git a/graphics/pgf/contrib/kblocks/kblocks-doc.pdf b/graphics/pgf/contrib/kblocks/kblocks-doc.pdf index 91229861e6..ae9827afff 100644 Binary files a/graphics/pgf/contrib/kblocks/kblocks-doc.pdf and b/graphics/pgf/contrib/kblocks/kblocks-doc.pdf differ diff --git a/graphics/pgf/contrib/kblocks/kblocks-doc.tex b/graphics/pgf/contrib/kblocks/kblocks-doc.tex index 27daa38287..fb99dabb11 100644 --- a/graphics/pgf/contrib/kblocks/kblocks-doc.tex +++ b/graphics/pgf/contrib/kblocks/kblocks-doc.tex @@ -1,10 +1,27 @@ \documentclass[onecolumn,a4paper,10pt]{IEEEtran} - +%\documentclass{article} \usepackage{kblocks} +%\tikzexternalize[prefix=figs/] % activate tikzpicture exports + \usepackage{bm} \usepackage{listings} +\usepackage{verbatim} +\usepackage{fancyvrb} % extended verbatim environments +\usepackage{fancyvrb-ex} + + +\usepackage{units} + +\usepackage{zi4} +%\usepackage{garamondx} +%\usepackage[lig=true]{baskervald} +%\usepackage{palatino} +%\def\rmdefault{zi4} +%\def\sfdefault{zi4} +\usepackage[defaultsans]{lato} + \usepackage{csquotes} \newcommand*{\kblocks}{\relax~\textit{k}\textsc{blocks}} @@ -14,24 +31,36 @@ \newcommand*{\TikzPGF}{\relax~{Ti\textit{k}Z/\textsc{pgf}}} \newcommand*{\spacetweak}{\medskip\medskip} -\begin{document} +\DefineVerbatimEnvironment +{cvl}{Verbatim} +{formatcom=\color{blue!10!black!90}, + numbers=left,numbersep=2mm,gobble=0, + frame=lines,rulecolor=\color{gray},framesep=1mm, + fontseries=,labelposition=none,fontsize=\normalsize, + xrightmargin=1cm, samepage=false} +% +\newenvironment{apilist}{ + \vspace{1ex}}% +{\vspace{1em}} +% +\newcommand{\cvhd}[1]{{ + {\subsection{#1}}{\mbox{}\break}\vspace{-5ex} +}} + +% +\fvset{formatcom=\color{darkgray}, + fontfamily=tt,fontsize=\footnotesize, fontseries=b, + frame=single,rulecolor=\color{olive},label=\fbox{A}, + numbers=left,numbersep=5pt} +%red,green,blue,cyan,magenta,yellow,black,gray,white, +%darkgray,lightgray,brown,lime,olive,orange,pink,purple,teal,violet + +\usepackage[open]{bookmark} +\newcommand*{\urlink}[1]{{ + {\texttt{\url{#1}}} +}} -\lstset{ - keywordstyle=\color{magenta}, - numberstyle=\tiny\color{gray}, - stringstyle=\color{purple}, - basicstyle=\sffamily\bfseries\scriptsize, - breakatwhitespace=false, - breaklines=true, - captionpos=b, - keepspaces=true, - numbers=left, - numbersep=5pt, - showspaces=false, - showstringspaces=false, - showtabs=false, - tabsize=2 -} +\begin{document} \title{\kblocks~Package} \author{ @@ -43,7 +72,7 @@ } -\markboth{\kblocks~Demo. Version~1.0. 13, October~2019}; +\markboth{01,~February~2021.~\kblocks~Documentation.~Version~2.0}; \maketitle @@ -53,283 +82,544 @@ can be found online, I thought: \textit{why not write my own macro package for t I wish to start with the question, \enquote{What is\kblocks?} The\kblocks~macro package is the product of using\TikzPGF~to directly typeset beautiful control block diagrams and signal flow graphs in my Masters' dissertation and papers directly with \LaTeX. -Basically, it just defines a dedicated \enquote{kblock} environment and a number of macro commands to make drawing control block diagrams using\TikzPGF~ more structured and easier. In a sense, when you +Basically, it just defines a dedicated \enquote{kblock} environment and a number of macro commands to make drawing control block diagrams with\TikzPGF{} more structured and easier. In a sense, when you use\kblocks~you \textit{program} or typeset graphics for control block diagrams, just as you “program” graphics in your document when you use \LaTeX~using\TikzPGF. The powerful options offered by\TikzPGF~often intimidates beginner users not ready to spend careful time learning about\TikzPGF. Like all \LaTeX~packages,\TikzPGF~inherits the steep learning curve of \LaTeX, that is, no \textit{what you see is what you get}. The\kblocks~macro reduces the length of this learning curve, by focusing the graphics theme on control block diagrams only. -Fortunately this documentation as it grows and gets to be improved, will come with a number of slowly-paced -tutorials, which will guide you on creating control block diagrams with\kblocks~without your having to read the\TikzPGF~manual. -My wish is that you do find it useful and helpful. Please, don't forget to share and like if you did. -I will readily welcome any e-mails for improvement or suggestion with respect to -using\kblocks~and making it useful for researchers, students and others involved in the applications and field of control theory. +Fortunately this documentation as it grows and gets to be improved, will come with a number of demos and proper documentation of the\kblocks{} API, which will guide you on creating control block diagrams with\kblocks{} without your having to read the\TikzPGF~manual. -\centering +My wish is that you do find it useful and helpful. -\section{Demos} -\subsection{}\spacetweak -\begin{kblock} - \kStartNode[$r$]{R1} - \kPlusMinusDown{R1}{S1}{0cm} - \kTFRight[0cm]{S1}{B1}{$\frac{1}{s}$} - \kMarkNodeRight[0cm]{}{B1}{N1} - \kOutRight{N1}{Y1}{$y$}{0cm} - - \kLinkVHHVAbove[0cm]{$1$}{N1}{S1}{0}{0} - \kLinkVHHVBelow[0cm]{$1$}{N1}{S1}{0}{0} - \kLink[]{R1}{S1} - \kLink[$e$]{S1}{B1} - \kLinkn[]{B1}{N1} -\end{kblock} +Please, don't forget to share and star the Github repo: \urlink{https://github.com/somefunAgba/kblocks}, if you did. -\begin{lstlisting} -\begin{kblock} - \kStartNode[$r$]{R1} - \kPlusMinusDown{R1}{S1}{0cm} - \kTFRight[0cm]{S1}{B1}{$\frac{1}{s}$} - \kMarkNodeRight[0cm]{}{B1}{N1} - \kOutRight{N1}{Y1}{$y$}{0cm} - - \kLinkVHHVAbove[0cm]{$1$}{N1}{S1}{0}{0} - \kLinkVHHVBelow[0cm]{$1$}{N1}{S1}{0}{0} - \kLink[]{R1}{S1} - \kLink[$e$]{S1}{B1} - \kLinkn[]{B1}{N1} -\end{kblock} -\end{lstlisting} +I will readily welcome any issues or emails for improvement or suggestion with respect to +using\kblocks{} and making it useful for researchers, students and others involved in the applications and field of control theory and signal processing. +\pagebreak +\section{Demos} +\centering \spacetweak - -\subsection{}\spacetweak +\subsection{Ex:A}\spacetweak +\begin{SideBySideExample}[label=\fbox{A},xrightmargin=10cm] \begin{kblock} - \kStartNodec[$r$]{(0,5)}{R1} - \kPlusMinusDown{R1}{S1}{0cm} - \kTFRight[0.33cm]{S1}{B1}{$G\left( s \right)$} - \kTFBelow[0cm]{B1}{B2}{$H\left( s \right)$} - \kMarkNodeRight[0.2cm]{}{B1}{N1} - \kOutRight{N1}{Y1}{$y$}{0} - - \kLinkVHTFHVBelow{$y$}{$\hat{y}$}{N1}{B2}{S1}{0}{0}{0} - \kLink[]{R1}{S1} - \kLink[$e$]{S1}{B1} - \kLinkn[]{B1}{N1} - - \kCoverRect[blue]{B1}{0.5cm}{1.5cm}{1.8cm}{1.5cm} - \kCoverTextRight{1cm}{0.5cm}{TX1}{Closed-loop system}; +% global ref point +\kJumpCS{init} +%% blocks +\kMarkNodeRight{0.2cm}{0cm}{$r$}{init}{rin} +\kPlusPlusMinus{rin}{sb1}{0.2cm} +\kTFRight[0.2cm]{sb1}{tfb1}{$\frac{1}{s}$} +\kMarkNodeRight{0.2cm}{0cm}{}{tfb1}{ny} +\kOutRight[0.2cm]{ny}{yout}{$y$}{0cm} +%% links +\kLink[]{rin}{sb1} +\kLink[$e$]{sb1}{tfb1} +\kLinkn[]{tfb1}{ny} +\kLinkVHHVBelow[0cm]{$1$}{ny}{sb1}{0cm}{0cm} +\kLinkVHHVAbove[0cm]{$1$}{ny}{sb1}{0cm}{0cm} \end{kblock} +\end{SideBySideExample} -\begin{lstlisting} +\subsection{Ex:B} +\spacetweak\spacetweak +\begin{SideBySideExample}[label=\fbox{B},xrightmargin=10cm] \begin{kblock} - \kStartNodec[$r$]{(0,5)}{R1} - \kPlusMinusDown{R1}{S1}{0cm} - \kTFRight[0.33cm]{S1}{B1}{$G\left( s \right)$} - \kTFBelow[0cm]{B1}{B2}{$H\left( s \right)$} - \kMarkNodeRight[0.2cm]{}{B1}{N1} - \kOutRight{N1}{Y1}{$y$}{0} - - \kLinkVHTFHVBelow{$y$}{$\hat{y}$}{N1}{B2}{S1}{0}{0}{0} - \kLink[]{R1}{S1} - \kLink[$e$]{S1}{B1} - \kLinkn[]{B1}{N1} - - \kCoverRect[blue]{B1}{0.5cm}{1.5cm}{1.8cm}{1.5cm} - \kCoverTextRight{1cm}{0.5cm}{TX1}{Closed-loop system}; +% global ref point +\kJumpCS{init} +%% blocks +\kMarkNodeRight{0.2cm}{0cm}{$r$}{init}{rin} +\kPlusMinusDown{rin}{sb1}{0.2cm} +\kTFRight[0.25cm]{sb1}{tfb1}{$G\left( s \right)$} +\kTFBelow[0.2cm]{tfb1}{tfb2}{$H\left( s \right)$} +\kMarkNodeRight{0.2cm}{0cm}{}{tfb1}{ny} +\kOutRight[0.2cm]{ny}{yout}{$y$}{0cm} +%% links +\kLinkVH[$y$]{ny}{tfb2}{0cm}{0cm}{0cm}{} +\kLinkHV[$\hat{y}$]{tfb2}{sb1}{0cm}{0cm}{9}{} +\kLink[]{rin}{sb1} +\kLink[$e$]{sb1}{tfb1} +\kLinkn[]{tfb1}{ny} +%% coverings +\kCoverRect[blue]{sb1}{1cm}{2cm}{0.5cm}{3cm} +\kCoverTextLeft{2cm}{1cm}{covtx}{Closed-loop system}; \end{kblock} -\end{lstlisting} -\spacetweak - -\subsection{}\spacetweak +\end{SideBySideExample} +\subsection{Ex:C} +\spacetweak\spacetweak +\begin{SideBySideExample}[label=\fbox{C},xrightmargin=10cm] \begin{kblock} - \kStartNodec[]{(5,-5)}{R1} - \kTFRight{R1}{M1}{$\bm{\hat{m}$}\\\textbf{PID}\\\textbf{model}} - \kOutDown[]{M1}{um}{$u_m$}{0} - \kScaleDistX[1.5] - \kTFRight{M1}{C1}{$\bm{K\left(y_m,y\right)}$\\\textbf{PID}\\\textbf{controller}} - \kTFBelowRight{0cm}{0.2cm}{C1}{P1}{$\bm{P\left(s\right)}$\\\textbf{process}} - - \kLink[$r$]{R1}{M1} - \kLink[$y_m$]{M1}{C1} - \kLinkHV[$u$]{C1}{P1}{north}{0} - \kLinkHV[$y$]{P1}{C1}{south}{0} +% ref +\kJumpCS{spt} +% top blocks +\kMarkNodeRight{0cm}{0cm}{$I^\star$}{spt}{inI} +\kPlusMinusDown{inI}{sb1}{1.cm} +\kTFRight[0.2cm]{sb1}{tfb1}{$s$} +\kTFBelow[0.5cm]{sb1}{tfb2}{$\frac{1}{2}$} +\kPlusDownPlusUpL{tfb2}{sb2}{0cm} +\kMinusPlusUp{tfb1}{sb3}{0cm} +\kTFRight[0cm]{sb3}{tfb3}{$0.2$} +\kTFRight[0cm]{tfb3}{tfb4}{$K_3$} +\kMarkNodeAbove{0cm}{0cm}{$V_{dc}$}{inI}{inVdc} +\kMarkNodeBelow{0cm}{0.3cm}{$V_2$}{inI}{inV2} +\kMarkNodeBelow{0cm}{-0.4cm}{$V_3$}{inV2}{inV3} +% bottom blocks +\kMarkNodeBelow{3cm}{0cm}{$V_1$}{inI}{inV1} +\kPlusPlusUpB{tfb4}{sb4}{3cm} +\kPlusMinusDown{inV1}{sb5}{0cm} +\kTFRight[0cm]{sb5}{tfb5}{$\lambda$} +\kOutRight[0cm]{sb4}{outV}{$V_{out}^{\star}$}{0cm} +\kMarkNodeBelow{0cm}{0cm}{$V_4$}{inV1}{inV4} +% top links +\kLinkHV[]{inVdc}{sb3}{0cm}{0cm}{0}{} +\kLinkHV[]{inV2}{sb2}{0cm}{0cm}{0}{} +\kLinkHV[]{inV3}{sb2}{0cm}{0cm}{0}{} +\kLink[]{inI}{sb1} +\kLink[]{sb1}{tfb1} +\kLink[$I_{\beta}$]{tfb2}{sb1} +\kLink[]{tfb1}{sb3} +\kLink[]{sb2}{tfb2} +\kLink[]{sb3}{tfb3} +\kLink[]{tfb3}{tfb4} +\kLink[$V_{\alpha}$]{tfb4}{sb4} +% bottom links +\kLink[]{inV1}{sb5} +\kLink[]{sb5}{tfb5} +\kLink[]{tfb5}{sb4} +\kLinkHV[]{inV4}{sb5}{0cm}{0cm}{0}{} \end{kblock} +\end{SideBySideExample} -\begin{lstlisting} +\subsection{Ex:D} +\spacetweak\spacetweak +\begin{SideBySideExample}[label=\fbox{D},xrightmargin=10cm] \begin{kblock} - \kStartNodec[]{(5,-5)}{R1} - \kTFRight{R1}{M1}{$\bm{\hat{m}$}\\\textbf{PID}\\\textbf{model}} - \kOutDown[]{M1}{um}{$u_m$}{0} - \kScaleDistX[1.5] - \kTFRight{M1}{C1}{$\bm{K\left(y_m,y\right)}$\\\textbf{PID}\\\textbf{controller}} - \kTFBelowRight{0cm}{0.2cm}{C1}{P1}{$\bm{P\left(s\right)}$\\\textbf{process}} - - \kLink[$r$]{R1}{M1} - \kLink[$y_m$]{M1}{C1} - \kLinkHV[$u$]{C1}{P1}{north}{0} - \kLinkHV[$y$]{P1}{C1}{south}{0} +% ref +\kJumpCS{ioref} + +% blks +\kTFRight[0cm]{ioref}{tfb1}{ +$\bm{\hat{m}$}\\\textbf{PID} +\\\textbf{model}} +\kTFRight[1cm]{tfb1}{tfb2}{$\bm{K\left(y_m,y\right)}$ +\\\textbf{PID}\\\textbf{controller}} +\kTFBelowRight{0.25cm}{0.5cm}{tfb2}{tfb3} +{$\bm{P\left(s\right)}$\\\textbf{process}} + +% links +\kInLeft[0cm]{tfb1}{inR}{$r$}{0cm} +\kOutDown[0cm]{tfb1}{outU}{$u_m$}{0cm} +\kLink[$y_m$]{tfb1}{tfb2} +\kLinkHV[$u$]{tfb2}{tfb3}{0cm}{0cm}{1}{} +\kLinkHV[$y$]{tfb3}{tfb2}{0cm}{0cm}{4}{} \end{kblock} -\end{lstlisting} -\spacetweak - -\subsection{}\spacetweak +\end{SideBySideExample} +\subsection{Ex:E} +\spacetweak\spacetweak +\begin{SideBySideExample}[label=\fbox{E},xrightmargin=10cm] \begin{kblock} - \kStartNodec[]{(-5,-5)}{R1} - \kTFRight{R1}{M1}{$\bm{\hat{m}$}\\\textbf{PID}\\\textbf{model}} - \kOutDown[]{M1}{um}{$u_m$}{0} - \kScaleDistX[1.75] - \kTFRight{M1}{C1}{$\bm{K\left(y_m,y\right)}$\\\textbf{PID}\\\textbf{controller}} - \kScaleDistX[1] - \kTFBelow{C1}{P1}{$\bm{P\left(s\right)}$\\\textbf{process}} - - \kLink[$r$]{R1}{M1} - \kLink[$y_m$]{M1}{C1} - \kLinkHVHRight[0]{$u$}{C1}{P1}{0}{0} - \kLinkHVHLeft[0.33]{$y$}{P1}{C1}{0}{-0.25} +% ref +\kJumpCS{refpt} + +% blks +\kTFRight[0cm]{refpt}{tfb1}{ + $\bm{\hat{m}$}\\\textbf{closed PID-loop} + \\\textbf{model}} +\kTFRight[2cm]{tfb1}{tfb2}{\textbf{PID}$\bm{(y_m,y)}$} +\kTFBelow[0.25cm]{tfb2}{tfb3} +{$\bm{P\left(s\right)}$\\\textbf{process}} + +% links +\kInLeft[0cm]{tfb1}{inR}{$r$}{0cm} +\kOutDown[0cm]{tfb1}{outU}{$u_m$}{0cm} +\kLink[$y_m$]{tfb1}{tfb2} +\kLinkHVHRight[0]{$u$}{tfb2}{tfb3}{0cm}{0cm}{1cm} +\kLinkHVHLeft[0.8cm]{$y$}{tfb3}{tfb2}{0cm}{-0.2cm} \end{kblock} -\begin{lstlisting} +\end{SideBySideExample} + +\subsection{Ex:F} +\spacetweak\spacetweak +\begin{SideBySideExample}[label=\fbox{F},xrightmargin=10cm] \begin{kblock} - \kStartNodec[]{(-5,-5)}{R1} - \kTFRight{R1}{M1}{$\bm{\hat{m}$}\\\textbf{PID}\\\textbf{model}} - \kOutDown[]{M1}{um}{$u_m$}{0} - \kScaleDistX[1.75] - \kTFRight{M1}{C1}{$\bm{K\left(y_m,y\right)}$\\\textbf{PID}\\\textbf{controller}} - \kScaleDistX[1] - \kTFBelow{C1}{P1}{$\bm{P\left(s\right)}$\\\textbf{process}} - - \kLink[$r$]{R1}{M1} - \kLink[$y_m$]{M1}{C1} - \kLinkHVHRight[0]{$u$}{C1}{P1}{0}{0} - \kLinkHVHLeft[0.33]{$y$}{P1}{C1}{0}{-0.25} +% generic coordinate reference points +%\kJumpCS[$(0,0)$]{i} +\kJumpCS{i} +\kJumpCSRight[-0.5cm]{i}{iR}{0cm}{3} +\kJumpCSLeft[-0.5cm]{i}{iL}{0cm}{9} +\kJumpCSAbove[-0.5cm]{i}{iA}{0cm}{12} +\kJumpCSBelow[-0.5cm]{i}{iB}{0cm}{6} + +% blks +\kTFBelow[]{iB}{tfb1}{\kmT{\mathcal{K}(\cdot)}} +\kTFBelow[]{tfb1}{tfb2}{\kmT{\mathcal{P}(s)}} + +% links +\kInLeftM[0cm]{tfb1}{inR}{$r$}{0.05cm}{6} +\kMarkNodeLeft{0cm}{0cm}{}{tfb2}{ny} +\kOutLeft[-0.5cm]{ny}{outY}{$y$}{0cm} +\kLinkn[]{ny}{tfb2} +\kLinkVH[$y$]{ny}{tfb1}{-0.1cm}{0cm}{2}{} +\kLinkHVHRight[0.6cm]{$u$}{tfb1}{tfb2}{0cm}{0cm} + +% covers +\kCoverRect[magenta!5!red]{tfb2} +{0.1cm}{0.1cm}{0.3cm}{0.3cm} +\kCoverTextBelow{0cm}{0cm}{txt1} +{physical system (e.g: a dc motor)}; +% +\kCoverRect[green!75!blue!80!]{tfb1} +{0.1cm}{0.1cm}{0.2cm}{0.2cm} +\kCoverTextAbove{0cm}{0cm}{txt2} +{computing system (embedded control algorithm)}; \end{kblock} -\end{lstlisting} -\spacetweak +\end{SideBySideExample} -\subsection{}\spacetweak +\subsection{Ex:G} +\spacetweak\spacetweak +\begin{SideBySideExample}[label=\fbox{G},xrightmargin=10cm] +\centering \begin{kblock} - \kJumpCS{R}{$(0,0)$} - - \kJumpCSRight[-0.5cm]{R}{CR}{0}{3} - \kJumpCSLeft[-0.5cm]{R}{CR}{0}{9} - \kJumpCSAbove[-0.5cm]{R}{CR}{0}{12} - \kJumpCSBelow[-0.5cm]{R}{CR}{0}{6} - - \kTFBelow{R}{C1}{\bfseries{PID}$\bm{(\cdot)}$} - \kScaleDistX[0.67] - \kTFBelow{C1}{P1}{$\bm{P(s)}$} - \kScaleDistX[1] - - \kInLeft[0cm]{C1}{RI}{$r$}{0.1} - - \kMarkNodeLeft[0cm]{}{P1}{ON} - \kLinkn[]{P1}{ON} - \kOutLeft[-0.5cm]{ON}{Y}{$y$}{0} - \kLinkVH[$y$]{ON}{C1}{west}{-0.1} - - \kLinkHVHRight[0]{$u$}{C1}{P1}{0}{0} +\kJumpCS{R} + +% blks +\kTFRight{R}{tfb1}{$\bm{P}$} +\kTFBelow{tfb1}{tfb2}{$\bm{C}$} + +% links +\kInLeftM[0cm]{tfb1}{inW}{$w$}{0.05cm}{2} +\kInLeftM[0cm]{tfb2}{inR}{$r$}{-0.05cm}{5} +\kOutRight[0cm]{tfb1}{outZ}{$z$}{0.05cm} +\kOutRight[0cm]{tfb2}{outV}{$v$}{-0.05cm} +\kLinkHVHRight[0.6cm]{$y$}{tfb1}{tfb2}{-0.1cm}{0.1cm} +\kLinkHVHLeft[0.6cm]{$u$}{tfb2}{tfb1}{0.1cm}{-0.1cm} + +% covers +\kCoverRect[blue!50!]{tfb1} +{0.1cm}{0.1cm}{0.3cm}{0.3cm} +\kCoverTextAbove{0cm}{0cm}{txt1}{Physical System}; +% +\kCoverRect[red]{tfb2} +{0.1cm}{0.1cm}{0.3cm}{0.3cm} +\kCoverTextBelow{0cm}{0cm}{txt2}{Computing System}; \end{kblock} +\end{SideBySideExample} -\begin{lstlisting} +\subsection{Ex:H} +\spacetweak\spacetweak +\begin{SideBySideExample}[label=\fbox{H},xrightmargin=10cm] +% Description: Closed PID-loop +\centering \begin{kblock} - \kJumpCS{R}{$(0,0)$} - - \kJumpCSRight[-0.5cm]{R}{CR}{0}{3} - \kJumpCSLeft[-0.5cm]{R}{CR}{0}{9} - \kJumpCSAbove[-0.5cm]{R}{CR}{0}{12} - \kJumpCSBelow[-0.5cm]{R}{CR}{0}{6} - - \kTFBelow{R}{C1}{\bfseries{PID}$\bm{(\cdot)}$} - \kScaleDistX[0.67] - \kTFBelow{C1}{P1}{$\bm{P(s)}$} - \kScaleDistX[1] - - \kInLeft[0cm]{C1}{RI}{$r$}{0.1} - - \kMarkNodeLeft[0cm]{}{P1}{ON} - \kLinkn[]{P1}{ON} - \kOutLeft[-0.5cm]{ON}{Y}{$y$}{0} - \kLinkVH[$y$]{ON}{C1}{west}{-0.1} - - \kLinkHVHRight[0]{$u$}{C1}{P1}{0}{0} +% global ref point +\kJumpCS{SRef} + +%% blocks +\kTFAbove[5cm]{SRef}{tfD}{\kmT{D}} +\kMarkNodeLeft{0.1cm}{0cm}{}{tfD}{yin} +\kPlusMinusDownPlaceAbove{yin}{S1}{0cm} +\kTFAbove[]{tfD}{tfA}{\kmT{A}} +\kTFAbove[]{tfA}{tfB}{\kmT{B}} +\kPlusPlusMinus{tfA}{S2}{0cm} +\kTFRight[0.5cm]{S2}{tfP}{\kmT{\mathcal{P}(s)}} + +%% other nodes-paths +\kMarkNodeRight{0cm}{0cm}{}{tfP}{ycut} +\kInLeft[0.1cm]{S1}{rin}{$r$}{0cm} +\kOutRight[0.1cm]{ycut}{yout}{$y^*$}{0cm} +\kMarkNodeRight{-0.4cm}{0cm}{}{rin}{rcut} + +%% links +\kLink[$e$]{S1}{tfA} +\kLinkVH[]{rcut}{tfB}{0cm}{0cm}{0}{} +\kLink[]{tfA}{S2} +\kLinkHV[]{tfB}{S2}{0cm}{0cm}{0}{} +\kLink[$u^*$]{S2}{tfP} +\kLinkHV[]{tfD}{S2}{0cm}{0cm}{0}{} +\kLinkn[]{tfP}{ycut} +\kLinknVHHVBelow[1.2cm]{}{ycut}{yin}{0cm}{0cm} +\kLink[]{yin}{tfD} +\kLink[]{yin}{S1} \end{kblock} -\end{lstlisting} -\spacetweak - -\subsection{}\spacetweak +\end{SideBySideExample} +\subsection{Ex:I} +\spacetweak\spacetweak +\begin{SideBySideExample}[label=\fbox{I},xrightmargin=10cm] +% Description: Closed PID-loop +\centering \begin{kblock} - \kJumpCS{R1}{$(5,5)$} - - \kTFRight{R1}{P1}{$\bm{P}$} - \kScaleDistX[0.67] - \kTFBelow{P1}{C1}{$\bm{C}$} - \kScaleDistX[1] - - \kInLeft[]{P1}{RI}{$w$}{0.1} - \kInLeft[]{C1}{RC}{$r$}{-0.1} - - \kLinkHVHRight[0.2]{$y$}{P1}{C1}{-0.1}{0.1} - \kLinkHVHLeft[0.2]{$u$}{C1}{P1}{0.1}{-0.1} - - \kOutRight[0cm]{P1}{Z}{$z$}{0.1} - \kOutRight[]{C1}{V}{$v$}{-0.1} - - \kCoverRect[blue!50!]{P1}{0.1cm}{0.1cm}{0.2cm}{0.2cm} - \kCoverTextAbove{0}{0}{TX1}{Physical System}; - - \kCoverRect[red]{C1}{0.1cm}{0.1cm}{0.2cm}{0.2cm} - \kCoverTextBelow{0cm}{0cm}{TX2}{Computing System}; +% global ref point +\kJumpCS{SRef} + +%% blocks + +\kTFAbove[]{SRef}{tfA}{\kmT{A}} +\kPlusMinusDownL{tfA}{S1}{0cm} +\kTFAbove[]{tfA}{tfB}{\kmT{B}} +\kPlusPlusMinus{tfA}{S2}{0cm} +\kTFRight[0.5cm]{S2}{tfP}{\kmT{\mathcal{P}(s)}} +\kTFBelow[0cm]{tfP}{tfD}{\kmT{D}} +\kMarkNodeRight{0cm}{0cm}{}{tfP}{ycut} +\kMarkNodeBelow{0cm}{0cm}{}{ycut}{yin} +\kInLeftM[0.1cm]{S1}{rin}{$r$}{0cm}{0} +\kOutRight[0.1cm]{ycut}{yout}{$y^*$}{0cm} +\kMarkNodeRight{-0.4cm}{0cm}{}{rin}{rcut} + +%% links +\kLink[$e$]{S1}{tfA} +\kLinkVH[]{rcut}{tfB}{0cm}{0cm}{0}{} +\kLink[]{tfA}{S2} +\kLinkHV[]{tfB}{S2}{0cm}{0cm}{0}{} +\kLink[$u^*$]{S2}{tfP} +\kLinkHV[]{tfD}{S2}{0cm}{0cm}{0}{} +\kLinkn[]{tfP}{ycut} +\kLinkn[]{ycut}{yin} +\kLinknVHHVBelow[0.5cm]{}{yin}{S1}{0cm}{0cm} +\kLink[]{yin}{tfD} \end{kblock} +\end{SideBySideExample} -\begin{lstlisting} +\subsection{Ex:J} +\spacetweak\spacetweak +\begin{SideBySideExample}[label=\fbox{J},xrightmargin=10cm] +% Description: Anon +\centering \begin{kblock} - \kJumpCS{R1}{$(5,5)$} - - \kTFRight{R1}{P1}{$\bm{P}$} - \kScaleDistX[0.67] - \kTFBelow{P1}{C1}{$\bm{C}$} - \kScaleDistX[1] - - \kInLeft[]{P1}{RI}{$w$}{0.1} - \kInLeft[]{C1}{RC}{$r$}{-0.1} - - \kLinkHVHRight[0.2]{$y$}{P1}{C1}{-0.1}{0.1} - \kLinkHVHLeft[0.2]{$u$}{C1}{P1}{0.1}{-0.1} - - \kOutRight[0cm]{P1}{Z}{$z$}{0.1} - \kOutRight[]{C1}{V}{$v$}{-0.1} - - \kCoverRect[blue!50!]{P1}{0.1cm}{0.1cm}{0.2cm}{0.2cm} - \kCoverTextAbove{0}{0}{TX1}{Physical System}; - - \kCoverRect[red]{C1}{0.1cm}{0.1cm}{0.2cm}{0.2cm} - \kCoverTextBelow{0cm}{0cm}{TX2}{Computing System}; +% global ref point +\kJumpCS{o} + +%% blocks +\kTFAbove[0cm]{o}{tfi}{\kmT{f_i(\cdot)}} +\kTFAbove[0.5cm]{tfi}{tfd}{\kmT{f_d(\cdot)}} +\kTFAbove[0.5cm]{tfd}{tfp}{\kmT{f_p(\cdot)}} + +%% links +\kInUpM[0cm]{tfp}{inu}{$u$}{0cm}{0} +\kOutRight[0.3cm]{tfp}{kp}{$K_p$}{0cm} +\kOutRight[0.3cm]{tfi}{ki}{$K_i$}{0cm} +\kOutRight[0.3cm]{tfd}{kd}{$K_d$}{0cm} +\kInLeftM[0cm]{tfd}{inwn}{$\omega_n$}{0cm}{6} +\kInLeftM[0cm]{tfp}{iny}{$y$}{0.15cm}{6} +\kInLeftM[0cm]{tfp}{inym}{$y_m$}{-0.15cm}{4} +\kMarkNodeLeft{-0.35cm}{0cm}{}{kp}{kpcut} +\kLinkVH[$\lambda$]{kpcut}{tfd}{0.2cm}{0cm}{2}{kpcutb} +\kLinkVH[]{kpcutb}{tfi}{0.2cm}{0cm}{0}{} +\kMarkNodeRight{-0.8cm}{0cm}{}{inwn}{wncut} +\kLinkVH[]{wncut}{tfi}{0cm}{0cm}{0}{} \end{kblock} -\end{lstlisting} +\end{SideBySideExample} +\subsection{Ex:K} \spacetweak - -\subsection{}\spacetweak +\begin{SideBySideExample}[label=\fbox{K},xrightmargin=10cm] +% DESCRIPTION: CPLMFC-Algorithm \begin{kblock} -\kJumpCS{io}{$(0,0)$} -\kJumpCSLeft[-0.5cm]{io}{jl}{0}{9} -\kCoverRect[blue]{jl}{2cm}{2cm}{2cm}{2cm} -\end{kblock} +% global ref point +\kJumpCS{SRef} +%% blocks +% place TF_fts right of global ref. +\kTFRight[4cm]{SRef}{TF_fts}{ \kmTw{f_\mathrm{t_s}} } +% place TF_mfc at h cm above TF_fts +\kTFAbove[0.3cm]{TF_fts}{TF_mfc}{ \kmT{f_\mathrm{MFC}} } +\kTFAbove[0.3cm]{TF_mfc}{TF_pid}{ \kmT{f_\mathrm{PID}} } +\kTFRight[3cm]{TF_mfc}{TF_sys}{ \kmTw{ \mathcal{P} } } + +%% nodes and links +% mark visible node N1 right of TF_mfc +\kMarkNodeRight{0.6cm}{0cm}{}{TF_mfc}{N1} +\kMarkNodeBelow{-0.8cm}{0cm}{}{N1}{N2} +\kMarkNodeRight{-0.6cm}{0cm}{}{N1}{N3} +\kMarkNodeRight{0cm}{}{}{TF_sys}{N4} +% extend node-path outwards +\kOutRight[0.1cm]{N4}{Y1}{$y^*$}{0cm} +\kMarkNodeLeft{0.3cm}{0cm}{}{TF_fts}{N5} +\kMarkNodeLeft{0.3cm}{-0.12cm}{}{TF_mfc}{N6} +\kInLeft[0.12cm]{TF_pid}{R1}{$r$}{-0.12cm} +\kMarkNodeLeft{0cm}{-0.12cm}{}{TF_pid}{N7} +% link TF_sys to N4 +\kLinkn[]{TF_sys}{N4} +\kLink[$u^*$]{N3}{TF_sys} +\kLink[]{N1}{TF_mfc} +\kLinkHV[]{TF_fts}{N2}{0cm}{0cm}{0}{} +% HV link from TF_pid to N1 +%\kLinkHV[]{$(TF_pid.east) + (0,0cm)$}{N1}{0cm}{0cm}{0}{} +\kLinkHV[]{TF_pid}{N1}{0cm}{0cm}{0}{} +% link N1 to N3 +%\kLink[]{N1}{N3} +% link N2 to N3 +\kLink[]{N2}{N3} +% VHHV feedback link from N4 to N5 +\kLinknVHHVBelow[1.5cm]{}{N4}{N5}{0cm}{0cm} +\kLink[]{N5}{TF_fts} +\kLink[]{N6}{$(TF_mfc.west) + (0,-0.12cm)$} +% arrowless link N5 and N6 +\kLinkn[]{N5}{N6} +\kLinkVH[]{N6}{TF_pid}{0.12cm}{0cm}{0}{} +\kLinkVH[]{N7}{TF_mfc}{0.12cm}{0cm}{0}{} +%% vector links +% link from inside TF_fts to TF_mfc +\kVecLink[$$]{TF_fts}{TF_mfc} +% link from inside TF_mfc to TF_pid +%\kVecLink[$$]{TF_mfc}{TF_pid} +\kVecLink[$$]{$(TF_mfc.north) + (-0.15cm,0cm)$} +{$(TF_pid.south) + (-0.15cm,0cm)$} +% link from inside TF_pid to TF_mfc +\kVecLink[$$]{$(TF_pid.south) + (0.15cm,0cm)$} +{$(TF_mfc.north) + (0.15cm,0cm)$} + +%% cover-sectioning +\kCoverRect[gray]{TF_mfc} +{1.8cm}{1.8cm}{1.5cm}{1.6cm} +\kCoverTextAbove{0cm}{0cm}{CT1}{CPLMFC Algorithm};% -\begin{lstlisting} +\end{kblock} +\end{SideBySideExample} +% \kLinkVH[$\bm{\omega_n}$]{T3}{T1}{0cm}{0cm}{0}{} +% +% \kVecLinkVH[$\bm{\kappa_{pid}}$]{T2}{T3}{0.1cm}{-0.1cm}{8} +% \kVecLinkHV[$\bm{\kappa_{pid,\lambda_{id}}}$]{T3}{T2}{-0.1cm}{0.1cm}{1} +% \kVecInUp[-0.3cm]{T3}{TS2}{$\bm{t_s,\tau_l}$}{0.5cm} + +\subsection{Ex:L}\spacetweak\spacetweak +\spacetweak\spacetweak +\begin{SideBySideExample}[label=\fbox{L},xrightmargin=10cm] \begin{kblock} -\kJumpCS{io}{$(0,0)$} -\kJumpCSLeft[-0.5cm]{io}{jl}{0}{9} -\kCoverRect[blue]{jl}{2cm}{2cm}{2cm}{2cm} +\kJumpCS{fspt} + +% blks +\kTFBelow[0.5cm]{fspt}{plt}{\kmT{P(s)}} +\kTFBelow[0cm]{plt}{pidcm}{ +\textbf{PID closed-loop model}\\ +$ +\begin{array}{c} + \bm{\dot{x}_m=\mathcal{S}({x_m},{r})} +\end{array} +$ +} +\kTFBelow[0.33cm]{pidcm}{tscalc} +{\kmT{f_{\omega_n}(\cdot)}} +\kTFBelow[0.33cm]{tscalc}{fis}{\kmT{f_{x_s}(\cdot)}} +\kTFBelow[0.2cm]{fis}{pid}{ +\textbf{PID Control Law}\\ +\kmT{u = f_{pid}(\cdot)} +} +\kTFRight[2.5cm]{tscalc}{obs}{ +\textbf{State Observer}\\ +$ +\begin{array}{c} + \bm{\hat{\dot{x}}=\mathcal{S}(\hat{x},{r})}\\ +\end{array} +$ +} + +% links +\kInDown[-0.4cm]{pid}{cp}{\kmT{\lambda_p}}{-0.6cm} +\kInDown[-0.4cm]{pid}{ci}{\kmT{\lambda_i}}{0.6cm} +\kInDown[-0.2cm]{pid}{cd}{\kmT{\lambda_d}}{0cm} +\kLinkHVHLeft[2cm]{\kmT{u}}{pid}{plt}{0cm}{0cm}{} +\kLinkHV[\kmT{y}]{plt}{obs}{0cm}{0cm}{1}{} +\kLinkVH[\kmT{\hat{x}}]{obs}{pid}{-0.1cm}{0cm}{3}{} +\kLinkHVHRight[]{\kmT{{x}_m}}{pidcm}{pid}{0cm}{0.1cm} +\kLink[$\bm{\omega_n}$]{tscalc}{pidcm} +\kLink[$\bm{x_s}$]{fis}{tscalc} +\kLink[$\bm{b,c}$]{pid}{fis} +\kMarkNodeAbove{-0.5cm}{0cm}{}{tscalc}{mkwn} +\kLinkHV[]{mkwn}{pid}{0cm}{1cm}{0cm}{} +\kMarkNodeAbove{-0.5cm}{0cm}{}{fis}{mkxts} +\kLinkHV[]{mkxts}{pid}{0cm}{0.8cm}{0}{} +\kInLeftM[0cm]{pidcm}{rin}{$\bm{r}$}{-0.15cm}{3} +\kOutLeft[0cm]{pidcm}{umout}{$\bm{u_m}$}{0.15cm} +\kInLeftM[0.2cm]{tscalc}{tsl}{$\bm{t_s,t_l}$}{0cm}{6} +\kMarkNodeRight{-0.84cm}{0cm}{}{tsl}{mktsl} +\kLinkVH[]{mktsl}{pid}{0.15cm}{0cm}{0}{} +\kMarkNodeBelow{0cm}{0cm}{}{obs}{mkxhat} +\kLinkHV[]{mkxhat}{obs}{0cm}{-0.5cm}{0}{} \end{kblock} -\end{lstlisting} +\end{SideBySideExample} + +\pagebreak +%% API +\spacetweak\spacetweak +\section{\kblocks{} API} +\bfseries TODO ... +%\begin{apilist} +%\cvhd{Place an invisible Node at origin, as reference point} +%\begin{cvl} +%\kJumpCS{current coordinate label} +%\end{cvl} +% +%\cvhd{Place Node with variable x-y coordinate shift} +%\begin{cvl} +%\kMarkNodeLeft{node x distance shift}{node y distance shift} +%{node text-label}{from node label}{to node or current node label} +% +%\kMarkNodeRight{node x distance shift}{node y distance shift} +%{node text-label}{from node label}{to node or current node label} +% +%\kMarkNodeAbove{node x distance shift}{node y distance shift} +%{node text-label}{from node label}{to node or current node label} +% +%\kMarkNodeBelow{node x distance shift}{node y distance shift} +%{node text-label}{from node label}{to node or current node label} +%\end{cvl} +% +%\cvhd{Place a Node at a specific coordinate} +%\begin{cvl} +%\kMarkNode{optional x distance shift}{optional y distance shift} +%{node label}{current node coordinate} +%\end{cvl} +% +%\cvhd{Arithmetic Summer Blocks} +%\begin{cvl} +%\kPlusPlusMinus{from node label}{to current sum node label} +%{optional horizontal position shift} +%\end{cvl} +% +%\cvhd{Transfer-Function block} +%\begin{cvl} +%\kTFRight[optional shift dimension]{from node label} +%{to current tf node label}{tf text content} +%\end{cvl} +% +%\cvhd{Scalar Link (arrowed) and Linkn (no arrow)} +%\begin{cvl} +%\kLink[optional signal label]{from node label}{to node label} +% +%\kLinkn[optional signal label]{from node label}{to node label} +%\end{cvl} +% +% +%\cvhd{Output Link from a node point} +%\begin{cvl} +%\kOutRight[optional distance shift]{from node label} +%{to current node label}{out signal label}{direction shift} +%\end{cvl} +% +% +%\cvhd{Scalar Link Full Feedback/FeedForward Vertical (Up or Down) to Horizontal (Right or Left) to Vertical (Up or Down)} +%\begin{cvl} +%\kLinkVHHVBelow[optional link shift]{unity link label} +%{from node{to node}{from node direction shift}{to node direction shift} +% +%\kLinkVHHVAbove[optional link shift]{unity link label} +%{from node}{to node}{from node direction shift}{to node direction shift} +%\end{cvl} +% +% +% +% +%\end{apilist} +\spacetweak\spacetweak + + -\spacetweak \end{document} diff --git a/graphics/pgf/contrib/kblocks/kblocks.sty b/graphics/pgf/contrib/kblocks/kblocks.sty index 54ea69c216..49ff9bfca8 100644 --- a/graphics/pgf/contrib/kblocks/kblocks.sty +++ b/graphics/pgf/contrib/kblocks/kblocks.sty @@ -1,6 +1,9 @@ +% some LaTeX code % kblocks.sty % TikZ-based block-diagram package for control theory applications +% version 2.0 (February 2021) % version 1.0 (October 2019) +% % Author: Somefun Oluwasegun {oasomefun@futa.edu.ng} % Change Log: % significant improvements and introduction of new macros and annotation @@ -10,7 +13,7 @@ % (2005): motivated by the TikZ-bloques package by Alejandro Garces {Alejandro Garcesalejandrogarces@gmail.com} % -% Copyright (c) 2019 by Oluwasegun Somefun . +% Copyright (c) 2021 by Oluwasegun Somefun . % MIT LICENSE % Permission is hereby granted, free of charge, to any person obtaining a copy of this software @@ -33,7 +36,7 @@ \typeout{kblocks: A package to easily typeset Control Block Diagrams and Signal Flow Graphs with TikZ/PGF.} -\typeout{(c) 2019. Oluwasegun Somefun} +\typeout{(c) 2021. Oluwasegun Somefun} \typeout{*} @@ -47,7 +50,8 @@ Flow Graphs with TikZ/PGF.} \RequirePackage{tikz,circuitikz} \usepgflibrary{shapes.misc} \usetikzlibrary{math,calc,arrows,decorations.pathmorphing,decorations.markings, -arrows.meta,backgrounds,fit,shadows} +arrows.meta,backgrounds,fit,shadows,matrix,chains,scopes,positioning, + decorations.pathreplacing,decorations.text,shapes.multipart,graphs,external} % Helpful @@ -64,6 +68,10 @@ arrows.meta,backgrounds,fit,shadows} \newcommand{\linetype}{very thick} \newcommand{\linepathtype}{semithick} +\newcommand{\kmT}[1]{$\:\bm{#1}\:$} % block math text with 1 left-right border spacing + +\newcommand{\kmTw}[1]{$\:\:\: \bm{#1} \:\:\:$} %block math text with wider left-right border spacing + \newcommand{\kShadow}{\renewcommand{\dark}{1}} \newcommand{\kColorB}[1]{\renewcommand{\backgroundcolor}{#1}} \newcommand{\kColorT}[1]{\renewcommand{\colortext}{#1}} @@ -77,6 +85,9 @@ arrows.meta,backgrounds,fit,shadows} \renewcommand{\horizdist}{1.5cm * #1} } +% to add very very thick width for vector lines +\tikzset{veclinetype/.style={line width=2.0pt}} + % Global variables for Coordinate Calculations \newdimen\xc \newdimen\yc @@ -117,7 +128,7 @@ mark=at position 0.5 with {\arrow{Latex[]}}},postaction={decorate}}} % Area Cover Rectangle -%% Usage [colour]{ref node}{north shift}{south shift}{west shift}{east shift} +%% Usage [colour]{ref node}{north shift dimension}{south shift dimension}{west shift dimension}{east shift dimension} \newcommand{\kCoverRect}[6][black]{ @@ -273,7 +284,7 @@ mark=at position 0.5 with {\arrow{Latex[]}}},postaction={decorate}}} % Arithmetic Summer Blocks %% Usage: {from node label}{to current sum node label}{optional horizontal position shift} - +% left down \newcommand{\kMinusPlusDown}[3]{ \def\dxpm{#3}; @@ -289,6 +300,51 @@ mark=at position 0.5 with {\arrow{Latex[]}}},postaction={decorate}}} \node [left of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}}; \node [below of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; } +\newcommand{\kMinusPlusDownL}[3]{ + + \def\dxpm{#3}; + + \ifx\dxpm\empty + \def\dxpm{0}; + \else + \fi + + \node [draw=\linecolor, circle,minimum size=1.5em, left of= #1, node distance= \horizdist + \dxpm, \linetype, + fill=\backgroundcolor, drop shadow={opacity=\dark}, font=\textsize] (#2) {}; + \node [draw, cross out, minimum size=1.0em, left of= #1, node distance= \horizdist + \dxpm, thin, draw=black] {}; + \node [left of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}}; + \node [below of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; +} +\newcommand{\kMinusPlusDownA}[3]{ + + \def\dxpm{#3}; + + \ifx\dxpm\empty + \def\dxpm{0}; + \else + \fi + + \node [draw=\linecolor, circle,minimum size=1.5em, above of= #1, node distance= \horizdist + \dxpm, \linetype, + fill=\backgroundcolor, drop shadow={opacity=\dark}, font=\textsize] (#2) {}; + \node [draw, cross out, minimum size=1.0em, above of= #1, node distance= \horizdist + \dxpm, thin, draw=black] {}; + \node [left of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}}; + \node [below of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; +} +\newcommand{\kMinusPlusDownB}[3]{ + + \def\dxpm{#3}; + + \ifx\dxpm\empty + \def\dxpm{0}; + \else + \fi + + \node [draw=\linecolor, circle,minimum size=1.5em, below of= #1, node distance= \horizdist + \dxpm, \linetype, + fill=\backgroundcolor, drop shadow={opacity=\dark}, font=\textsize] (#2) {}; + \node [draw, cross out, minimum size=1.0em, below of= #1, node distance= \horizdist + \dxpm, thin, draw=black] {}; + \node [left of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}}; + \node [below of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; +} \newcommand{\kMinusMinusDown}[3]{ @@ -305,6 +361,51 @@ mark=at position 0.5 with {\arrow{Latex[]}}},postaction={decorate}}} \node [left of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}}; \node [below of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}}; } +\newcommand{\kMinusMinusDownL}[3]{ + + \def\dxpm{#3}; + + \ifx\dxpm\empty + \def\dxpm{0}; + \else + \fi + + \node [draw=\linecolor, circle,minimum size=1.5em, left of= #1, node distance= \horizdist + \dxpm, \linetype, + fill=\backgroundcolor, drop shadow={opacity=\dark}, font=\textsize] (#2) {}; + \node [draw, cross out, minimum size=1.0em, left of= #1, node distance= \horizdist + \dxpm, thin, draw=black] {}; + \node [left of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}}; + \node [below of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}}; +} +\newcommand{\kMinusMinusDownA}[3]{ + + \def\dxpm{#3}; + + \ifx\dxpm\empty + \def\dxpm{0}; + \else + \fi + + \node [draw=\linecolor, circle,minimum size=1.5em, above of = #1, node distance= \horizdist + \dxpm, \linetype, + fill=\backgroundcolor, drop shadow={opacity=\dark}, font=\textsize] (#2) {}; + \node [draw, cross out, minimum size=1.0em, above of = #1, node distance= \horizdist + \dxpm, thin, draw=black] {}; + \node [left of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}}; + \node [below of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}}; +} +\newcommand{\kMinusMinusDownB}[3]{ + + \def\dxpm{#3}; + + \ifx\dxpm\empty + \def\dxpm{0}; + \else + \fi + + \node [draw=\linecolor, circle,minimum size=1.5em, below of = #1, node distance= \horizdist + \dxpm, \linetype, + fill=\backgroundcolor, drop shadow={opacity=\dark}, font=\textsize] (#2) {}; + \node [draw, cross out, minimum size=1.0em, below of = #1, node distance= \horizdist + \dxpm, thin, draw=black] {}; + \node [left of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}}; + \node [below of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}}; +} \newcommand{\kPlusMinusDown}[3]{ @@ -321,8 +422,114 @@ mark=at position 0.5 with {\arrow{Latex[]}}},postaction={decorate}}} \node [left of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; \node [below of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}}; } +\newcommand{\kPlusMinusDownL}[3]{ + + \def\dxpm{#3}; + + \ifx\dxpm\empty + \def\dxpm{0}; + \else + \fi + + \node [draw=\linecolor, circle,minimum size=1.5em, left of= #1, node distance= \horizdist + \dxpm, \linetype, + fill=\backgroundcolor, drop shadow={opacity=\dark}, font=\textsize] (#2) {}; + \node [draw, cross out, minimum size=1.0em, left of= #1, node distance= \horizdist + \dxpm, thin, draw=black] {}; + \node [left of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; + \node [below of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}}; +} +\newcommand{\kPlusMinusDownA}[3]{ + + \def\dxpm{#3}; + + \ifx\dxpm\empty + \def\dxpm{0}; + \else + \fi + + \node [draw=\linecolor, circle,minimum size=1.5em, above of= #1, node distance= \horizdist + \dxpm, \linetype, + fill=\backgroundcolor, drop shadow={opacity=\dark}, font=\textsize] (#2) {}; + \node [draw, cross out, minimum size=1.0em, above of= #1, node distance= \horizdist + \dxpm, thin, draw=black] {}; + \node [left of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; + \node [below of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}}; +} +\newcommand{\kPlusMinusDownB}[3]{ + + \def\dxpm{#3}; + + \ifx\dxpm\empty + \def\dxpm{0}; + \else + \fi + + \node [draw=\linecolor, circle,minimum size=1.5em, below of= #1, node distance= \horizdist + \dxpm, \linetype, + fill=\backgroundcolor, drop shadow={opacity=\dark}, font=\textsize] (#2) {}; + \node [draw, cross out, minimum size=1.0em, below of= #1, node distance= \horizdist + \dxpm, thin, draw=black] {}; + \node [left of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; + \node [below of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}}; +} \newcommand{\kPlusPlusDown}[3]{ + \def\dxpm{#3}; + + \ifx\dxpm\empty + \def\dxpm{0}; + \else + \fi + + \node [draw=\linecolor, circle,minimum size=1.5em, right of= #1, node distance= \horizdist + \dxpm, \linetype, + fill=\backgroundcolor, drop shadow={opacity=\dark}, font=\textsize] (#2) {}; + \node [draw, cross out, minimum size=1.0em, right of= #1, node distance= \horizdist + \dxpm, thin, draw=black] {}; + \node [left of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; + \node [below of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; +} +\newcommand{\kPlusPlusDownL}[3]{ + + \def\dxpm{#3}; + + \ifx\dxpm\empty + \def\dxpm{0}; + \else + \fi + + \node [draw=\linecolor, circle,minimum size=1.5em, left of= #1, node distance= \horizdist + \dxpm, \linetype, + fill=\backgroundcolor, drop shadow={opacity=\dark}, font=\textsize] (#2) {}; + \node [draw, cross out, minimum size=1.0em, left of= #1, node distance= \horizdist + \dxpm, thin, draw=black] {}; + \node [left of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; + \node [below of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; +} +\newcommand{\kPlusPlusDownA}[3]{ + + \def\dxpm{#3}; + + \ifx\dxpm\empty + \def\dxpm{0}; + \else + \fi + + \node [draw=\linecolor, circle,minimum size=1.5em, above of= #1, node distance= \horizdist + \dxpm, \linetype, + fill=\backgroundcolor, drop shadow={opacity=\dark}, font=\textsize] (#2) {}; + \node [draw, cross out, minimum size=1.0em, above of= #1, node distance= \horizdist + \dxpm, thin, draw=black] {}; + \node [left of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; + \node [below of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; +} +\newcommand{\kPlusPlusDownB}[3]{ + + \def\dxpm{#3}; + + \ifx\dxpm\empty + \def\dxpm{0}; + \else + \fi + + \node [draw=\linecolor, circle,minimum size=1.5em, below of= #1, node distance= \horizdist + \dxpm, \linetype, + fill=\backgroundcolor, drop shadow={opacity=\dark}, font=\textsize] (#2) {}; + \node [draw, cross out, minimum size=1.0em, below of= #1, node distance= \horizdist + \dxpm, thin, draw=black] {}; + \node [left of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; + \node [below of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; +} + +\newcommand{\kPlusMinusDownPlaceAbove}[3]{ + \def\dxpm{#3}; \ifx\dxpm\empty @@ -330,13 +537,31 @@ mark=at position 0.5 with {\arrow{Latex[]}}},postaction={decorate}}} \else \fi - \node [draw=\linecolor, circle,minimum size=1.5em, right of= #1, node distance= \horizdist + \dxpm, \linetype, + \node [draw=\linecolor, circle,minimum size=1.5em, above of= #1, node distance= \horizdist + \dxpm, \linetype, fill=\backgroundcolor, drop shadow={opacity=\dark}, font=\textsize] (#2) {}; - \node [draw, cross out, minimum size=1.0em, right of= #1, node distance= \horizdist + \dxpm, thin, draw=black] {}; + \node [draw, cross out, minimum size=1.0em, above of= #1, node distance= \horizdist + \dxpm, thin, draw=black] {}; \node [left of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; - \node [below of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; + \node [below of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}}; } +\newcommand{\kPlusMinusDownPlaceBelow}[3]{ + + \def\dxpm{#3}; + + \ifx\dxpm\empty + \def\dxpm{0}; + \else + \fi + + \node [draw=\linecolor, circle,minimum size=1.5em, below of= #1, node distance= \horizdist + \dxpm, \linetype, + fill=\backgroundcolor, drop shadow={opacity=\dark}, font=\textsize] (#2) {}; + \node [draw, cross out, minimum size=1.0em, below of= #1, node distance= \horizdist + \dxpm, thin, draw=black] {}; + \node [left of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; + \node [below of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}}; +} + + +% left up \newcommand{\kMinusPlusUp}[3]{ \def\dxpm{#3}; @@ -352,6 +577,52 @@ mark=at position 0.5 with {\arrow{Latex[]}}},postaction={decorate}}} \node [left of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}}; \node [above of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; } +\newcommand{\kMinusPlusUpL}[3]{ + + \def\dxpm{#3}; + + \ifx\dxpm\empty + \def\dxpm{0}; + \else + \fi + + \node [draw=\linecolor, circle,minimum size=1.5em, left of = #1, node distance= \horizdist+\dxpm, \linetype, + fill=\backgroundcolor, drop shadow={opacity=\dark}, font=\textsize] (#2) {}; + \node [draw, cross out, minimum size=1.0em, left of = #1, node distance= \horizdist + \dxpm, thin, draw=black] {}; + \node [left of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}}; + \node [above of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; +} +\newcommand{\kMinusPlusUpA}[3]{ + + \def\dxpm{#3}; + + \ifx\dxpm\empty + \def\dxpm{0}; + \else + \fi + + \node [draw=\linecolor, circle,minimum size=1.5em, above of = #1, node distance= \horizdist+\dxpm, \linetype, + fill=\backgroundcolor, drop shadow={opacity=\dark}, font=\textsize] (#2) {}; + \node [draw, cross out, minimum size=1.0em, above of = #1, node distance= \horizdist + \dxpm, thin, draw=black] {}; + \node [left of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}}; + \node [above of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; +} +\newcommand{\kMinusPlusUpB}[3]{ + + \def\dxpm{#3}; + + \ifx\dxpm\empty + \def\dxpm{0}; + \else + \fi + + \node [draw=\linecolor, circle,minimum size=1.5em, below of = #1, node distance= \horizdist+\dxpm, \linetype, + fill=\backgroundcolor, drop shadow={opacity=\dark}, font=\textsize] (#2) {}; + \node [draw, cross out, minimum size=1.0em, below of = #1, node distance= \horizdist + \dxpm, thin, draw=black] {}; + \node [left of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}}; + \node [above of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; +} + \newcommand{\kMinusMinusUp}[3]{ \def\dxpm{#3}; @@ -367,6 +638,52 @@ mark=at position 0.5 with {\arrow{Latex[]}}},postaction={decorate}}} \node [left of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}}; \node [above of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}}; } +\newcommand{\kMinusMinusUpL}[3]{ + + \def\dxpm{#3}; + + \ifx\dxpm\empty + \def\dxpm{0}; + \else + \fi + + \node [draw=\linecolor, circle,minimum size=1.5em, left of = #1, node distance= \horizdist+\dxpm, \linetype, + fill=\backgroundcolor, drop shadow={opacity=\dark}, font=\textsize] (#2) {}; + \node [draw, cross out, minimum size=1.0em, left of = #1, node distance= \horizdist + \dxpm, thin, draw=black] {}; + \node [left of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}}; + \node [above of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}}; +} +\newcommand{\kMinusMinusUpA}[3]{ + + \def\dxpm{#3}; + + \ifx\dxpm\empty + \def\dxpm{0}; + \else + \fi + + \node [draw=\linecolor, circle,minimum size=1.5em, above of = #1, node distance= \horizdist+\dxpm, \linetype, + fill=\backgroundcolor, drop shadow={opacity=\dark}, font=\textsize] (#2) {}; + \node [draw, cross out, minimum size=1.0em, above of = #1, node distance= \horizdist + \dxpm, thin, draw=black] {}; + \node [left of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}}; + \node [above of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}}; +} +\newcommand{\kMinusMinusUpB}[3]{ + + \def\dxpm{#3}; + + \ifx\dxpm\empty + \def\dxpm{0}; + \else + \fi + + \node [draw=\linecolor, circle,minimum size=1.5em, below of = #1, node distance= \horizdist+\dxpm, \linetype, + fill=\backgroundcolor, drop shadow={opacity=\dark}, font=\textsize] (#2) {}; + \node [draw, cross out, minimum size=1.0em, below of = #1, node distance= \horizdist + \dxpm, thin, draw=black] {}; + \node [left of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}}; + \node [above of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}}; +} + \newcommand{\kPlusMinusUp}[3]{ @@ -383,6 +700,51 @@ mark=at position 0.5 with {\arrow{Latex[]}}},postaction={decorate}}} \node [left of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; \node [above of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}}; } +\newcommand{\kPlusMinusUpB}[3]{ + + \def\dxpm{#3}; + + \ifx\dxpm\empty + \def\dxpm{0}; + \else + \fi + + \node [draw=\linecolor, circle,minimum size=1.5em, below of= #1, node distance= \horizdist+\dxpm, \linetype, + fill=\backgroundcolor, drop shadow={opacity=\dark}, font=\textsize] (#2) {}; + \node [draw, cross out, minimum size=1.0em, below of= #1, node distance= \horizdist + \dxpm, thin, draw=black] {}; + \node [left of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; + \node [above of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}}; +} +\newcommand{\kPlusMinusUpA}[3]{ + + \def\dxpm{#3}; + + \ifx\dxpm\empty + \def\dxpm{0}; + \else + \fi + + \node [draw=\linecolor, circle,minimum size=1.5em, above of= #1, node distance= \horizdist+\dxpm, \linetype, + fill=\backgroundcolor, drop shadow={opacity=\dark}, font=\textsize] (#2) {}; + \node [draw, cross out, minimum size=1.0em, above of= #1, node distance= \horizdist + \dxpm, thin, draw=black] {}; + \node [left of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; + \node [above of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}}; +} +\newcommand{\kPlusMinusUpL}[3]{ + + \def\dxpm{#3}; + + \ifx\dxpm\empty + \def\dxpm{0}; + \else + \fi + + \node [draw=\linecolor, circle,minimum size=1.5em, left of= #1, node distance= \horizdist+\dxpm, \linetype, + fill=\backgroundcolor, drop shadow={opacity=\dark}, font=\textsize] (#2) {}; + \node [draw, cross out, minimum size=1.0em, left of= #1, node distance= \horizdist + \dxpm, thin, draw=black] {}; + \node [left of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; + \node [above of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}}; +} \newcommand{\kPlusPlusUp}[3]{ @@ -399,6 +761,115 @@ mark=at position 0.5 with {\arrow{Latex[]}}},postaction={decorate}}} \node [left of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; \node [above of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; } +\newcommand{\kPlusPlusUpB}[3]{ + + \def\dxpm{#3}; + + \ifx\dxpm\empty + \def\dxpm{0}; + \else + \fi + + \node [draw=\linecolor, circle,minimum size=1.5em, below of= #1, node distance= \horizdist+\dxpm, \linetype, + fill=\backgroundcolor, drop shadow={opacity=\dark}, font=\textsize] (#2) {}; + \node [draw, cross out, minimum size=1.0em, below of= #1, node distance= \horizdist + \dxpm, thin, draw=black] {}; + \node [left of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; + \node [above of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; +} +\newcommand{\kPlusPlusUpA}[3]{ + + \def\dxpm{#3}; + + \ifx\dxpm\empty + \def\dxpm{0}; + \else + \fi + + \node [draw=\linecolor, circle,minimum size=1.5em, above of= #1, node distance= \horizdist+\dxpm, \linetype, + fill=\backgroundcolor, drop shadow={opacity=\dark}, font=\textsize] (#2) {}; + \node [draw, cross out, minimum size=1.0em, above of= #1, node distance= \horizdist + \dxpm, thin, draw=black] {}; + \node [left of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; + \node [above of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; +} +\newcommand{\kPlusPlusUpL}[3]{ + +\def\dxpm{#3}; + +\ifx\dxpm\empty +\def\dxpm{0}; +\else +\fi + +\node [draw=\linecolor, circle,minimum size=1.5em, left of= #1, node distance= \horizdist+\dxpm, \linetype, +fill=\backgroundcolor, drop shadow={opacity=\dark}, font=\textsize] (#2) {}; +\node [draw, cross out, minimum size=1.0em, left of= #1, node distance= \horizdist + \dxpm, thin, draw=black] {}; +\node [left of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; +\node [above of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; +} + +% up down +\newcommand{\kPlusDownPlusUp}[3]{ + + \def\dxpm{#3}; + + \ifx\dxpm\empty + \def\dxpm{0}; + \else + \fi + + \node [draw=\linecolor, circle,minimum size=1.5em, right of= #1, node distance= \horizdist+\dxpm, \linetype, + fill=\backgroundcolor, drop shadow={opacity=\dark}, font=\textsize] (#2) {}; + \node [draw, cross out, minimum size=1.0em, right of= #1, node distance= \horizdist + \dxpm, thin, draw=black] {}; + \node [below of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; + \node [above of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; +} +\newcommand{\kPlusDownPlusUpB}[3]{ + + \def\dxpm{#3}; + + \ifx\dxpm\empty + \def\dxpm{0}; + \else + \fi + + \node [draw=\linecolor, circle,minimum size=1.5em, below of= #1, node distance= \horizdist+\dxpm, \linetype, + fill=\backgroundcolor, drop shadow={opacity=\dark}, font=\textsize] (#2) {}; + \node [draw, cross out, minimum size=1.0em, below of= #1, node distance= \horizdist + \dxpm, thin, draw=black] {}; + \node [below of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; + \node [above of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; +} +\newcommand{\kPlusDownPlusUpA}[3]{ + + \def\dxpm{#3}; + + \ifx\dxpm\empty + \def\dxpm{0}; + \else + \fi + + \node [draw=\linecolor, circle,minimum size=1.5em, above of= #1, node distance= \horizdist+\dxpm, \linetype, + fill=\backgroundcolor, drop shadow={opacity=\dark}, font=\textsize] (#2) {}; + \node [draw, cross out, minimum size=1.0em, above of= #1, node distance= \horizdist + \dxpm, thin, draw=black] {}; + \node [below of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; + \node [above of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; +} +\newcommand{\kPlusDownPlusUpL}[3]{ + + \def\dxpm{#3}; + + \ifx\dxpm\empty + \def\dxpm{0}; + \else + \fi + + \node [draw=\linecolor, circle,minimum size=1.5em, left of= #1, node distance= \horizdist+\dxpm, \linetype, + fill=\backgroundcolor, drop shadow={opacity=\dark}, font=\textsize] (#2) {}; + \node [draw, cross out, minimum size=1.0em, left of= #1, node distance= \horizdist + \dxpm, thin, draw=black] {}; + \node [below of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; + \node [above of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; +} + +% left up down \newcommand{\kPlusPlusMinus}[3]{ \def\dxpm{#3}; @@ -415,6 +886,55 @@ mark=at position 0.5 with {\arrow{Latex[]}}},postaction={decorate}}} \node [above of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; \node [below of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}}; } +\newcommand{\kPlusPlusMinusB}[3]{ + + \def\dxpm{#3}; + + \ifx\dxpm\empty + \def\dxpm{0}; + \else + \fi + + \node [draw=\linecolor, circle,minimum size=1.5em, below of = #1, node distance= \horizdist+\dxpm, \linetype, + fill=\backgroundcolor, drop shadow={opacity=\dark}, font=\textsize] (#2) {}; + \node [draw, cross out, minimum size=1.0em, below of = #1, node distance= \horizdist + \dxpm, thin, draw=black] {}; + \node [left of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; + \node [above of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; + \node [below of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}}; +} +\newcommand{\kPlusPlusMinusA}[3]{ + + \def\dxpm{#3}; + + \ifx\dxpm\empty + \def\dxpm{0}; + \else + \fi + + \node [draw=\linecolor, circle,minimum size=1.5em, above of = #1, node distance= \horizdist+\dxpm, \linetype, + fill=\backgroundcolor, drop shadow={opacity=\dark}, font=\textsize] (#2) {}; + \node [draw, cross out, minimum size=1.0em, above of = #1, node distance= \horizdist + \dxpm, thin, draw=black] {}; + \node [left of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; + \node [above of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; + \node [below of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}}; +} +\newcommand{\kPlusPlusMinusL}[3]{ + + \def\dxpm{#3}; + + \ifx\dxpm\empty + \def\dxpm{0}; + \else + \fi + + \node [draw=\linecolor, circle,minimum size=1.5em, left of = #1, node distance= \horizdist+\dxpm, \linetype, + fill=\backgroundcolor, drop shadow={opacity=\dark}, font=\textsize] (#2) {}; + \node [draw, cross out, minimum size=1.0em, left of = #1, node distance= \horizdist + \dxpm, thin, draw=black] {}; + \node [left of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; + \node [above of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; + \node [below of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}}; +} + \newcommand{\kPlusMinusMinus}[3]{ \def\dxpm{#3}; @@ -431,6 +951,54 @@ mark=at position 0.5 with {\arrow{Latex[]}}},postaction={decorate}}} \node [above of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}}; \node [below of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}}; } +\newcommand{\kPlusMinusMinusL}[3]{ + + \def\dxpm{#3}; + + \ifx\dxpm\empty + \def\dxpm{0}; + \else + \fi + + \node [draw=\linecolor, circle,minimum size=1.5em, left of = #1, node distance= \horizdist+\dxpm, \linetype, + fill=\backgroundcolor, drop shadow={opacity=\dark}, font=\textsize] (#2) {}; + \node [draw, cross out, minimum size=1.0em, left of = #1, node distance= \horizdist + \dxpm, thin, draw=black] {}; + \node [left of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; + \node [above of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}}; + \node [below of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}}; +} +\newcommand{\kPlusMinusMinusA}[3]{ + + \def\dxpm{#3}; + + \ifx\dxpm\empty + \def\dxpm{0}; + \else + \fi + + \node [draw=\linecolor, circle,minimum size=1.5em, above of = #1, node distance= \horizdist+\dxpm, \linetype, + fill=\backgroundcolor, drop shadow={opacity=\dark}, font=\textsize] (#2) {}; + \node [draw, cross out, minimum size=1.0em, above of = #1, node distance= \horizdist + \dxpm, thin, draw=black] {}; + \node [left of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; + \node [above of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}}; + \node [below of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}}; +} +\newcommand{\kPlusMinusMinusB}[3]{ + + \def\dxpm{#3}; + + \ifx\dxpm\empty + \def\dxpm{0}; + \else + \fi + + \node [draw=\linecolor, circle,minimum size=1.5em, below of = #1, node distance= \horizdist+\dxpm, \linetype, + fill=\backgroundcolor, drop shadow={opacity=\dark}, font=\textsize] (#2) {}; + \node [draw, cross out, minimum size=1.0em, below of = #1, node distance= \horizdist + \dxpm, thin, draw=black] {}; + \node [left of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; + \node [above of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}}; + \node [below of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}}; +} \newcommand{\kPlusMinusPlus}[3]{ @@ -448,6 +1016,54 @@ mark=at position 0.5 with {\arrow{Latex[]}}},postaction={decorate}}} \node [above of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}}; \node [below of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; } +\newcommand{\kPlusMinusPlusB}[3]{ + + \def\dxpm{#3}; + + \ifx\dxpm\empty + \def\dxpm{0}; + \else + \fi + + \node [draw=\linecolor, circle,minimum size=1.5em, below of = #1, node distance= \horizdist+\dxpm, \linetype, + fill=\backgroundcolor, drop shadow={opacity=\dark}, font=\textsize] (#2) {}; + \node [draw, cross out, minimum size=1.0em, below of = #1, node distance= \horizdist + \dxpm, thin, draw=black] {}; + \node [left of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; + \node [above of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}}; + \node [below of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; +} +\newcommand{\kPlusMinusPlusA}[3]{ + + \def\dxpm{#3}; + + \ifx\dxpm\empty + \def\dxpm{0}; + \else + \fi + + \node [draw=\linecolor, circle,minimum size=1.5em, above of = #1, node distance= \horizdist+\dxpm, \linetype, + fill=\backgroundcolor, drop shadow={opacity=\dark}, font=\textsize] (#2) {}; + \node [draw, cross out, minimum size=1.0em, above of = #1, node distance= \horizdist + \dxpm, thin, draw=black] {}; + \node [left of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; + \node [above of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}}; + \node [below of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; +} +\newcommand{\kPlusMinusPlusL}[3]{ + + \def\dxpm{#3}; + + \ifx\dxpm\empty + \def\dxpm{0}; + \else + \fi + + \node [draw=\linecolor, circle,minimum size=1.5em, left of = #1, node distance= \horizdist+\dxpm, \linetype, + fill=\backgroundcolor, drop shadow={opacity=\dark}, font=\textsize] (#2) {}; + \node [draw, cross out, minimum size=1.0em, left of = #1, node distance= \horizdist + \dxpm, thin, draw=black] {}; + \node [left of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; + \node [above of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$-$}}; + \node [below of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; +} \newcommand{\kPlusPlusPlus}[3]{ @@ -465,6 +1081,55 @@ mark=at position 0.5 with {\arrow{Latex[]}}},postaction={decorate}}} \node [above of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; \node [below of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; } +\newcommand{\kPlusPlusPlusL}[3]{ + + \def\dxpm{#3}; + + \ifx\dxpm\empty + \def\dxpm{0}; + \else + \fi + + \node [draw=\linecolor, circle,minimum size=1.5em, left of = #1, node distance= \horizdist+\dxpm, \linetype, + fill=\backgroundcolor, drop shadow={opacity=\dark}, font=\textsize] (#2) {}; + \node [draw, cross out, minimum size=1.0em, left of = #1, node distance= \horizdist + \dxpm, thin, draw=black] {}; + \node [left of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; + \node [above of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; + \node [below of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; +} +\newcommand{\kPlusPlusPlusA}[3]{ + + \def\dxpm{#3}; + + \ifx\dxpm\empty + \def\dxpm{0}; + \else + \fi + + \node [draw=\linecolor, circle,minimum size=1.5em, above of = #1, node distance= \horizdist+\dxpm, \linetype, + fill=\backgroundcolor, drop shadow={opacity=\dark}, font=\textsize] (#2) {}; + \node [draw, cross out, minimum size=1.0em, above of = #1, node distance= \horizdist + \dxpm, thin, draw=black] {}; + \node [left of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; + \node [above of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; + \node [below of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; +} +\newcommand{\kPlusPlusPlusB}[3]{ + + \def\dxpm{#3}; + + \ifx\dxpm\empty + \def\dxpm{0}; + \else + \fi + + \node [draw=\linecolor, circle,minimum size=1.5em, below of = #1, node distance= \horizdist+\dxpm, \linetype, + fill=\backgroundcolor, drop shadow={opacity=\dark}, font=\textsize] (#2) {}; + \node [draw, cross out, minimum size=1.0em, below of = #1, node distance= \horizdist + \dxpm, thin, draw=black] {}; + \node [left of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; + \node [above of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; + \node [below of= #2, node distance = 0.45em] () { \color{\colortext}\tiny{$+$}}; +} + % Circular Gain Block \newcommand{\kGain}[4][]{ @@ -632,60 +1297,100 @@ mark=at position 0.5 with {\arrow{Latex[]}}},postaction={decorate}}} % Mark Visible Circular Nodes -%% Usage: [optional distance shift]{optional node label}{from node label}{to current node label} -% Place Node Right -\newcommand{\kMarkNodeRight}[4][]{ - \def\dxnr{#1}; +% Place Node with variable x-y coordinate shift +%% Usage: {node x distance shift}{node y distance shift}{node text label}{from node label}{to current node label} - \ifx\dxnr\empty - \def\dxnr{0}; +% Place Node Left +\newcommand{\kMarkNodeLeft}[5]{ + \def\dxnlx{#1}; + \def\dynly{#2}; + + \ifx\dxnlx\empty + \def\dxnlx{0}; \else - \fi - \node[fill=\linecolor,circle,inner sep=0pt, outer sep=0pt, minimum size=.3em, - right of = #3, node distance= 1.2cm + \dxnr] (#4) {\textsize{#2}}; - + \fi + \ifx\dynly\empty + \def\dynly{0}; + \else + \fi + \node[fill=\linecolor,circle,inner sep=0pt, outer sep=0pt, minimum size=0.3em, + left of = #4, node distance= 1.2cm + \dxnlx, yshift=\dynly, label=\textsize{#3}] (#5) {}; } -% Place Node Left -\newcommand{\kMarkNodeLeft}[4][]{ - \def\dxnl{#1}; - \ifx\dxnl\empty - \def\dxnl{0}; +% Place Node Right +\newcommand{\kMarkNodeRight}[5]{ + \def\dxnrx{#1}; + \def\dynry{#2}; + + \ifx\dxnrx\empty + \def\dxnrx{0}; \else - \fi - \node[fill=\linecolor,circle,inner sep=0pt, outer sep=0pt, minimum size=.3em, - left of = #3, node distance= 1.2cm + \dxnl] (#4) {\textsize{#2}}; - + \fi + \ifx\dynry\empty + \def\dynry{0}; + \else + \fi + \node[fill=\linecolor,circle,inner sep=0pt, outer sep=0pt, minimum size=0.3em, + right of = #4, node distance= 1.2cm + \dxnrx, yshift=\dynry, label=\textsize{#3}] (#5) {}; } -% Place Node Above -\newcommand{\kMarkNodeAbove}[4][]{ - \def\dxna{#1}; - \ifx\dxna\empty - \def\dxna{0}; +% Place Node Above +\newcommand{\kMarkNodeAbove}[5]{ + \def\dxnax{#1}; + \def\dynay{#2}; + + \ifx\dxnax\empty + \def\dxnax{0}; \else - \fi - \node[fill=\linecolor,circle,inner sep=0pt, outer sep=0pt, minimum size=.3em, - above of = #3, node distance= 1.2cm + \dxna] (#4) {\textsize{#2}}; - \node[fill=\linecolor,circle,inner sep=0pt, outer sep=0pt, minimum size=.3em, - above of = #3, node distance= 1.2cm + \dxna] (#4) {\textsize{#2}}; - + \fi + \ifx\dynay\empty + \def\dynay{0}; + \else + \fi + \node[fill=\linecolor,circle,inner sep=0pt, outer sep=0pt, minimum size=0.3em, + above of = #4, node distance= 1.2cm + \dxnax, yshift=\dynay, label=\textsize{#3}] (#5) {}; } -% Place Node Below -\newcommand{\kMarkNodeBelow}[4][]{ - \def\dxnb{#1}; - \ifx\dxnb\empty - \def\dxnb{0}; +% Place Node Below +\newcommand{\kMarkNodeBelow}[5]{ + \def\dxnbx{#1}; + \def\dynby{#2}; + + \ifx\dxnbx\empty + \def\dxnbx{0}; \else - \fi - \node[fill=\linecolor,circle,inner sep=0pt, outer sep=0pt, minimum size=.3em, - below of = #3, node distance= 1.2cm + \dxnb] (#4) {\textsize{#2}}; + \fi + \ifx\dynby\empty + \def\dynby{0}; + \else + \fi + \node[fill=\linecolor,circle,inner sep=0pt, outer sep=0pt, minimum size=0.3em, + below of = #4, node distance= 1.2cm + \dxnbx, yshift=\dynby, label=\textsize{#3}] (#5) {}; +} + +% Place Node At Coordinate +%% Usage: {optional x distance shift}{optional y distance shift}{empty text-label}{current node coordinate} +\newcommand{\kMarkNode}[4]{ + \def\dxncsx{#1}; + \def\dyncsy{#2}; + + \ifx\dxncsx\empty + \def\dxncsx{0}; + \else + \fi + \ifx\dyncsy\empty + \def\dyncsy{0}; + \else + \fi + + \node[fill=\linecolor,circle,inner sep=0pt, outer sep=0pt, minimum size=.3em, + node distance= 0cm + \dxncsx, yshift=\dyncsy, label=\textsize{#3}] (#4) {}; } + % Place a Reference Invisible Node relative to other nodes %% Usage: [optional distance shift]{from node label}{to current coordinate label}{direction shift}{coordinate text label} @@ -732,38 +1437,790 @@ mark=at position 0.5 with {\arrow{Latex[]}}},postaction={decorate}}} % Place a Reference Invisible Node at any specific coordinate %% Usage: {current coordinate label}{coordinate (x,y)} -\newcommand{\kJumpCS}[2]{ - \coordinate (#1) at (#2); +\newcommand{\kJumpCS}[2][$(0,0)$]{ + \coordinate (#2) at (#1); } % Links %% swap, near end,mid, add label text above lines or besides %% Usage: [optional signal label]{from node label}{to node label} - % Link Left or Right, Up or Down \newcommand{\kLink}[3][]{ - \draw [-latex,\linecolor, \linepathtype] (#2) -- node[auto,above] {\textsize{#1}} (#3); + \draw [-latex,\linecolor, \linepathtype] (#2) -- node[auto] {\textsize{#1}} (#3); } % no arrow \newcommand{\kLinkn}[3][]{ \draw [\linecolor, \linepathtype] (#2) -- node[auto,above] {\textsize{#1}} (#3); } -% Link Horizontal(Right or Left) Vertical(Up or Down) -%% Usage: [optional link label]{from node label}{to current node label}{direction}{direction shift} +%% Vector link variant +% Link Left or Right, Up or Down +\newcommand{\kVecLink}[3][]{ + \draw [-latex,\linecolor, veclinetype] (#2) -- node[auto] {\textsize{#1}} (#3); +} +% no arrow +\newcommand{\kVecLinkn}[3][]{ + \draw [\linecolor, veclinetype] (#2) -- node[auto,above] {\textsize{#1}} (#3); +} + +%% Link Directed TODO: investigate use +%% Usage: [optional signal link label]{from node label}{to node label}{from-to node direction shift} +% Directed Link Left or Right, Up or Down +\newcommand{\kLinkdir}[4][]{ + \coordinate (tmp) at ($(#2.west) + (0,#4)$); + \draw[-latex, \linecolor, \linepathtype] (tmp) -- node[auto] {\textsize{#1}} ($(#3.east) + (0,#4)$); +} +% no arrow +\newcommand{\kLinkndir}[4][]{ + \coordinate (tmp) at ($(#2.west) + (0,#4)$); + \draw[\linecolor, \linepathtype] (tmp) -- node[auto] {\textsize{#1}} ($(#3.east) + (0,#4)$); +} +%% Vector link variant +\newcommand{\kVecLinkdir}[4][]{ + \coordinate (tmp) at ($(#2.west) + (0,#4)$); + \draw[-latex, \linecolor, veclinetype] (tmp) -- node[auto] {\textsize{#1}} ($(#3.east) + (0,#4)$); +} +% no arrow +\newcommand{\kVecLinkndir}[4][]{ + \coordinate (tmp) at ($(#2.west) + (0,#4)$); + \draw[\linecolor, veclinetype] (tmp) -- node[auto] {\textsize{#1}} ($(#3.east) + (0,#4)$); +} + +% Link Horizontal(Right or Left) Vertical(Up or Down) +%% Usage: [optional link label]{from node label}{to current node label}{direction shift y}{direction shift x}{link label position} % Link: Left Up, Left Down, Right Up, Right Down -\newcommand{\kLinkHV}[5][]{ - \def\direct{#4}; - \draw[-latex, \linecolor, \linepathtype] (#2) -| node[near end, above left] {\textsize{#1}} ($(#3.\direct) + (0,#5)$); +\newcommand{\kLinkHV}[7][]{% TODO:DONE + \def\dxpos{#5}; + \ifx\dxpos\empty + \def\dxpos{0}; + \else + \fi + + \def\dypos{#4}; + \ifx\dypos\empty + \def\dypos{0}; + \else + \fi + + \coordinate (fromn) at (#2);% from node coordinate + \coordinate (ton) at (#3);% to node coordinate + + + % extract x and y coordinates + \newdimen\xf;% + \newdimen\yf;% + \path (fromn); \pgfgetlastxy{\xf}{\yf}; + \newdimen\xt;% + \newdimen\yt;% + \path (ton); \pgfgetlastxy{\xt}{\yt}; + + \newdimen\asumxft; + + \tikzmath{ + \asumxft = \yt - \yf; + if \asumxft>0 then {let \directn = south;} else { + if \asumxft<0 then {let \directn = north;} else { + let \directn = 0; + }; + }; + \asumxft = \xt - \xf; + if \asumxft>0 then {let \fdirectn = east;} else { + if \asumxft<0 then {let \fdirectn = west;} else { + let \fdirectn = 0; + }; + }; + } + + % immediate marking of perpendicular edge of VH or HV links + \def\mkpt{#7}; + \ifx\mkpt\empty + \else + \coordinate (hat3) at ($(#3.\directn) + (0,\dypos)$); + \newdimen\xtohat; + \newdimen\ytohat;% + \path (hat3); \pgfgetlastxy{\xtohat}{\ytohat}; + \coordinate (#7) at (\xf,\ytohat); % markpt coordinate + %\coordinate (#1) at (\xf,\yt); % markpt coordinate + \node[fill=\linecolor,circle,inner sep=0pt, outer sep=0pt, minimum size=0.3em] at (\xf,\ytohat) {}; + \fi + + % label positioning: 10 options (0 - 9) + \def\poslabel{#6}; + \ifx\poslabel\empty + \def\poslabel{5}; + \else + \fi + + % integer register, count0 (0-255) + \count0=\poslabel\relax; + + \ifnum\count0=0 + \draw[-latex, \linecolor, \linepathtype] ($(#2.\fdirectn) + (0,\dypos)$) -| node[above, pos=0.15] {\textsize{#1}} ($(#3.\directn) + (\dxpos,0)$); + \else + \ifnum\count0=1 + \draw[-latex, \linecolor, \linepathtype] ($(#2.\fdirectn) + (0,\dypos)$) -| node[below, pos=0.15] {\textsize{#1}} ($(#3.\directn) + (\dxpos,0)$); + \else + \ifnum\count0=2 + \draw[-latex, \linecolor, \linepathtype] ($(#2.\fdirectn) + (0,\dypos)$) -| node[above, pos=0.3] {\textsize{#1}} ($(#3.\directn) + (\dxpos,0)$); + \else + \ifnum\count0=3 + \draw[-latex, \linecolor, \linepathtype] ($(#2.\fdirectn) + (0,\dypos)$) -| node[below, pos=0.3] {\textsize{#1}} ($(#3.\directn) + (\dxpos,0)$); + \else + \ifnum\count0=4 + \draw[-latex, \linecolor, \linepathtype] ($(#2.\fdirectn) + (0,\dypos)$) -| node[above left,pos=0.5] {\textsize{#1}} ($(#3.\directn) + (\dxpos,0)$); + \else + \ifnum\count0=5 + \draw[-latex, \linecolor, \linepathtype] ($(#2.\fdirectn) + (0,\dypos)$) -| node[above right,pos=0.5] {\textsize{#1}} ($(#3.\directn) + (\dxpos,0)$); + \else + \ifnum\count0=6 + \draw[-latex, \linecolor, \linepathtype] ($(#2.\fdirectn) + (0,\dypos)$) -| node[below left,pos=0.5] {\textsize{#1}} ($(#3.\directn) + (\dxpos,0)$); + \else + \ifnum\count0=7 + \draw[-latex, \linecolor, \linepathtype] ($(#2.\fdirectn) + (0,\dypos)$) -| node[below right,pos=0.5] {\textsize{#1}} ($(#3.\directn) + (\dxpos,0)$); + \else + \ifnum\count0=8 + \draw[-latex, \linecolor, \linepathtype] ($(#2.\fdirectn) + (0,\dypos)$) -| node[left,pos=0.75] {\textsize{#1}} ($(#3.\directn) + (\dxpos,0)$); + \else + \ifnum\count0=9 + \draw[-latex, \linecolor, \linepathtype] ($(#2.\fdirectn) + (0,\dypos)$) -| node[right,pos=0.75] {\textsize{#1}} ($(#3.\directn) + (\dxpos,0)$); + \else + \draw[-latex, \linecolor, \linepathtype] ($(#2.\fdirectn) + (0,\dypos)$) -| node[above left,pos=0.5] {\textsize{#1}} ($(#3.\directn) + (\dxpos,0)$); + \fi + \fi + \fi + \fi + \fi + \fi + \fi + \fi + \fi + \fi +} + + +%% vector variant +\newcommand{\kVecLinkHV}[6][]{% TODO:extend changes made here to its other HV variants + \def\dxpos{#5}; + \ifx\dxpos\empty + \def\dxpos{0}; + \else + \fi + + \def\dypos{#4}; + \ifx\dypos\empty + \def\dypos{0}; + \else + \fi + + \coordinate (fromn) at (#2);% from node coordinate + \coordinate (ton) at (#3);% to node coordinate + + + % extract x and y coordinates + \newdimen\xf;% + \newdimen\yf;% + \path (fromn); \pgfgetlastxy{\xf}{\yf}; + \newdimen\xt;% + \newdimen\yt;% + \path (ton); \pgfgetlastxy{\xt}{\yt}; + + \newdimen\asumxft; + + \tikzmath{ + \asumxft = \yt - \yf; + if \asumxft>0 then {let \directn = south;} else { + if \asumxft<0 then {let \directn = north;} else { + let \directn = 0; + }; + }; + \asumxft = \xt - \xf; + if \asumxft>0 then {let \fdirectn = east;} else { + if \asumxft<0 then {let \fdirectn = west;} else { + let \fdirectn = 0; + }; + }; + } + +\ifnum#6=0 +\draw[-latex, \linecolor, veclinetype] ($(#2.\fdirectn) + (0,\dypos)$) -| node[near end, above left] {\textsize{#1}} ($(#3.\directn) + (\dxpos,0)$); +\else +\ifnum#6=1 +\draw[-latex, \linecolor, veclinetype] ($(#2.\fdirectn) + (0,\dypos)$) -| node[near end, above right] {\textsize{#1}} ($(#3.\directn) + (\dxpos,0)$); +\else +\ifnum#6=2 +\draw[-latex, \linecolor, veclinetype] ($(#2.\fdirectn) + (0,\dypos)$) -| node[near end, below left] {\textsize{#1}} ($(#3.\directn) + (\dxpos,0)$); +\else +\ifnum#6=3 +\draw[-latex, \linecolor, veclinetype] ($(#2.\fdirectn) + (0,\dypos)$) -| node[near end, below right] {\textsize{#1}} ($(#3.\directn) + (\dxpos,0)$); +\else +\ifnum#6=4 +\draw[-latex, \linecolor, veclinetype] ($(#2.\fdirectn) + (0,\dypos)$) -| node[midway, above left] {\textsize{#1}} ($(#3.\directn) + (\dxpos,0)$); +\else +\ifnum#6=5 +\draw[-latex, \linecolor, veclinetype] ($(#2.\fdirectn) + (0,\dypos)$) -| node[midway, above right] {\textsize{#1}} ($(#3.\directn) + (\dxpos,0)$); +\else +\ifnum#6=6 +\draw[-latex, \linecolor, veclinetype] ($(#2.\fdirectn) + (0,\dypos)$) -| node[midway, below left] {\textsize{#1}} ($(#3.\directn) + (\dxpos,0)$); +\else +\ifnum#6=7 +\draw[-latex, \linecolor, veclinetype] ($(#2.\fdirectn) + (0,\dypos)$) -| node[midway, below right] {\textsize{#1}} ($(#3.\directn) + (\dxpos,0)$); +\else +\ifnum#6=8 +\draw[-latex, \linecolor, veclinetype] ($(#2.\fdirectn) + (0,\dypos)$) -| node[midway, below] {\textsize{#1}} ($(#3.\directn) + (\dxpos,0)$); +\else +\draw[-latex, \linecolor, veclinetype] ($(#2.\fdirectn) + (0,\dypos)$) -| node[near end, above] {\textsize{#1}} ($(#3.\directn) + (\dxpos,0)$); +\fi +\fi +\fi +\fi +\fi +\fi +\fi +\fi +\fi + +} + +%% No direction +\newcommand{\kLinknHV}[6][]{% TODO:extend changes made here to its other HV variants + \def\dxpos{#5}; + \ifx\dxpos\empty + \def\dxpos{0}; + \else + \fi + + \def\dypos{#4}; + \ifx\dypos\empty + \def\dypos{0}; + \else + \fi + + \coordinate (fromn) at (#2);% from node coordinate + \coordinate (ton) at (#3);% to node coordinate + + + % extract x and y coordinates + \newdimen\xf;% + \newdimen\yf;% + \path (fromn); \pgfgetlastxy{\xf}{\yf}; + \newdimen\xt;% + \newdimen\yt;% + \path (ton); \pgfgetlastxy{\xt}{\yt}; + + \newdimen\asumxft; + + \tikzmath{ + \asumxft = \yt - \yf; + if \asumxft>0 then {let \directn = south;} else { + if \asumxft<0 then {let \directn = north;} else { + let \directn = 0; + }; + }; + \asumxft = \xt - \xf; + if \asumxft>0 then {let \fdirectn = east;} else { + if \asumxft<0 then {let \fdirectn = west;} else { + let \fdirectn = 0; + }; + }; + } + +\ifnum#6=0 +\draw[\linecolor, \linepathtype] ($(#2.\fdirectn) + (0,\dypos)$) -| node[near end, above left] {\textsize{#1}} ($(#3.\directn) + (\dxpos,0)$); +\else +\ifnum#6=1 +\draw[\linecolor, \linepathtype] ($(#2.\fdirectn) + (0,\dypos)$) -| node[near end, above right] {\textsize{#1}} ($(#3.\directn) + (\dxpos,0)$); +\else +\ifnum#6=2 +\draw[\linecolor, \linepathtype] ($(#2.\fdirectn) + (0,\dypos)$) -| node[near end, below left] {\textsize{#1}} ($(#3.\directn) + (\dxpos,0)$); +\else +\ifnum#6=3 +\draw[\linecolor, \linepathtype] ($(#2.\fdirectn) + (0,\dypos)$) -| node[near end, below right] {\textsize{#1}} ($(#3.\directn) + (\dxpos,0)$); +\else +\ifnum#6=4 +\draw[\linecolor, \linepathtype] ($(#2.\fdirectn) + (0,\dypos)$) -| node[midway, above left] {\textsize{#1}} ($(#3.\directn) + (\dxpos,0)$); +\else +\ifnum#6=5 +\draw[\linecolor, \linepathtype] ($(#2.\fdirectn) + (0,\dypos)$) -| node[midway, above right] {\textsize{#1}} ($(#3.\directn) + (\dxpos,0)$); +\else +\ifnum#6=6 +\draw[\linecolor, \linepathtype] ($(#2.\fdirectn) + (0,\dypos)$) -| node[midway, below left] {\textsize{#1}} ($(#3.\directn) + (\dxpos,0)$); +\else +\ifnum#6=7 +\draw[\linecolor, \linepathtype] ($(#2.\fdirectn) + (0,\dypos)$) -| node[midway, below right] {\textsize{#1}} ($(#3.\directn) + (\dxpos,0)$); +\else +\ifnum#6=8 +\draw[\linecolor, \linepathtype] ($(#2.\fdirectn) + (0,\dypos)$) -| node[midway, below] {\textsize{#1}} ($(#3.\directn) + (\dxpos,0)$); +\else +\draw[\linecolor, \linepathtype] ($(#2.\fdirectn) + (0,\dypos)$) -| node[near end, above] {\textsize{#1}} ($(#3.\directn) + (\dxpos,0)$); +\fi +\fi +\fi +\fi +\fi +\fi +\fi +\fi +\fi + + % \def\mkpt{#5}; + % \ifx\mkpt\empty + % \else + % \coordinate (#5) at (\xf,\yt); % markpt coordinate + % \node[fill=\linecolor,circle,inner sep=0pt, outer sep=0pt, minimum size=0.3em] at (\xt,\yf) {}; + % \fi +} +%% vector variant +\newcommand{\kVecLinknHV}[6][]{% TODO:extend changes made here to its other HV variants + \def\dxpos{#5}; + \ifx\dxpos\empty + \def\dxpos{0}; + \else + \fi + + \def\dypos{#4}; + \ifx\dypos\empty + \def\dypos{0}; + \else + \fi + + \coordinate (fromn) at (#2);% from node coordinate + \coordinate (ton) at (#3);% to node coordinate + + + % extract x and y coordinates + \newdimen\xf;% + \newdimen\yf;% + \path (fromn); \pgfgetlastxy{\xf}{\yf}; + \newdimen\xt;% + \newdimen\yt;% + \path (ton); \pgfgetlastxy{\xt}{\yt}; + + \newdimen\asumxft; + + \tikzmath{ + \asumxft = \yt - \yf; + if \asumxft>0 then {let \directn = south;} else { + if \asumxft<0 then {let \directn = north;} else { + let \directn = 0; + }; + }; + \asumxft = \xt - \xf; + if \asumxft>0 then {let \fdirectn = east;} else { + if \asumxft<0 then {let \fdirectn = west;} else { + let \fdirectn = 0; + }; + }; + } + +\ifnum#6=0 +\draw[\linecolor, veclinetype] ($(#2.\fdirectn) + (0,\dypos)$) -| node[near end, above left] {\textsize{#1}} ($(#3.\directn) + (\dxpos,0)$); +\else +\ifnum#6=1 +\draw[\linecolor, veclinetype] ($(#2.\fdirectn) + (0,\dypos)$) -| node[near end, above right] {\textsize{#1}} ($(#3.\directn) + (\dxpos,0)$); +\else +\ifnum#6=2 +\draw[\linecolor, veclinetype] ($(#2.\fdirectn) + (0,\dypos)$) -| node[near end, below left] {\textsize{#1}} ($(#3.\directn) + (\dxpos,0)$); +\else +\ifnum#6=3 +\draw[\linecolor, veclinetype] ($(#2.\fdirectn) + (0,\dypos)$) -| node[near end, below right] {\textsize{#1}} ($(#3.\directn) + (\dxpos,0)$); +\else +\ifnum#6=4 +\draw[\linecolor, veclinetype] ($(#2.\fdirectn) + (0,\dypos)$) -| node[midway, above left] {\textsize{#1}} ($(#3.\directn) + (\dxpos,0)$); +\else +\ifnum#6=5 +\draw[\linecolor, veclinetype] ($(#2.\fdirectn) + (0,\dypos)$) -| node[midway, above right] {\textsize{#1}} ($(#3.\directn) + (\dxpos,0)$); +\else +\ifnum#6=6 +\draw[\linecolor, veclinetype] ($(#2.\fdirectn) + (0,\dypos)$) -| node[midway, below left] {\textsize{#1}} ($(#3.\directn) + (\dxpos,0)$); +\else +\ifnum#6=7 +\draw[\linecolor, veclinetype] ($(#2.\fdirectn) + (0,\dypos)$) -| node[midway, below right] {\textsize{#1}} ($(#3.\directn) + (\dxpos,0)$); +\else +\ifnum#6=8 +\draw[\linecolor, veclinetype] ($(#2.\fdirectn) + (0,\dypos)$) -| node[midway, below] {\textsize{#1}} ($(#3.\directn) + (\dxpos,0)$); +\else +\draw[\linecolor, veclinetype] ($(#2.\fdirectn) + (0,\dypos)$) -| node[near end, above] {\textsize{#1}} ($(#3.\directn) + (\dxpos,0)$); +\fi +\fi +\fi +\fi +\fi +\fi +\fi +\fi +\fi + } + + % Link Vertical(Up or Down) Horizontal(Right or Left) % Link Up Left, Up Right, Down Left, Down Right -\newcommand{\kLinkVH}[5][]{ - \def\direct{#4}; - \draw[-latex, \linecolor, \linepathtype] (#2) |- node[near end, below] {\textsize{#1}} ($(#3.\direct) + (0,#5)$); -} +\newcommand{\kLinkVH}[7][]{ % TODO:DONE + + \def\dypos{#4}; + \def\dxpos{#5}; + \ifx\dypos\empty + \def\dypos{0}; + \else + \fi + \ifx\dxpos\empty + \def\dxpos{0}; + \else + \fi + + \coordinate (fromn) at (#2);% from node coordinate + \coordinate (ton) at (#3);% to node coordinate + + + % extract x and y coordinates + \newdimen\xf;% + \newdimen\yf;% + \path (fromn); \pgfgetlastxy{\xf}{\yf}; + \newdimen\xt;% + \newdimen\yt;% + \path (ton); \pgfgetlastxy{\xt}{\yt}; + + \newdimen\asumxft; + + \tikzmath{ + \asumxft = \xt - \xf; + if \asumxft>0 then {let \directn = west;} else { + if \asumxft<0 then {let \directn = east;} else { + let \directn = 0; + }; + }; + \asumyft = \yt - \yf; + if \asumyft>0 then {let \fdirectn = north;} else { + if \asumyft<0 then {let \fdirectn = south;} else { + let \fdirectn = 0; + }; + }; + } + + + % immediate marking of perpendicular edge of VH or HV links + \def\mkpt{#7}; + \ifx\mkpt\empty + \else + \coordinate (hat3) at ($(#3.\directn) + (0,\dypos)$); + \newdimen\xtohat; + \newdimen\ytohat;% + \path (hat3); \pgfgetlastxy{\xtohat}{\ytohat}; + \coordinate (#7) at (\xf,\ytohat); % markpt coordinate + %\coordinate (#1) at (\xf,\yt); % markpt coordinate + \node[fill=\linecolor,circle,inner sep=0pt, outer sep=0pt, minimum size=0.3em] at (\xf,\ytohat) {}; + \fi + + + % label positioning: 10 options (0 - 9) + \def\poslabel{#6}; + \ifx\poslabel\empty + \def\poslabel{5}; + \else + \fi + + % integer register, count0 (0-255) + \count0=\poslabel\relax; + + \ifnum\count0=0 + \draw[-latex, \linecolor, \linepathtype] ($(#2.\fdirectn) + (\dxpos,0)$) |- node[left,pos=0.15] {\textsize{#1}} ($(#3.\directn) + (0,\dypos)$); + \else + \ifnum\count0=1 + \draw[-latex, \linecolor, \linepathtype] ($(#2.\fdirectn) + (\dxpos,0)$) |- node[right, pos=0.15] {\textsize{#1}} ($(#3.\directn) + (0,\dypos)$); + \else + \ifnum\count0=2 + \draw[-latex, \linecolor, \linepathtype] ($(#2.\fdirectn) + (\dxpos,0)$) |- node[left,pos=0.3] {\textsize{#1}} ($(#3.\directn) + (0,\dypos)$); + \else + \ifnum\count0=3 + \draw[-latex, \linecolor, \linepathtype] ($(#2.\fdirectn) + (\dxpos,0)$) |- node[right,pos=0.3] {\textsize{#1}} ($(#3.\directn) + (0,\dypos)$); + \else + \ifnum\count0=4 + \draw[-latex, \linecolor, \linepathtype] ($(#2.\fdirectn) + (\dxpos,0)$) |- node[above left,pos=0.5] {\textsize{#1}} ($(#3.\directn) + (0,\dypos)$); + \else + \ifnum\count0=5 + \draw[-latex, \linecolor, \linepathtype] ($(#2.\fdirectn) + (\dxpos,0)$) |- node[above right,pos=0.5] {\textsize{#1}} ($(#3.\directn) + (0,\dypos)$); + \else + \ifnum\count0=6 + \draw[-latex, \linecolor, \linepathtype] ($(#2.\fdirectn) + (\dxpos,0)$) |- node[below left,pos=0.5] {\textsize{#1}} ($(#3.\directn) + (0,\dypos)$); + \else + \ifnum\count0=7 + \draw[-latex, \linecolor, \linepathtype] ($(#2.\fdirectn) + (\dxpos,0)$) |- node[below right,pos=0.5] {\textsize{#1}} ($(#3.\directn) + (0,\dypos)$); + \else + \ifnum\count0=8 + \draw[-latex, \linecolor, \linepathtype] ($(#2.\fdirectn) + (\dxpos,0)$) |- node[above, pos=0.75] {\textsize{#1}} ($(#3.\directn) + (0,\dypos)$); + \else + \ifnum\count0=9 + \draw[-latex, \linecolor, \linepathtype] ($(#2.\fdirectn) + (\dxpos,0)$) |- node[below, pos=0.75] {\textsize{#1}} ($(#3.\directn) + (0,\dypos)$); + \else + \draw[-latex, \linecolor, \linepathtype] ($(#2.\fdirectn) + (\dxpos,0)$) |- node[above right,pos=0.5] {\textsize{#1}} ($(#3.\directn) + (0,\dypos)$); + \fi + \fi + \fi + \fi + \fi + \fi + \fi + \fi + \fi + \fi + +} + +%% vector variant +\newcommand{\kVecLinkVH}[6][]{ % TODO:extend changes made here to its other VH variants + + \def\dypos{#4}; + \def\dxpos{#5}; + \ifx\dypos\empty + \def\dypos{0}; + \else + \fi + \ifx\dxpos\empty + \def\dxpos{0}; + \else + \fi + + \coordinate (fromn) at (#2);% from node coordinate + \coordinate (ton) at (#3);% to node coordinate + + + % extract x and y coordinates + \newdimen\xf;% + \newdimen\yf;% + \path (fromn); \pgfgetlastxy{\xf}{\yf}; + \newdimen\xt;% + \newdimen\yt;% + \path (ton); \pgfgetlastxy{\xt}{\yt}; + + \newdimen\asumxft; + + \tikzmath{ + \asumxft = \xt - \xf; + if \asumxft>0 then {let \directn = west;} else { + if \asumxft<0 then {let \directn = east;} else { + let \directn = 0; + }; + }; + \asumyft = \yt - \yf; + if \asumyft>0 then {let \fdirectn = north;} else { + if \asumyft<0 then {let \fdirectn = south;} else { + let \fdirectn = 0; + }; + }; + } + + +\ifnum#6=0 +\draw[-latex, \linecolor, veclinetype] ($(#2.\fdirectn) + (\dxpos,0)$) |- node[near end, above] {\textsize{#1}} ($(#3.\directn) + (0,\dypos)$); +\else +\ifnum#6=1 +\draw[-latex, \linecolor, veclinetype] ($(#2.\fdirectn) + (\dxpos,0)$) |- node[near end, above right] {\textsize{#1}} ($(#3.\directn) + (0,\dypos)$); +\else +\ifnum#6=2 +\draw[-latex, \linecolor, veclinetype] ($(#2.\fdirectn) + (\dxpos,0)$) |- node[near end, below] {\textsize{#1}} ($(#3.\directn) + (0,\dypos)$); +\else +\ifnum#6=3 +\draw[-latex, \linecolor, veclinetype] ($(#2.\fdirectn) + (\dxpos,0)$) |- node[near end, below right] {\textsize{#1}} ($(#3.\directn) + (0,\dypos)$); +\else +\ifnum#6=4 +\draw[-latex, \linecolor, veclinetype] ($(#2.\fdirectn) + (\dxpos,0)$) |- node[midway, above] {\textsize{#1}} ($(#3.\directn) + (0,\dypos)$); +\else +\ifnum#6=5 +\draw[-latex, \linecolor, veclinetype] ($(#2.\fdirectn) + (\dxpos,0)$) |- node[midway, above right] {\textsize{#1}} ($(#3.\directn) + (0,\dypos)$); +\else +\ifnum#6=6 +\draw[-latex, \linecolor, veclinetype] ($(#2.\fdirectn) + (\dxpos,0)$) |- node[midway, above left] {\textsize{#1}} ($(#3.\directn) + (0,\dypos)$); +\else +\ifnum#6=7 +\draw[-latex, \linecolor, veclinetype] ($(#2.\fdirectn) + (\dxpos,0)$) |- node[midway, below right] {\textsize{#1}} ($(#3.\directn) + (0,\dypos)$); +\else +\ifnum#6=8 +\draw[-latex, \linecolor, veclinetype] ($(#2.\fdirectn) + (\dxpos,0)$) |- node[midway, below left] {\textsize{#1}} ($(#3.\directn) + (0,\dypos)$); +\else +\draw[-latex, \linecolor, veclinetype] ($(#2.\fdirectn) + (\dxpos,0)$) |- node[auto, above] {\textsize{#1}} ($(#3.\directn) + (0,\dypos)$); +\fi +\fi +\fi +\fi +\fi +\fi +\fi +\fi +\fi + +} + +%% No Direction +\newcommand{\kLinknVH}[6][]{ % TODO:extend changes made here to its other VH variants + + \def\dypos{#4}; + \def\dxpos{#5}; + \ifx\dypos\empty + \def\dypos{0}; + \else + \fi + \ifx\dxpos\empty + \def\dxpos{0}; + \else + \fi + + \coordinate (fromn) at (#2);% from node coordinate + \coordinate (ton) at (#3);% to node coordinate + -%% Usage: {optional link scale}{link label}{from node}{to node}{from node direction shift}{to node direction shift} + % extract x and y coordinates + \newdimen\xf;% + \newdimen\yf;% + \path (fromn); \pgfgetlastxy{\xf}{\yf}; + \newdimen\xt;% + \newdimen\yt;% + \path (ton); \pgfgetlastxy{\xt}{\yt}; + + \newdimen\asumxft; + + \tikzmath{ + \asumxft = \xt - \xf; + if \asumxft>0 then {let \directn = west;} else { + if \asumxft<0 then {let \directn = east;} else { + let \directn = 0; + }; + }; + \asumyft = \yt - \yf; + if \asumyft>0 then {let \fdirectn = north;} else { + if \asumyft<0 then {let \fdirectn = south;} else { + let \fdirectn = 0; + }; + }; + } + +\ifnum#6=0 +\draw[\linecolor, \linepathtype] ($(#2.\fdirectn) + (\dxpos,0)$) |- node[near end, above] {\textsize{#1}} ($(#3.\directn) + (0,\dypos)$); +\else +\ifnum#6=1 +\draw[\linecolor, \linepathtype] ($(#2.\fdirectn) + (\dxpos,0)$) |- node[near end, above right] {\textsize{#1}} ($(#3.\directn) + (0,\dypos)$); +\else +\ifnum#6=2 +\draw[\linecolor, \linepathtype] ($(#2.\fdirectn) + (\dxpos,0)$) |- node[near end, below] {\textsize{#1}} ($(#3.\directn) + (0,\dypos)$); +\else +\ifnum#6=3 +\draw[\linecolor, \linepathtype] ($(#2.\fdirectn) + (\dxpos,0)$) |- node[near end, below right] {\textsize{#1}} ($(#3.\directn) + (0,\dypos)$); +\else +\ifnum#6=4 +\draw[\linecolor, \linepathtype] ($(#2.\fdirectn) + (\dxpos,0)$) |- node[midway, above] {\textsize{#1}} ($(#3.\directn) + (0,\dypos)$); +\else +\ifnum#6=5 +\draw[\linecolor, \linepathtype] ($(#2.\fdirectn) + (\dxpos,0)$) |- node[midway, above right] {\textsize{#1}} ($(#3.\directn) + (0,\dypos)$); +\else +\ifnum#6=6 +\draw[\linecolor, \linepathtype] ($(#2.\fdirectn) + (\dxpos,0)$) |- node[midway, above left] {\textsize{#1}} ($(#3.\directn) + (0,\dypos)$); +\else +\ifnum#6=7 +\draw[\linecolor, \linepathtype] ($(#2.\fdirectn) + (\dxpos,0)$) |- node[midway, below right] {\textsize{#1}} ($(#3.\directn) + (0,\dypos)$); +\else +\ifnum#6=8 +\draw[\linecolor, \linepathtype] ($(#2.\fdirectn) + (\dxpos,0)$) |- node[midway, below left] {\textsize{#1}} ($(#3.\directn) + (0,\dypos)$); +\else +\draw[\linecolor, \linepathtype] ($(#2.\fdirectn) + (\dxpos,0)$) |- node[auto, above] {\textsize{#1}} ($(#3.\directn) + (0,\dypos)$); +\fi +\fi +\fi +\fi +\fi +\fi +\fi +\fi +\fi + +} + +%% vector variant +\newcommand{\kVecLinknVH}[6][]{ % TODO:extend changes made here to its other VH variants + + \def\dypos{#4}; + \def\dxpos{#5}; + \ifx\dypos\empty + \def\dypos{0}; + \else + \fi + \ifx\dxpos\empty + \def\dxpos{0}; + \else + \fi + + \coordinate (fromn) at (#2);% from node coordinate + \coordinate (ton) at (#3);% to node coordinate + + + % extract x and y coordinates + \newdimen\xf;% + \newdimen\yf;% + \path (fromn); \pgfgetlastxy{\xf}{\yf}; + \newdimen\xt;% + \newdimen\yt;% + \path (ton); \pgfgetlastxy{\xt}{\yt}; + + \newdimen\asumxft; + + \tikzmath{ + \asumxft = \xt - \xf; + if \asumxft>0 then {let \directn = west;} else { + if \asumxft<0 then {let \directn = east;} else { + let \directn = 0; + }; + }; + \asumyft = \yt - \yf; + if \asumyft>0 then {let \fdirectn = north;} else { + if \asumyft<0 then {let \fdirectn = south;} else { + let \fdirectn = 0; + }; + }; + } + + +\ifnum#6=0 +\draw[\linecolor, veclinetype] ($(#2.\fdirectn) + (\dxpos,0)$) |- node[near end, above] {\textsize{#1}} ($(#3.\directn) + (0,\dypos)$); +\else +\ifnum#6=1 +\draw[\linecolor, veclinetype] ($(#2.\fdirectn) + (\dxpos,0)$) |- node[near end, above right] {\textsize{#1}} ($(#3.\directn) + (0,\dypos)$); +\else +\ifnum#6=2 +\draw[\linecolor, veclinetype] ($(#2.\fdirectn) + (\dxpos,0)$) |- node[near end, below] {\textsize{#1}} ($(#3.\directn) + (0,\dypos)$); +\else +\ifnum#6=3 +\draw[\linecolor, veclinetype] ($(#2.\fdirectn) + (\dxpos,0)$) |- node[near end, below right] {\textsize{#1}} ($(#3.\directn) + (0,\dypos)$); +\else +\ifnum#6=4 +\draw[\linecolor, veclinetype] ($(#2.\fdirectn) + (\dxpos,0)$) |- node[midway, above] {\textsize{#1}} ($(#3.\directn) + (0,\dypos)$); +\else +\ifnum#6=5 +\draw[\linecolor, veclinetype] ($(#2.\fdirectn) + (\dxpos,0)$) |- node[midway, above right] {\textsize{#1}} ($(#3.\directn) + (0,\dypos)$); +\else +\ifnum#6=6 +\draw[\linecolor, veclinetype] ($(#2.\fdirectn) + (\dxpos,0)$) |- node[midway, above left] {\textsize{#1}} ($(#3.\directn) + (0,\dypos)$); +\else +\ifnum#6=7 +\draw[\linecolor, veclinetype] ($(#2.\fdirectn) + (\dxpos,0)$) |- node[midway, below right] {\textsize{#1}} ($(#3.\directn) + (0,\dypos)$); +\else +\ifnum#6=8 +\draw[\linecolor, veclinetype] ($(#2.\fdirectn) + (\dxpos,0)$) |- node[midway, below left] {\textsize{#1}} ($(#3.\directn) + (0,\dypos)$); +\else +\draw[\linecolor, veclinetype] ($(#2.\fdirectn) + (\dxpos,0)$) |- node[auto, above] {\textsize{#1}} ($(#3.\directn) + (0,\dypos)$); +\fi +\fi +\fi +\fi +\fi +\fi +\fi +\fi +\fi + +} + + +% Link Full Feedback/FeedForward Horizontal(Right or Left) to Vertical(Up or Down) +% to Horizontal(Right or Left) +%% Usage: [optional link scale]{link label}{from node}{to node}{from node direction shift}{to node direction shift} \newcommand{\kLinkHVHRight}[6][]{ \def\dxr{#1}; @@ -775,6 +2232,17 @@ mark=at position 0.5 with {\arrow{Latex[]}}},postaction={decorate}}} \coordinate (tmp) at ($(#3.east) + (0,#5) + (0.33+\dxr,0)$); \draw[-latex, \linecolor, \linepathtype] (tmplr) -| (tmp) node[at end, below right] {\textsize{#2}} |-($(#4.east) + (0,#6)$); } +% vector +\newcommand{\kVLinkHVHRight}[6][]{ + \def\dxr{#1}; + \ifx\dxr\empty + \def\dxr{0}; + \else + \fi + \coordinate (tmplr) at ($(#3.east) + (0,#5)$); + \coordinate (tmp) at ($(#3.east) + (0,#5) + (0.33+\dxr,0)$); + \draw[-latex, \linecolor, veclinetype] (tmplr) -| (tmp) node[at end, below right] {\textsize{#2}} |-($(#4.east) + (0,#6)$); +} \newcommand{\kLinkHVHLeft}[6][]{ \def\dxl{#1}; \ifx\dxl\empty @@ -785,7 +2253,8 @@ mark=at position 0.5 with {\arrow{Latex[]}}},postaction={decorate}}} \coordinate (tmp) at ($(#3.west) + (0,#5) + (-0.33-\dxl,0)$); \draw[-latex, \linecolor, \linepathtype] (tmpll) -| (tmp) node[at end, above left] {\textsize{#2}} |- ($(#4.west) + (0,#6)$); } -% Link Full Feedback/FeedForward Horizontal(Right or Left) Vertical(Up or Down) + +% Link Full Feedback/FeedForward Vertical(Up or Down) to Horizontal(Right or Left) to Vertical(Up or Down) %% Usage: {optional link shift}{unity link label}{from node}{to node}{from node direction shift}{to node direction shift} % Above @@ -814,6 +2283,7 @@ mark=at position 0.5 with {\arrow{Latex[]}}},postaction={decorate}}} \coordinate [label=\tiny{#2}] (tmp) at ($ (\xcr,\yca) + (0,1cm-\dxb) $); \draw [-latex,\linecolor, \linepathtype] (tmpb) |- (tmp) -| ($(#4.north) + (#6,0)$); } + % Below \newcommand{\kLinkVHHVBelow}[6][]{ \def\dxb{#1}; @@ -842,6 +2312,62 @@ mark=at position 0.5 with {\arrow{Latex[]}}},postaction={decorate}}} \draw [-latex,\linecolor, \linepathtype] (tmpb) |- (tmp) -| ($(#4.south) + (#6,0)$); } +% No directions +% Above +\newcommand{\kLinknVHHVAbove}[6][]{ + \def\dxb{#1}; + \ifx\dxb\empty + \def\dxb{0}; + \else + \fi + \coordinate (tmpb) at ($(#3.north) + (#5,0)$); + \coordinate (tmpc) at ($(#4.north) + (#6,0)$); + + \newdimen\xca; + \newdimen\yca; + \path (tmpb); \pgfgetlastxy{\xca}{\yca}; + \newdimen\xcb; + \newdimen\ycb; + \path (tmpc); \pgfgetlastxy{\xcb}{\ycb}; + + \newdimen\xcr; + + \tikzmath{ + \xcr = 0.5 * (\xca+\xcb); + } + + \coordinate [label=\tiny{#2}] (tmp) at ($ (\xcr,\yca) + (0,1cm-\dxb) $); + \draw [\linecolor, \linepathtype] (tmpb) |- (tmp) -| ($(#4.north) + (#6,0)$); +} + +% Below +\newcommand{\kLinknVHHVBelow}[6][]{ + \def\dxb{#1}; + + \ifx\dxb\empty + \def\dxb{0}; + \else + \fi + \coordinate (tmpb) at ($(#3.south) + (#5,0)$); + \coordinate (tmpc) at ($(#4.south) + (#6,0)$); + + \newdimen\xca; + \newdimen\yca; + \path (tmpb); \pgfgetlastxy{\xca}{\yca}; + \newdimen\xcb; + \newdimen\ycb; + \path (tmpc); \pgfgetlastxy{\xcb}{\ycb}; + + \newdimen\xcr; + + \tikzmath{ + \xcr = 0.5 * (\xca+\xcb); + } + + \coordinate [label=\tiny{#2}] (tmp) at ($ (\xcr,\yca) + (0,-1cm-\dxb) $); + \draw [\linecolor, \linepathtype] (tmpb) |- (tmp) -| ($(#4.south) + (#6,0)$); +} + % Link Feedback/FeedForward with a TF Block in between %% Usage: {signal label before tf}{signal label after tf}{from node}{tf node}{to node}{from node direction shift}{tf direction shift}{to node direction shift} \newcommand{\kLinkVHTFHVBelow}[8]{ @@ -896,17 +2422,28 @@ mark=at position 0.5 with {\arrow{Latex[]}}},postaction={decorate}}} } -% Link Inputs Invisible Node +% Link Inputs and Outputs Invisible Node %% Usage: [optional distance shift]{from node label}{to current node label}{in label}{direction}{direction shift} +% Marked Link Inputs and Outputs Visible Node +%% Usage: [optional distance shift]{from node label}{to current node label}{in label}{direction}{direction shift}{label position} + +% Inputs \newcommand{\kInRight}[5][]{ \def\dxinr{#1}; \ifx\dxinr\empty \def\dxinr{0}; \else \fi + + % to add to all + \def\dypos{#5}; + \ifx\dypos\empty + \def\dypos{0}; + \else + \fi - \coordinate (tmpn) at ($(#2.east) + (0,#5)$); + \coordinate (tmpn) at ($(#2.east) + (0,\dypos)$); \node[right of= tmpn, node distance= 1.2cm + \dxinr, font=\textsize] (#3) {\color{\colortext}#4}; @@ -920,7 +2457,14 @@ mark=at position 0.5 with {\arrow{Latex[]}}},postaction={decorate}}} \else \fi - \coordinate (tmpn) at ($(#2.west) + (0,#5)$); + % to add to all + \def\dypos{#5}; + \ifx\dypos\empty + \def\dypos{0}; + \else + \fi + + \coordinate (tmpn) at ($(#2.west) + (0,\dypos)$); \node[left of= tmpn, node distance= 1.2cm + \dxinr, font=\textsize] (#3) {\color{\colortext}#4}; @@ -934,7 +2478,13 @@ mark=at position 0.5 with {\arrow{Latex[]}}},postaction={decorate}}} \else \fi - \coordinate (tmpn) at ($(#2.north) + (#5,0)$); + \def\dxpos{#5}; + \ifx\dxpos\empty + \def\dxpos{0}; + \else + \fi + + \coordinate (tmpn) at ($(#2.north) + (\dxpos,0)$); \node[above of= tmpn, node distance= 1.2cm + \dxina, font=\textsize] (#3) {\color{\colortext}#4}; @@ -942,22 +2492,231 @@ mark=at position 0.5 with {\arrow{Latex[]}}},postaction={decorate}}} } \newcommand{\kInDown}[5][]{ - \def\dxinr{#1}; - \ifx\dxinr\empty - \def\dxinr{0}; + \def\dxina{#1}; + \ifx\dxina\empty + \def\dxina{0}; \else \fi + + \def\dxpos{#5}; + \ifx\dxpos\empty + \def\dxpos{0}; + \else + \fi + + \coordinate (tmpn) at ($(#2.south) + (\dxpos,0)$); - \coordinate (tmpn) at ($(#2.south) + (#5,0)$); - - \node[below of= tmpn, node distance= 1.2cm + \dxinr, font=\textsize] (#3) {\color{\colortext}#4}; + \node[below of= tmpn, node distance= 1.2cm + \dxina, font=\textsize] (#3) {\color{\colortext}#4}; \draw[-latex, \linecolor, \linepathtype] (#3)--(tmpn); } - -% Link Outputs Invisible Node -%% Usage: [optional distance shift]{from node label}{to current node label}{out signal label}{direction shift} +% Marked (visible node) Link Inputs +\newcommand{\kInLeftM}[6][]{ + \def\dxinr{#1}; + \ifx\dxinr\empty + \def\dxinr{0}; + \else + \fi + + % to add to all + \def\dypos{#5}; + \ifx\dypos\empty + \def\dypos{0}; + \else + \fi + + \coordinate (tmpn) at ($(#2.west) + (0,\dypos)$); + + \ifnum#6=0 + \node[fill=\linecolor, circle, inner sep=0pt, outer sep=0pt, minimum size=0.3em, left of= tmpn, node distance= 1.2cm + \dxinr, font=\textsize] (#3) [label=above:\color{\colortext}{#4}] {}; + \else + \ifnum#6=1 + \node[fill=\linecolor, circle, inner sep=0pt, outer sep=0pt, minimum size=0.3em, left of= tmpn, node distance= 1.2cm + \dxinr, font=\textsize] (#3) [label=above left:\color{\colortext}{#4}] {}; + \else + \ifnum#6=2 + \node[fill=\linecolor, circle, inner sep=0pt, outer sep=0pt, minimum size=0.3em, left of= tmpn, node distance= 1.2cm + \dxinr, font=\textsize] (#3) [label=above right:\color{\colortext}{#4}] {}; + % + \else + \ifnum#6=3 + \node[fill=\linecolor, circle, inner sep=0pt, outer sep=0pt, minimum size=0.3em, left of= tmpn, node distance= 1.2cm + \dxinr, font=\textsize] (#3) [label=below:\color{\colortext}{#4}] {}; + \else + \ifnum#6=4 + \node[fill=\linecolor, circle, inner sep=0pt, outer sep=0pt, minimum size=0.3em, left of= tmpn, node distance= 1.2cm + \dxinr, font=\textsize] (#3) [label=below left:\color{\colortext}{#4}] {}; + \else + \ifnum#6=5 + \node[fill=\linecolor, circle, inner sep=0pt, outer sep=0pt, minimum size=0.3em, left of= tmpn, node distance= 1.2cm + \dxinr, font=\textsize] (#3) [label=below right:\color{\colortext}{#4}] {}; + % + \else + \ifnum#6=6 + \node[fill=\linecolor, circle, inner sep=0pt, outer sep=0pt, minimum size=0.3em, left of= tmpn, node distance= 1.2cm + \dxinr, font=\textsize] (#3) [label=left:\color{\colortext}{#4}] {}; + \else + \node[fill=\linecolor, circle, inner sep=0pt, outer sep=0pt, minimum size=0.3em, left of= tmpn, node distance= 1.2cm + \dxinr, font=\textsize] (#3) [label=above:\color{\colortext}{#4}] {}; + \fi + \fi + \fi + \fi + \fi + \fi + \fi + % + \draw[-latex, \linecolor, \linepathtype] (#3) -- (tmpn); +} + +\newcommand{\kInRightM}[6][]{ + \def\dxinr{#1}; + \ifx\dxinr\empty + \def\dxinr{0}; + \else + \fi + + % to add to all + \def\dypos{#5}; + \ifx\dypos\empty + \def\dypos{0}; + \else + \fi + + \coordinate (tmpn) at ($(#2.east) + (0,\dypos)$); + + \ifnum#6=0 + \node[fill=\linecolor, circle, inner sep=0pt, outer sep=0pt, minimum size=0.3em, right of= tmpn, node distance= 1.2cm + \dxinr, font=\textsize] (#3) [label=above:\color{\colortext}{#4}] {}; + \else + \ifnum#6=1 + \node[fill=\linecolor, circle, inner sep=0pt, outer sep=0pt, minimum size=0.3em, right of= tmpn, node distance= 1.2cm + \dxinr, font=\textsize] (#3) [label=above left:\color{\colortext}{#4}] {}; + \else + \ifnum#6=2 + \node[fill=\linecolor, circle, inner sep=0pt, outer sep=0pt, minimum size=0.3em, right of= tmpn, node distance= 1.2cm + \dxinr, font=\textsize] (#3) [label=above right:\color{\colortext}{#4}] {}; + % + \else + \ifnum#6=3 + \node[fill=\linecolor, circle, inner sep=0pt, outer sep=0pt, minimum size=0.3em, right of= tmpn, node distance= 1.2cm + \dxinr, font=\textsize] (#3) [label=below:\color{\colortext}{#4}] {}; + \else + \ifnum#6=4 + \node[fill=\linecolor, circle, inner sep=0pt, outer sep=0pt, minimum size=0.3em, right of= tmpn, node distance= 1.2cm + \dxinr, font=\textsize] (#3) [label=below left:\color{\colortext}{#4}] {}; + \else + \ifnum#6=5 + \node[fill=\linecolor, circle, inner sep=0pt, outer sep=0pt, minimum size=0.3em, right of= tmpn, node distance= 1.2cm + \dxinr, font=\textsize] (#3) [label=below right:\color{\colortext}{#4}] {}; + % + \else + \ifnum#6=6 + \node[fill=\linecolor, circle, inner sep=0pt, outer sep=0pt, minimum size=0.3em, right of= tmpn, node distance= 1.2cm + \dxinr, font=\textsize] (#3) [label=left:\color{\colortext}{#4}] {}; + \else + \node[fill=\linecolor, circle, inner sep=0pt, outer sep=0pt, minimum size=0.3em, right of= tmpn, node distance= 1.2cm + \dxinr, font=\textsize] (#3) [label=above:\color{\colortext}{#4}] {}; + \fi + \fi + \fi + \fi + \fi + \fi + \fi + % + \draw[-latex, \linecolor, \linepathtype] (#3) -- (tmpn); +} + +\newcommand{\kInUpM}[6][]{ + \def\dxina{#1}; + \ifx\dxina\empty + \def\dxina{0}; + \else + \fi + + % to add to all + \def\dxpos{#5}; + \ifx\dxpos\empty + \def\dxpos{0}; + \else + \fi + + \coordinate (tmpn) at ($(#2.north) + (\dxpos,0)$); + + \ifnum#6=0 + \node[fill=\linecolor, circle, inner sep=0pt, outer sep=0pt, minimum size=0.3em, above of= tmpn, node distance= 1.2cm + \dxina, font=\textsize, label=above:\color{\colortext}{#4}] (#3) {}; + \else + \ifnum#6=1 + \node[fill=\linecolor, circle, inner sep=0pt, outer sep=0pt, minimum size=0.3em, above of= tmpn, node distance= 1.2cm + \dxinr, font=\textsize] (#3) [label=above left:\color{\colortext}{#4}] {}; + \else + \ifnum#6=2 + \node[fill=\linecolor, circle, inner sep=0pt, outer sep=0pt, minimum size=0.3em, above of= tmpn, node distance= 1.2cm + \dxinr, font=\textsize] (#3) [label=above right:\color{\colortext}{#4}] {}; + % + \else + \ifnum#6=3 + \node[fill=\linecolor, circle, inner sep=0pt, outer sep=0pt, minimum size=0.3em, above of= tmpn, node distance= 1.2cm + \dxinr, font=\textsize] (#3) [label=below:\color{\colortext}{#4}] {}; + \else + \ifnum#6=4 + \node[fill=\linecolor, circle, inner sep=0pt, outer sep=0pt, minimum size=0.3em, above of= tmpn, node distance= 1.2cm + \dxinr, font=\textsize] (#3) [label=below left:\color{\colortext}{#4}] {}; + \else + \ifnum#6=5 + \node[fill=\linecolor, circle, inner sep=0pt, outer sep=0pt, minimum size=0.3em, above of= tmpn, node distance= 1.2cm + \dxinr, font=\textsize] (#3) [label=below right:\color{\colortext}{#4}] {}; + % + \else + \ifnum#6=6 + \node[fill=\linecolor, circle, inner sep=0pt, outer sep=0pt, minimum size=0.3em, above of= tmpn, node distance= 1.2cm + \dxinr, font=\textsize] (#3) [label=left:\color{\colortext}{#4}] {}; + \else + \node[fill=\linecolor, circle, inner sep=0pt, outer sep=0pt, minimum size=0.3em, above of= tmpn, node distance= 1.2cm + \dxinr, font=\textsize] (#3) [label=above:\color{\colortext}{#4}] {}; + \fi + \fi + \fi + \fi + \fi + \fi + \fi + % + \draw[-latex, \linecolor, \linepathtype] (#3) -- (tmpn); +} + +\newcommand{\kInDownM}[6][]{ + \def\dxina{#1}; + \ifx\dxina\empty + \def\dxina{0}; + \else + \fi + + % to add to all + \def\dxpos{#5}; + \ifx\dxpos\empty + \def\dxpos{0}; + \else + \fi + + \coordinate (tmpn) at ($(#2.south) + (\dxpos,0)$); + + \ifnum#6=0 + \node[fill=\linecolor, circle, inner sep=0pt, outer sep=0pt, minimum size=0.3em, below of= tmpn, node distance= 1.2cm + \dxina, font=\textsize] (#3) [label=above:\color{\colortext}{#4}] {}; + \else + \ifnum#6=1 + \node[fill=\linecolor, circle, inner sep=0pt, outer sep=0pt, minimum size=0.3em, below of= tmpn, node distance= 1.2cm + \dxinr, font=\textsize] (#3) [label=above left:\color{\colortext}{#4}] {}; + \else + \ifnum#6=2 + \node[fill=\linecolor, circle, inner sep=0pt, outer sep=0pt, minimum size=0.3em, below of= tmpn, node distance= 1.2cm + \dxinr, font=\textsize] (#3) [label=above right:\color{\colortext}{#4}] {}; + % + \else + \ifnum#6=3 + \node[fill=\linecolor, circle, inner sep=0pt, outer sep=0pt, minimum size=0.3em, below of= tmpn, node distance= 1.2cm + \dxinr, font=\textsize] (#3) [label=below:\color{\colortext}{#4}] {}; + \else + \ifnum#6=4 + \node[fill=\linecolor, circle, inner sep=0pt, outer sep=0pt, minimum size=0.3em, below of= tmpn, node distance= 1.2cm + \dxinr, font=\textsize] (#3) [label=below left:\color{\colortext}{#4}] {}; + \else + \ifnum#6=5 + \node[fill=\linecolor, circle, inner sep=0pt, outer sep=0pt, minimum size=0.3em, below of= tmpn, node distance= 1.2cm + \dxinr, font=\textsize] (#3) [label=below right:\color{\colortext}{#4}] {}; + % + \else + \ifnum#6=6 + \node[fill=\linecolor, circle, inner sep=0pt, outer sep=0pt, minimum size=0.3em, below of= tmpn, node distance= 1.2cm + \dxinr, font=\textsize] (#3) [label=left:\color{\colortext}{#4}] {}; + \else + \node[fill=\linecolor, circle, inner sep=0pt, outer sep=0pt, minimum size=0.3em, below of= tmpn, node distance= 1.2cm + \dxinr, font=\textsize] (#3) [label=above:\color{\colortext}{#4}] {}; + \fi + \fi + \fi + \fi + \fi + \fi + \fi + % + \draw[-latex, \linecolor, \linepathtype] (#3) -- (tmpn); +} + +% Outputs \newcommand{\kOutRight}[5][]{ \def\dxoutr{#1}; \ifx\dxoutr\empty @@ -1014,69 +2773,403 @@ mark=at position 0.5 with {\arrow{Latex[]}}},postaction={decorate}}} \draw[-latex, \linecolor, \linepathtype] (tmpo)--(#3); } + +% Marked (visible node) Link Outputs (Redundant): To Remove this +\newcommand{\kOutLeftM}[6][]{ + \def\dxinr{#1}; + \ifx\dxinr\empty + \def\dxinr{0}; + \else + \fi + + % to add to all + \def\dypos{#5}; + \ifx\dypos\empty + \def\dypos{0}; + \else + \fi + + \coordinate (tmpn) at ($(#2.west) + (0,\dypos)$); + + \ifnum#6=0 + \node[fill=\linecolor, circle, inner sep=0pt, outer sep=0pt, minimum size=0.3em, left of= tmpn, node distance= 1.2cm + \dxinr, font=\textsize] (#3) [label=above:\color{\colortext}{#4}] {}; + \else + \ifnum#6=1 + \node[fill=\linecolor, circle, inner sep=0pt, outer sep=0pt, minimum size=0.3em, left of= tmpn, node distance= 1.2cm + \dxinr, font=\textsize] (#3) [label=above left:\color{\colortext}{#4}] {}; + \else + \ifnum#6=2 + \node[fill=\linecolor, circle, inner sep=0pt, outer sep=0pt, minimum size=0.3em, left of= tmpn, node distance= 1.2cm + \dxinr, font=\textsize] (#3) [label=above right:\color{\colortext}{#4}] {}; + % + \else + \ifnum#6=3 + \node[fill=\linecolor, circle, inner sep=0pt, outer sep=0pt, minimum size=0.3em, left of= tmpn, node distance= 1.2cm + \dxinr, font=\textsize] (#3) [label=below:\color{\colortext}{#4}] {}; + \else + \ifnum#6=4 + \node[fill=\linecolor, circle, inner sep=0pt, outer sep=0pt, minimum size=0.3em, left of= tmpn, node distance= 1.2cm + \dxinr, font=\textsize] (#3) [label=below left:\color{\colortext}{#4}] {}; + \else + \ifnum#6=5 + \node[fill=\linecolor, circle, inner sep=0pt, outer sep=0pt, minimum size=0.3em, left of= tmpn, node distance= 1.2cm + \dxinr, font=\textsize] (#3) [label=below right:\color{\colortext}{#4}] {}; + % + \else + \ifnum#6=6 + \node[fill=\linecolor, circle, inner sep=0pt, outer sep=0pt, minimum size=0.3em, left of= tmpn, node distance= 1.2cm + \dxinr, font=\textsize] (#3) [label=left:\color{\colortext}{#4}] {}; + \else + \node[fill=\linecolor, circle, inner sep=0pt, outer sep=0pt, minimum size=0.3em, left of= tmpn, node distance= 1.2cm + \dxinr, font=\textsize] (#3) [label=above:\color{\colortext}{#4}] {}; + \fi + \fi + \fi + \fi + \fi + \fi + \fi + % + \draw[-latex, \linecolor, \linepathtype] (tmpn) -- (#3); +} + +\newcommand{\kOutRightM}[6][]{ + \def\dxinr{#1}; + \ifx\dxinr\empty + \def\dxinr{0}; + \else + \fi + + % to add to all + \def\dypos{#5}; + \ifx\dypos\empty + \def\dypos{0}; + \else + \fi + + \coordinate (tmpn) at ($(#2.east) + (0,\dypos)$); + + \ifnum#6=0 + \node[fill=\linecolor, circle, inner sep=0pt, outer sep=0pt, minimum size=0.3em, right of= tmpn, node distance= 1.2cm + \dxinr, font=\textsize] (#3) [label=above:\color{\colortext}{#4}] {}; + \else + \ifnum#6=1 + \node[fill=\linecolor, circle, inner sep=0pt, outer sep=0pt, minimum size=0.3em, right of= tmpn, node distance= 1.2cm + \dxinr, font=\textsize] (#3) [label=above left:\color{\colortext}{#4}] {}; + \else + \ifnum#6=2 + \node[fill=\linecolor, circle, inner sep=0pt, outer sep=0pt, minimum size=0.3em, right of= tmpn, node distance= 1.2cm + \dxinr, font=\textsize] (#3) [label=above right:\color{\colortext}{#4}] {}; + % + \else + \ifnum#6=3 + \node[fill=\linecolor, circle, inner sep=0pt, outer sep=0pt, minimum size=0.3em, right of= tmpn, node distance= 1.2cm + \dxinr, font=\textsize] (#3) [label=below:\color{\colortext}{#4}] {}; + \else + \ifnum#6=4 + \node[fill=\linecolor, circle, inner sep=0pt, outer sep=0pt, minimum size=0.3em, right of= tmpn, node distance= 1.2cm + \dxinr, font=\textsize] (#3) [label=below left:\color{\colortext}{#4}] {}; + \else + \ifnum#6=5 + \node[fill=\linecolor, circle, inner sep=0pt, outer sep=0pt, minimum size=0.3em, right of= tmpn, node distance= 1.2cm + \dxinr, font=\textsize] (#3) [label=below right:\color{\colortext}{#4}] {}; + % + \else + \ifnum#6=6 + \node[fill=\linecolor, circle, inner sep=0pt, outer sep=0pt, minimum size=0.3em, right of= tmpn, node distance= 1.2cm + \dxinr, font=\textsize] (#3) [label=left:\color{\colortext}{#4}] {}; + \else + \node[fill=\linecolor, circle, inner sep=0pt, outer sep=0pt, minimum size=0.3em, right of= tmpn, node distance= 1.2cm + \dxinr, font=\textsize] (#3) [label=above:\color{\colortext}{#4}] {}; + \fi + \fi + \fi + \fi + \fi + \fi + \fi + % + \draw[-latex, \linecolor, \linepathtype] (tmpn) -- (#3); +} + +\newcommand{\kOutUpM}[6][]{ + \def\dxina{#1}; + \ifx\dxina\empty + \def\dxina{0}; + \else + \fi + + % to add to all + \def\dxpos{#5}; + \ifx\dxpos\empty + \def\dxpos{0}; + \else + \fi + + \coordinate (tmpn) at ($(#2.north) + (\dxpos,0)$); + + \ifnum#6=0 + \node[fill=\linecolor, circle, inner sep=0pt, outer sep=0pt, minimum size=0.3em, above of= tmpn, node distance= 1.2cm + \dxina, font=\textsize] (#3) [label=above:\color{\colortext}{#4}] {}; + \else + \ifnum#6=1 + \node[fill=\linecolor, circle, inner sep=0pt, outer sep=0pt, minimum size=0.3em, above of= tmpn, node distance= 1.2cm + \dxinr, font=\textsize] (#3) [label=above left:\color{\colortext}{#4}] {}; + \else + \ifnum#6=2 + \node[fill=\linecolor, circle, inner sep=0pt, outer sep=0pt, minimum size=0.3em, above of= tmpn, node distance= 1.2cm + \dxinr, font=\textsize] (#3) [label=above right:\color{\colortext}{#4}] {}; + % + \else + \ifnum#6=3 + \node[fill=\linecolor, circle, inner sep=0pt, outer sep=0pt, minimum size=0.3em, above of= tmpn, node distance= 1.2cm + \dxinr, font=\textsize] (#3) [label=below:\color{\colortext}{#4}] {}; + \else + \ifnum#6=4 + \node[fill=\linecolor, circle, inner sep=0pt, outer sep=0pt, minimum size=0.3em, above of= tmpn, node distance= 1.2cm + \dxinr, font=\textsize] (#3) [label=below left:\color{\colortext}{#4}] {}; + \else + \ifnum#6=5 + \node[fill=\linecolor, circle, inner sep=0pt, outer sep=0pt, minimum size=0.3em, above of= tmpn, node distance= 1.2cm + \dxinr, font=\textsize] (#3) [label=below right:\color{\colortext}{#4}] {}; + % + \else + \ifnum#6=6 + \node[fill=\linecolor, circle, inner sep=0pt, outer sep=0pt, minimum size=0.3em, above of= tmpn, node distance= 1.2cm + \dxinr, font=\textsize] (#3) [label=left:\color{\colortext}{#4}] {}; + \else + \node[fill=\linecolor, circle, inner sep=0pt, outer sep=0pt, minimum size=0.3em, above of= tmpn, node distance= 1.2cm + \dxinr, font=\textsize] (#3) [label=above:\color{\colortext}{#4}] {}; + \fi + \fi + \fi + \fi + \fi + \fi + \fi + % + \draw[-latex, \linecolor, \linepathtype] (tmpn) -- (#3); +} + +\newcommand{\kOutDownM}[6][]{ + \def\dxina{#1}; + \ifx\dxina\empty + \def\dxina{0}; + \else + \fi + + % to add to all + \def\dxpos{#5}; + \ifx\dxpos\empty + \def\dxpos{0}; + \else + \fi + + \coordinate (tmpn) at ($(#2.south) + (\dxpos,0)$); + + \ifnum#6=0 + \node[fill=\linecolor, circle, inner sep=0pt, outer sep=0pt, minimum size=0.3em, below of= tmpn, node distance= 1.2cm + \dxina, font=\textsize] (#3) [label=above:\color{\colortext}{#4}] {}; + \else + \ifnum#6=1 + \node[fill=\linecolor, circle, inner sep=0pt, outer sep=0pt, minimum size=0.3em, below of= tmpn, node distance= 1.2cm + \dxinr, font=\textsize] (#3) [label=above left:\color{\colortext}{#4}] {}; + \else + \ifnum#6=2 + \node[fill=\linecolor, circle, inner sep=0pt, outer sep=0pt, minimum size=0.3em, below of= tmpn, node distance= 1.2cm + \dxinr, font=\textsize] (#3) [label=above right:\color{\colortext}{#4}] {}; + % + \else + \ifnum#6=3 + \node[fill=\linecolor, circle, inner sep=0pt, outer sep=0pt, minimum size=0.3em, below of= tmpn, node distance= 1.2cm + \dxinr, font=\textsize] (#3) [label=below:\color{\colortext}{#4}] {}; + \else + \ifnum#6=4 + \node[fill=\linecolor, circle, inner sep=0pt, outer sep=0pt, minimum size=0.3em, below of= tmpn, node distance= 1.2cm + \dxinr, font=\textsize] (#3) [label=below left:\color{\colortext}{#4}] {}; + \else + \ifnum#6=5 + \node[fill=\linecolor, circle, inner sep=0pt, outer sep=0pt, minimum size=0.3em, below of= tmpn, node distance= 1.2cm + \dxinr, font=\textsize] (#3) [label=below right:\color{\colortext}{#4}] {}; + % + \else + \ifnum#6=6 + \node[fill=\linecolor, circle, inner sep=0pt, outer sep=0pt, minimum size=0.3em, below of= tmpn, node distance= 1.2cm + \dxinr, font=\textsize] (#3) [label=left:\color{\colortext}{#4}] {}; + \else + \node[fill=\linecolor, circle, inner sep=0pt, outer sep=0pt, minimum size=0.3em, below of= tmpn, node distance= 1.2cm + \dxinr, font=\textsize] (#3) [label=above:\color{\colortext}{#4}] {}; + \fi + \fi + \fi + \fi + \fi + \fi + \fi + % + \draw[-latex, \linecolor, \linepathtype] (tmpn) -- (#3); +} + + + + + +%% Vector variants +\newcommand{\kVecInRight}[5][]{ + \def\dxinr{#1}; + \ifx\dxinr\empty + \def\dxinr{0}; + \else + \fi + + \coordinate (tmpn) at ($(#2.east) + (0,#5)$); + + \node[right of= tmpn, node distance= 1.2cm + \dxinr, font=\textsize] (#3) {\color{\colortext}#4}; + + \draw[-latex, \linecolor, veclinetype] (#3)--(tmpn); +} + +\newcommand{\kVecInLeft}[5][]{ + \def\dxinr{#1}; + \ifx\dxinr\empty + \def\dxinr{0}; + \else + \fi + + % to add to all + \def\dypos{#5}; + \ifx\dypos\empty + \def\dypos{0}; + \else + \fi + + \coordinate (tmpn) at ($(#2.west) + (0,\dypos)$); + + \node[left of= tmpn, node distance= 1.2cm + \dxinr, font=\textsize] (#3) {\color{\colortext}#4}; + + \draw[-latex, \linecolor, veclinetype] (#3)--(tmpn); +} + +\newcommand{\kVecInUp}[5][]{ + \def\dxina{#1}; + \ifx\dxina\empty + \def\dxina{0}; + \else + \fi + + \coordinate (tmpn) at ($(#2.north) + (#5,0)$); + + \node[above of= tmpn, node distance= 1.2cm + \dxina, font=\textsize] (#3) {\color{\colortext}#4}; + + \draw[-latex, \linecolor, veclinetype] (#3)--(tmpn); +} + +\newcommand{\kVecInDown}[5][]{ + \def\dxinr{#1}; + \ifx\dxinr\empty + \def\dxinr{0}; + \else + \fi + + \coordinate (tmpn) at ($(#2.south) + (#5,0)$); + + \node[below of= tmpn, node distance= 1.2cm + \dxinr, font=\textsize] (#3) {\color{\colortext}#4}; + + \draw[-latex, \linecolor, veclinetype] (#3)--(tmpn); +} + + +% Link Outputs Invisible Node +%% Usage: [optional distance shift]{from node label}{to current node label}{out signal label}{direction shift} +\newcommand{\kVecOutRight}[5][]{ + \def\dxoutr{#1}; + \ifx\dxoutr\empty + \def\dxoutr{0}; + \else + \fi + + \coordinate (tmpo) at ($(#2.east) + (0,#5)$); + + \node[right of= tmpo, node distance= 1.2cm + \dxoutr, font=\textsize] (#3) {\color{\colortext}#4}; + + \draw[-latex, \linecolor, veclinetype] (tmpo)--(#3); +} + +\newcommand{\kVecOutLeft}[5][]{ + \def\dxoutr{#1}; + \ifx\dxoutr\empty + \def\dxoutr{0}; + \else + \fi + + \coordinate (tmpo) at ($(#2.west) + (0,#5)$); + + \node[left of= tmpo, node distance= 1.2cm + \dxoutr, font=\textsize] (#3) {\color{\colortext}#4}; + + \draw[-latex, \linecolor, veclinetype] (tmpo)--(#3); +} + +\newcommand{\kVecOutUp}[5][]{ + \def\dxoutr{#1}; + \ifx\dxoutr\empty + \def\dxoutr{0}; + \else + \fi + + \coordinate (tmpo) at ($(#2.north) + (#5,0)$); + + \node[above of= tmpo, node distance= 1.2cm + \dxoutr, font=\textsize] (#3) {\color{\colortext}#4}; + + \draw[-latex, \linecolor, veclinetype] (tmpo)--(#3); +} + +\newcommand{\kVecOutDown}[5][]{ + \def\dxoutr{#1}; + \ifx\dxoutr\empty + \def\dxoutr{0}; + \else + \fi + + \coordinate (tmpo) at ($(#2.south) + (#5,0)$); + + \node[below of= tmpo, node distance= 1.2cm + \dxoutr, font=\textsize] (#3) {\color{\colortext}#4}; + + \draw[-latex, \linecolor, veclinetype] (tmpo)--(#3); +} + + % ---------------------------------------------------------------------------------------- % SIGNAL FLOW GRAPHS -\newcommand{\sfgStart}[3]{ +\newcommand{\ksfgStart}[3]{ \node[draw,circle,fill=\linecolor,inner sep=0pt, outer sep=0pt, minimum size=0.5em, node distance= \horizdist,label=below:\color{\colortext}\textsize{#3}] (#1) at #2 {}; } -\newcommand{\sfgNStart}[3]{ +\newcommand{\ksfgNStart}[3]{ \node[draw,circle,fill=\linecolor,inner sep=0pt, outer sep=0pt, minimum size=0.5em, node distance= \horizdist,label=below:\color{\colortext}\textsize{#3}] (#1) at #2 {}; } -\newcommand{\sfgNodeR}[5][]{ +\newcommand{\ksfgNodeR}[5][]{ \node[fill=\linecolor,circle,inner sep=0pt, outer sep=0pt, minimum size=.5em, right of = #2, node distance= \sfghorizdist,label=#5:\color{\colortext}\textsize{#4}] (#3) {}; \draw [\linecolor, \linepathtype, midarrow] (#2)-- node[auto,above] {\textsize{#1}} (#3); } -\newcommand{\sfgNodeL}[5][]{ +\newcommand{\ksfgNodeL}[5][]{ \node[fill=\linecolor,circle,inner sep=0pt, outer sep=0pt, minimum size=.5em, left of = #2, node distance= \sfghorizdist,label=#5:\color{\colortext}\textsize{#4}] (#3) {}; \draw [\linecolor, \linepathtype, midarrow] (#2)-- node[auto,above] {\textsize{#1}} (#3); } -\newcommand{\sfgNodeU}[5][]{ +\newcommand{\ksfgNodeU}[5][]{ \node[fill=\linecolor,circle,inner sep=0pt, outer sep=0pt, minimum size=.5em, above of = #2, node distance= \sfghorizdist,label=#5:\color{\colortext}\textsize{#4}] (#3) {}; \draw [\linecolor, \linepathtype, midarrow] (#2)-- node[auto,above] {\textsize{#1}} (#3); } -\newcommand{\sfgNodeD}[5][]{ +\newcommand{\ksfgNodeD}[5][]{ \node[fill=\linecolor,circle,inner sep=0pt, outer sep=0pt, minimum size=.5em, below of = #2, node distance= \sfghorizdist,label=#5:\color{\colortext}\textsize{#4}] (#3) {}; \draw [\linecolor, \linepathtype, midarrow] (#2)-- node[auto,above] {\textsize{#1}} (#3); } -\newcommand{\sfgLinkSelfR}[2][]{ +\newcommand{\ksfgLinkSelfR}[2][]{ \draw[\linecolor, \linepathtype, midarrow,looseness=50] (#2) to [out=45,in=-45] node[right] {\textsize{#1}} (#2); } -\newcommand{\sfgLinkSelfL}[2][]{ +\newcommand{\ksfgLinkSelfL}[2][]{ \draw[\linecolor, \linepathtype, midarrow,looseness=50] (#2) to [out=-135,in=-135] node[left] {\textsize{#1}} (#2); } -\newcommand{\sfgLinkSelfU}[2][]{ +\newcommand{\ksfgLinkSelfU}[2][]{ \draw[\linecolor, \linepathtype, midarrow,looseness=50] (#2) to [in=45,out=135] node[above] {\textsize{#1}} (#2); } -\newcommand{\sfgLinkSelfD}[2][]{ +\newcommand{\ksfgLinkSelfD}[2][]{ \draw[\linecolor, \linepathtype, midarrow,looseness=50] (#2) to [in=225,out=315] node[below] {\textsize{#1}} (#2); } -\newcommand{\sfgCLinkFlip}[4][]{ +\newcommand{\ksfgCLinkFlip}[4][]{ \draw[midarrow, bend right=60] (#2) to node[#4] {\textsize{#1}} (#3); } -\newcommand{\sfgCLink}[4][]{ +\newcommand{\ksfgCLink}[4][]{ \draw[midarrow, bend left=60] (#2) to node[#4] {\textsize{#1}} (#3); } %% node label positioning: at start near start midway near end at end, above below, sloped -- cgit v1.2.3