| 1 |
% Block diagrams in TeXdraw |
| 2 |
|
| 3 |
% $Id: blockdiagram.tex 1.15 2019/04/18 TeXdraw-v2r3 $ |
| 4 |
|
| 5 |
% Copyright (C) 1993-2019 Peter Kabal |
| 6 |
|
| 7 |
% This work is licensed under the Creative Commons Attribution (CC-BY) |
| 8 |
% License, any version. To view the licenses, visit |
| 9 |
% creativecommons.org/licenses/by or send a letter to |
| 10 |
% Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. |
| 11 |
|
| 12 |
% Peter Kabal |
| 13 |
% Department of Electrical & Computer Engineering |
| 14 |
% McGill University |
| 15 |
|
| 16 |
% peter dot kabal at mcgill dot ca |
| 17 |
% http://www-mmsp.ece.mcgill.ca/MMSP/Documents/Software/ |
| 18 |
|
| 19 |
% =============================================================== |
| 20 |
|
| 21 |
\input txdtools |
| 22 |
|
| 23 |
% size of sum and product circles |
| 24 |
\def\cradius{0.08} |
| 25 |
|
| 26 |
% \bdot |
| 27 |
% big dot |
| 28 |
\def\bdot{\fcir f:0 r:0.02 } |
| 29 |
|
| 30 |
% centred, stacked items |
| 31 |
\def\hcp#1{$\vcenter{\halign{\hss ##\hss\cr #1\crcr}}$} |
| 32 |
|
| 33 |
% left justified, stacked items |
| 34 |
\def\hlp#1{$\vcenter{\halign{##\hss\cr #1\crcr}}$} |
| 35 |
|
| 36 |
% right justified, stacked items |
| 37 |
\def\hrp#1{$\vcenter{\halign{\hss ##\cr #1\crcr}}$} |
| 38 |
|
| 39 |
% signal labels - Top text, Bottom text, Left text, Right text, |
| 40 |
% and Center text |
| 41 |
\def\Ttext#1{\bsegment |
| 42 |
\textref h:C v:B \htext (0 +0.06){\hcp{#1}} |
| 43 |
\esegment} |
| 44 |
\def\Btext#1{\bsegment |
| 45 |
\textref h:C v:T \htext (0 -0.06){\hcp{#1}} |
| 46 |
\esegment} |
| 47 |
\def\Ltext#1{\bsegment |
| 48 |
\textref h:R v:C \htext (-0.06 0){\hrp{#1}} |
| 49 |
\esegment} |
| 50 |
\def\Rtext#1{\bsegment |
| 51 |
\textref h:L v:C \htext (+0.06 0){\hlp{#1}} |
| 52 |
\esegment} |
| 53 |
\def\Ctext#1{\bsegment |
| 54 |
\textref h:C v:C \htext{\hcp{#1}} |
| 55 |
\esegment} |
| 56 |
|
| 57 |
% ruled box (horizontal) with centered label, |
| 58 |
% position set to the end of the box |
| 59 |
% \Fbox W H text |
| 60 |
\def\Fbox#1#2#3{\bsegment |
| 61 |
\bsegment |
| 62 |
\setsegscale 0.5 |
| 63 |
\textref h:C v:C \htext (#1 0){\hcp{#3}} |
| 64 |
\esegment |
| 65 |
\setsegscale 0.5 \lvec (0 #2) |
| 66 |
\setsegscale 1 |
| 67 |
\rlvec (#1 0) \rlvec (0 -#2) \rlvec (-#1 0) \lvec (0 0) |
| 68 |
\savepos (#1 0)(*@x *@y) |
| 69 |
\esegment |
| 70 |
\move (*@x *@y)} |
| 71 |
|
| 72 |
% ruled box (vertical) with centered label, position set to the end of the box |
| 73 |
% \Gbox W H text |
| 74 |
\def\Gbox#1#2#3{\bsegment |
| 75 |
\bsegment |
| 76 |
\setsegscale 0.5 |
| 77 |
\textref h:C v:C \htext (0 #2){\hcp{#3}} |
| 78 |
\esegment |
| 79 |
\setsegscale 0.5 \lvec (#1 0) |
| 80 |
\setsegscale 1 |
| 81 |
\rlvec (0 #2) \rlvec (-#1 0) \rlvec (0 -#2) \lvec (0 0) |
| 82 |
\savepos (0 #2)(*@x *@y) |
| 83 |
\esegment |
| 84 |
\move (*@x *@y)} |
| 85 |
|
| 86 |
% ruled triangle (horizontal) with centered label, |
| 87 |
% position set to the end of the box |
| 88 |
% \Ftri W H text |
| 89 |
\def\Ftri#1#2#3{\bsegment |
| 90 |
\bsegment |
| 91 |
\setsegscale 0.3333 |
| 92 |
\textref h:C v:C \htext (#1 0){\hcp{#3}} |
| 93 |
\esegment |
| 94 |
\bsegment |
| 95 |
\savepos (#1 0)(*@x *@y) |
| 96 |
\esegment |
| 97 |
\setsegscale 0.5 \lvec (0 #2) |
| 98 |
\setsegscale 1 \lvec (#1 0) |
| 99 |
\setsegscale 0.5 \lvec (0 -#2) \lvec (0 0) |
| 100 |
\esegment |
| 101 |
\move (*@x *@y)} |
| 102 |
|
| 103 |
% \pluss |
| 104 |
% plus sign |
| 105 |
\def\pluss {\bsegment |
| 106 |
\setsegscale {\cradius} |
| 107 |
\move (-0.5 0) \lvec (+0.5 0) |
| 108 |
\move (0 -0.5) \lvec (0 +0.5) |
| 109 |
\esegment} |
| 110 |
|
| 111 |
% \minuss |
| 112 |
% minus sign |
| 113 |
\def\minuss {\bsegment |
| 114 |
\setsegscale {\cradius} |
| 115 |
\move (-0.5 0) \lvec (+0.5 0) |
| 116 |
\esegment} |
| 117 |
% \mults |
| 118 |
% multiplication sign |
| 119 |
\def\mults {\bsegment |
| 120 |
\setsegscale {\cradius} |
| 121 |
\realmult \cradius {0.354} \tmpa |
| 122 |
\move (-0.354 -0.354) \lvec (+0.354 +0.354) |
| 123 |
\move (-0.354 +0.354) \lvec (+0.354 -0.354) |
| 124 |
\esegment} |
| 125 |
|
| 126 |
% \pcir |
| 127 |
% circle of given radius with a plus sign |
| 128 |
\def\pcir {\lcir r:{\cradius} \pluss} |
| 129 |
|
| 130 |
% \mcir |
| 131 |
% circle of given radius with a multiplication sign |
| 132 |
\def\mcir {\lcir r:{\cradius} \mults} |
| 133 |
|
| 134 |
% \putn, \putnne, etc |
| 135 |
% places text at an offset from the center of a circle, with |
| 136 |
% the position of the text specified in compass directions |
| 137 |
\def\puttext (#1 #2)#3{\bsegment |
| 138 |
\setsegscale {\cradius} |
| 139 |
\textref h:C v:C \htext (#1 #2){#3} |
| 140 |
\esegment} |
| 141 |
\def\putn #1{\puttext ( 0 +2 ){#1}} |
| 142 |
\def\putnne #1{\puttext (+1.2 +1.7){#1}} |
| 143 |
\def\putene #1{\puttext (+1.7 +1.2){#1}} |
| 144 |
\def\putese #1{\puttext (+1.7 -1.2){#1}} |
| 145 |
\def\putsse #1{\puttext (+1.2 -1.7){#1}} |
| 146 |
\def\puts #1{\puttext ( 0 -2 ){#1}} |
| 147 |
\def\putssw #1{\puttext (-1.2 -1.7){#1}} |
| 148 |
\def\putwsw #1{\puttext (-1.7 -1.2){#1}} |
| 149 |
\def\putwnw #1{\puttext (-1.7 +1.2){#1}} |
| 150 |
\def\putnnw #1{\puttext (-1.2 +1.7){#1}} |
| 151 |
|
| 152 |
|
| 153 |
% \avectoc |
| 154 |
% arrow vector to a circle |
| 155 |
\def\avectoc (#1 #2){\currentpos \xa\ya |
| 156 |
\cossin ({\xa} \ya)(#1 #2)\cosa\sina |
| 157 |
\savepos (#1 #2)(*@x *@y)% |
| 158 |
\bsegment |
| 159 |
\move (*@x *@y)% |
| 160 |
\setsegscale {\cradius} |
| 161 |
\rmove ({-\cosa} -\sina)% |
| 162 |
\savecurrpos (*@x *@y)% |
| 163 |
\esegment |
| 164 |
\avec (*@x *@y)% |
| 165 |
\move (#1 #2)} |
| 166 |
% \avecfrc |
| 167 |
% arrow vector from a circle |
| 168 |
\def\avecfrc (#1 #2){\currentpos \xa\ya |
| 169 |
\cossin ({\xa} \ya)(#1 #2)\cosa\sina |
| 170 |
\bsegment |
| 171 |
\setsegscale {\cradius} |
| 172 |
\move ({\cosa} \sina)% |
| 173 |
\savecurrpos (*@x *@y)% |
| 174 |
\esegment |
| 175 |
\move (*@x *@y)% |
| 176 |
\avec (#1 #2)} |
| 177 |
% \avecfrctoc |
| 178 |
% arrow vector from a circle to a circle |
| 179 |
\def\avecfrctoc (#1 #2){\currentpos \xa\ya |
| 180 |
\cossin ({\xa} \ya)(#1 #2)\cosa\sina |
| 181 |
\bsegment |
| 182 |
\setsegscale {\cradius} |
| 183 |
\move ({\cosa} \sina)% |
| 184 |
\savecurrpos (*@x *@y)% |
| 185 |
\esegment |
| 186 |
\move (*@x *@y)% |
| 187 |
\avectoc (#1 #2)} |
| 188 |
% \lvecfrc |
| 189 |
% line vector from a circle |
| 190 |
\def\lvecfrc (#1 #2){\currentpos \xa\ya |
| 191 |
\cossin ({\xa} \ya)(#1 #2)\cosa\sina |
| 192 |
\bsegment |
| 193 |
\setsegscale {\cradius} |
| 194 |
\move ({\cosa} {\sina})% |
| 195 |
\savecurrpos (*@x *@y)% |
| 196 |
\esegment |
| 197 |
\move (*@x *@y)% |
| 198 |
\lvec (#1 #2)} |