diff options
Diffstat (limited to 'Master/texmf-dist/doc/latex/circuit-macros/examples/extras')
63 files changed, 4202 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/ASMEbox.m4 b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/ASMEbox.m4 new file mode 100644 index 00000000000..6dc9d02d8ac --- /dev/null +++ b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/ASMEbox.m4 @@ -0,0 +1,55 @@ +.PS +# ASME_Y14-5.m4 +# https://en.wikipedia.org/wiki/Geometric_dimensioning_and_tolerancing +cct_init +sinclude(ASME_Y14-5.m4def) +sinclude(../ASME_Y14-5.m4def) +ifsvg(`svg_font(sans-serif,12bp__,3bp__)', +`textht = 11bp__*2/3 + iflatex(`command "{\sf"')') + + boxht = 7.5/0.5*textht + boxwid = 15/7.5 * boxht + circlerad = 2.3/0.5*textht*0.5 + thicklines_(1) +# ASME Y14.5 specs: + arrowht = textht*0.8 + arrowwid = textht*0.6 + + Box: box + Circle: circle at Box.c; {CM: move from Circle.se down textht right textht} +thinlines_ +CLU: ctrline( up_ Box.ht with .c at Box.c, Box.ht/2 ) +CLH: ctrline( right Box.ht with .c at Box.c, Box.ht/2 ) + + dimension_(from Box.nw to Box.n,Box.ht/6) + thicklines_(1) + {Y14_frame("10") with .s at AS_C+(0,textht/2)} + thinlines_ + line from 3rd last line.start to CLU.end + dimension_(from Box.w to Box.nw,Box.ht/6) + thicklines_(1) + {Y14_frame("5") with .e at AS_C+(-textht/2,0)} + thinlines_ + line from 4th last line.start to CLH.start + +thicklines_ + DA: Y14_frame("A") at Box.ne+(-textht*1.5,textht*5) + datumarrow(from DA.s to (DA,Box.n)) + DB: Y14_frame("B") at Box.sw+(-textht*5,textht*2) + datumarrow(from DB.e to (Box.w,DB)) + + F: Y14_frame(Y14_pos_, + Y14_dia_;"0.03";"(M)", + "A","B","C") with .w at Box.se+(-textht*4,-textht*2) + G: Y14_frame(Y14_fla_,Y14_cyl_,Y14_lin_, + Y14_sur_,Y14_per_,Y14_ang_, + Y14_par_) with .nw at F.sw+(0,-0.1) + H: Y14_frame(Y14_pos_,Y14_cir_,Y14_tot_,Y14_dia_) \ + with .nw at G.sw+(0,-0.1) + + { CB: move left textht from F.w } + arrow <- from Circle.se to Intersect_(CM,CB) then to F.w + +command iflatex(`"}"',ifsvg(`"</g>"')) +.PE diff --git a/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Ant.m4 b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Ant.m4 new file mode 100644 index 00000000000..f4a22226a20 --- /dev/null +++ b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Ant.m4 @@ -0,0 +1,30 @@ +.PS +# Ant.m4 (Langton's ant) +# https://tex.stackexchange.com/questions/361838/how-to-create-a-langtons-ant-in-latex/361891 +# https://en.wikipedia.org/wiki/Langton%27s_ant +gen_init +NeedDpicTools + picwid = 5 + D: (0,0); DD: (1,0); t[D] = 0 + minx = 0; miny = 0; maxx = 0; maxy = 0 + for i = 0 to 10500 do { + if (t[D]%2) == 0 then { DD: (-DD.y,DD.x) } else { DD: (DD.y,-DD.x) } + t[D] += 1 + D: D+DD + if D.x > maxx then { maxx = D.x; for y = miny to maxy do { t[maxx,y] = 0 }} \ + else { if D.x < minx then { + minx = D.x; for y = miny to maxy do { t[minx,y] = 0 }}} + if D.y > maxy then { maxy = D.y; for x = minx to maxx do { t[x,maxy] = 0 }} \ + else { if D.y < miny then { + miny = D.y; for x = minx to maxx do { t[x,miny] = 0 }}} + } + boxwid = picwid/(maxx-minx) + boxht = picwid/(maxy-miny) + if boxht > boxwid then { boxht = boxwid } else { boxwid = boxht } + circlerad = boxht/2 + hue = 240; val = 1 + for i = minx to maxx do { for j = miny to maxy do { + if t[i,j]!=0 then { sat = (t[i,j]%20)/20 + hsvtorgb(hue,sat,val,r,g,b) + circle colored rgbstring(r,g,b) at (-i,j)*boxwid } }} +.PE diff --git a/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/ArrowFn.m4 b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/ArrowFn.m4 new file mode 100644 index 00000000000..f8ca1527224 --- /dev/null +++ b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/ArrowFn.m4 @@ -0,0 +1,56 @@ +.PS +# ArrowFn.m4 +# https://tex.stackexchange.com/questions/581089/arrow-function-diagrams +gen_init +textoffset = 3bp__ + brad = 0.04 + bht = 0.4 + bwid = 0.25 +define(`rbox',`box rad brad outlined "orange"') + +B1: [ + linethick = 1.2 + arrowwid = 0.08 + rbox wid 5*boxwid ht 3/2*boxwid + line from last box.w-(bht/4,0) "\Large $X$" above ljust +T: Here + arrow up bwid right bwid then right bwid +F: rbox ht bht "\Large $f$" + {"\Large $Y$" above ljust } + arrow down bwid right bwid from T then right boxwid + bwid*3/2 +G: rbox ht bht "\Large $g$" + {"\Large $Z$" above ljust } +S: circle diam bht "\Large $+$" at (G.e.x+boxwid,(F.y+G.y)/2) + d = F.y-S.nw.y + arrow from F.e to S.nw+(-d,d) then to S.nw + arrow from G.e to S.sw+(-d,-d) then to S.sw + arrow right from S.e + ] +[ + bht = bht/2 + sbwid = boxwid*3/4 + bbwid = sbwid*5/4 + dh = bht/2 +B1: rbox wid bbwid ht bbwid +B2: rbox wid sbwid*3/2 ht bbwid at B1+(3/2*bbwid,0) +B3: rbox wid bbwid ht bbwid at B2+(3/2*bbwid,0) +B4: rbox wid sbwid*3/2 ht bbwid at B3+(3/2*bbwid,0) +B5: rbox wid bbwid ht bbwid at B4+(3/2*bbwid,0) + F: rbox ht bht wid sbwid at B2.n-(0,bht*3/4) "$f$" +BR: B2.s+(0,B2.n.y-F.y) + G: rbox ht bht wid sbwid at (B4,F) "$g$" + S: circle diam bht*3/2 at B5+(bht/2,0) "$+$" + arrow right from S.e + T: B1.w+(dh,0) +B: rbox ht bbwid*5/4 wid boxwid*7.25 with .w at T-(sbwid*3/4,0) + { line from T left sbwid "$x$" above ljust } + arrow from T to (B1.e-(dh,0),F) then to F.w + arrow from F.e to (B3.w+(dh,0),F) then to (B3.e-(dh,0),BR) + continue to (B5.w+(dh,0),Here) then to S.sw + line thick 5 outlined "white" from B3.sw to B3.ne chop brad + arrow from T to (B1.e-(dh,0),BR) then to (B3.w+(dh,0),BR) \ + then to (B3.e-(dh,0),G) then to G.w + arrow from G.e to (B5.w+(dh,0),G) then to S.nw + ] with .nw at B1.sw+(0,-0.2) + +.PE diff --git a/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Attention.m4 b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Attention.m4 new file mode 100644 index 00000000000..7f0b7127c7a --- /dev/null +++ b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Attention.m4 @@ -0,0 +1,41 @@ +.PS +# Attention.m4 +gen_init +scale = 2.54 +linethick = 0.2 + +define dot2 { (($1).x*($2).x + ($1).y*($2).y) } + + nlines = 128 + nr = 50 + innerrad = 1 + outerrad = 8 + diff = outerrad - innerrad +B: box wid outerrad*2 ht outerrad*2 outline "red" shaded "red" +C: circle rad outerrad at B + circle rad innerrad at C shaded "black" + P[0]: C+(innerrad,0) + t = 0 + for i=1 to nr do { + r = innerrad+i/nr*diff + t = t + i/nr*(-pi_/2)/nr + P[i]: C+(rect_(r,t)) + } + dth = twopi_/nlines + R: (cos(dth),-sin(dth)) + S: (sin(dth),cos(dth)) + for j = 0 to nlines-1 do { + for i=0 to nr do { + X: P[i]-C + Q[nr-i]: (dot2(R,X),dot2(S,X)) + C + } + shade(j%2, + fitcurve(P,nr) + line from P[nr] to Q[0] + fitcurve(Q,nr) + line from Q[nr] to P[0] + ) + for i=0 to nr do { P[i]: Q[nr-i] } + } + +.PE diff --git a/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Autoencoder.m4 b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Autoencoder.m4 new file mode 100644 index 00000000000..92a81ac9509 --- /dev/null +++ b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Autoencoder.m4 @@ -0,0 +1,82 @@ +.PS +# Masked_Autoencoder.m4 +gen_init +NeedDpicTools + + circlerad = 0.2 + circlesep = 0.5 + rowsep = 0.9 + arrowht = arrowht*0.8 + arrowwid = arrowwid*1.4 + linethick = 1 + +define plan { + m = 0 + for i=1 to 4 do { + for j=1 to ncircles[i] do { + exec sprintf("C[i,j]: circle thick 1.6 at Here \"\large\sf $%g\"",m+j) + if i>1 then { + if "$1"=="" then { + for k=1 to ncircles[i-1] do { arrow from C[i,j] to C[i-1,k] chop } } + } + if j!=ncircles[i] then { move right_ circlesep from C[i,j] } + } + m += ncircles[i] + case(i, + move to C[1,1]+(-circlesep/2,-rowsep), + move to C[2,1]+(0,-rowsep), + move to C[3,1]+(circlesep/2,-rowsep), ) + } + } + gridsiz = 0.78/4 +define grid { [ SW: 0,0 + for i=1 to $1 do { + move to (0,(0.5-i)*gridsiz) + exec sprintf("fv = $%g",2+i) + for j=1 to $2 do { fl = 1-(int(fv / 2^(j-1)) % 2) + box wid gridsiz ht gridsiz outlined "gray" shaded rgbstring(fl,fl,fl) } + } ]} +define cxt { + m = 1 + for i=2 to 4 do { + for j=1 to ncircles[i] do { + exec sprintf("narrows = $%g",m) + for k=1 to narrows do { + exec sprintf("cnum = $%g",m+k) + arrow from C[i,j] to C[i-1,cnum] chop + } + m += narrows+1 + } } } + + array(ncircles,3,4,4,3) + plan() + for j=1 to 3 do { + sprintf("$\hat{x}_%g$",j) at C[1,j].n above + sprintf("$x_%g$",j) at C[4,j].s+(0,-2bp__) below + } + "V" at 0.5 between C[2,1].w and C[1,1].w + "W$^2$" at 0.5 between C[3,1].w and C[2,1].w + "W$^1$" at 0.5 between C[3,1].w and C[4,1].w + +GV: grid(3,4,0,15,6) with .w at C[2,4]+(circlerad*2,rowsep/2) + "$=\hbox{M}^{\hbox{V}}$" at GV.e ljust +G2: grid(4,4,13,0,0,13) with .w at (GV.w,C[3,4]+(circlerad*2,rowsep/2)) + "$=\hbox{M}^{\hbox{V}^2}$" at G2.e ljust +G1: grid(4,3,1,5,1,1) with .w at (GV.w,C[4,3]+(circlerad*2,rowsep/2)) + "$=\hbox{M}^{\hbox{V}^1}$" at G1.e ljust + + move to (GV.x+3*circlesep,C[1,1].y) + plan(3,1,2,1,2,2,1,2,1,2,2,3,1,2) + for i=2 to 4 do { + rgbdraw(0.5,0.5,0.5, + cxt(2,1,3,0,0,2,1,3, 0,4,1,2,3,4,0,0, 0,4,1,2,3,4,0) ) + cxt(0,1,1,1,1,0, 2,2,3,0,2,2,3,2,2,3, 0,0,3,1,3,4) + } + for j=1 to 3 do { sprintf("$x_%g$",j) at C[4,j].s+(0,-2bp__) below } + arrow dotted from C[1,2].n up circlesep/2; "$p(x_2)$" above + "$p(x_3|x_2)$" at (C[1,3]+(circlesep/2,0),last "") above + arrow dotted from C[1,3] to last "".s chop circlerad chop textoffset + "$p(x_1|x_2,x_3)$" at (C[1,1]+(-circlesep/2,0),last "") above + arrow dotted from C[1,1] to last "".s chop circlerad chop textoffset + +.PE diff --git a/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Bridge.m4 b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Bridge.m4 new file mode 100644 index 00000000000..74717922391 --- /dev/null +++ b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Bridge.m4 @@ -0,0 +1,35 @@ +.PS +# Bridge.m4 +cct_init +linewid = 1.5 + down_ + AC: source(up_ elen_,S) + line right_ elen_ + dlen = linewid*2/3 +Bridge: [ + N: Here; S: Here+(0,-2*dlen); E: N+(dlen,-dlen); W: N+(-dlen,-dlen) + diode(from N to E) + diode(from S to E) + diode(from W to N) + diode(from W to S) + ] at (Here,AC) + + line from Bridge.N to last line.end + line from Bridge.S to (Bridge.S,AC.start) + Gr: line to AC.start + line from Bridge.E right_ dlen + G: gap(down_ Bridge.ht/2+dimen_/4,1); llabel(+,,-) + line from Bridge.W left_ dlen/4 + crossover(to (Here,G.end),,Gr) + line to G.end chop 0 chop dotrad_ + + [ L: line right_ linewid/3 + sinusoid( linewid/6,twopi_/linewid*4,-pi_/2,0,linewid/8) with .End at L + sinusoid( linewid/6,twopi_/linewid*4,-pi_/2,0,linewid/8) with .Start at L + ] at G + R: resistor(down_ G.len from G.start+(dimen_/2,0)); llabel(,R) + arrow wid arrowwid*2 from R.start to 0.5<R.start,G.start> + arrow wid arrowwid*2 from R.end to 0.5<R.end,G.end> + + +.PE diff --git a/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/CSlight.m4 b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/CSlight.m4 new file mode 100644 index 00000000000..720e74f9e2b --- /dev/null +++ b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/CSlight.m4 @@ -0,0 +1,173 @@ +.PS +# Csource.m4 + ifmpost(command "verbatimtex") + command "\newcommand\scriptstack[2][c]{\hbox{\scriptsize\shortstack[#1]{#2}}}%" + command "{\scriptsize" + ifmpost(command "etex") +define(`density',0.90) +setrgb(density, density, density) + +cct_init + linewid = 0.4 + +define(`npair',`[define(`m4lr',ifelse(`$1',,l,r)) + J: mosfet(down_ dimen_,ifelse(`$1',,R,L),uHSDF,E) + "\scriptstack[l]{$Q_{`$2'}$\\ 2N5464}" at J.n+(0,8pt__) + G: J.G + line ifelse(`$1',,right,left) dimen_/4 from J.D + Q: bi_tr(up_ dimen_,ifelse(`$1',,L,R),,E) with .B at Here + ifelse(`$1',,r,l)label(,`\scriptstack[m4lr]{$Q_{`$3'}$\\ 2N4239}') + E: Q.E + S: dot(at (Q.C,J.S)) + line from J.S to S then to Q.C ]') + +define(`ppair',`[define(`m4lr',ifelse(`$1',,l,r)) + J: mosfet(down_ dimen_,ifelse(`$1',,R,L),dHSDF,E) + "\scriptstack[l]{$Q_{`$2'}$\\ 2N3819}" at J.s-(0,8pt__) + G: J.G + line ifelse(`$1',,right,left) dimen_/4 from J.S + Q: bi_tr(down_ dimen_,ifelse(`$1',,R,L),P,E) with .B at Here + ifelse(`$1',,l,r)label(,`\scriptstack[m4lr]{$Q_{`$3'}$\\ 2N4236}') + E: Q.E + S: dot(at (Q.C,J.D)) + line from J.D to S then to Q.C ]') + + R2: resistor(down_ dimen_) + llabel(,`\scriptstack[l]{$R_2$\\ 150}') + dot + Q13: bi_tr(down_ dimen_,,P,E) with .E at Here + rlabel(,`\scriptstack[r]{$Q_{13}$\\ 2N4236}') + line down 3.1*elen_ from Q13.C + Q14: bi_tr(up_ dimen_,R,,E) with .C at Here + llabel(,`\scriptstack[r]{$Q_{14}$\\ 2N4239}') + dot(at Q14.E) + { line left_ dimen_*1.3 then up_ dimen_ + R1: potentiometer(up_ dimen_) with .Start at Here + rlabel(,`\scriptstack[l]{$R_1$\\ $20\,$K}') + { ground(at R1.T1) } + line from R1.End to (R1.End,Q13.E) then to Q13.E } + { dot(at Q13.C+(0,-elen_)) + line to (R1.R,Here)+(-dimen_/2,0) + { arrowline(right_ dimen_/2); llabel(,i_1) } + V1: gap(down_ dimen_,1); rlabel(+,V_1,-) + line down_ dimen_/4 chop dotrad_ chop 0; ground(,T) } + R3: resistor(down_ dimen_) + llabel(,`\scriptstack[l]{$R_3$\\ 150}') + dot(at Q13.C+(0,-2*elen_)) + line right_ dimen_/2 + A1: opamp with .In2 at Here; "$A_1$" at A1.C + "`\scriptstack[l]{Nexus\\ SQ-10A}'" at A1.s below + line left_ dimen_/4 from A1.In1 then up_ dimen_/2 then right dimen_ + dot + { resistor(up_ elen_) + llabel(,`\scriptstack[r]{$R_{14}$\\ $19\,$K}') + line to (Here,Q13.E) then to Q13.E } + line to (A1.Out,Here) + dot + { line to A1.Out + dot + resistor(down_ to (Here,Q14.E)) + llabel(,`\scriptstack[l]{$R_{13}$\\ $91\,$K}') + line to Q14.E } + R6: resistor(right_ dimen_) + rlabel(,`\scriptstack[l]{$R_6$\\ $15\,$K}') + dot + line to (Here,A1.In1) then right_ dimen_/4 + A2: opamp with .In1 at Here; "$A_2$" at A2.C + "`\scriptstack[l]{Nexus\\ SQ-10A}'" at A2.s below + line left_ dimen_/4 from A2.In2 + ground + + dot(at A2.Out) + DP1: npair(,3,4) with .E at (A2.Out,Q14.B)+(elen_*1.25,0) + line from A2.Out to (A2.Out,DP1.G) then to DP1.G + line from DP1.E to (DP1.E,R3.bottom); dot + D4: reversed(`diode',up_ dimen_/2 from DP1.S) + D3: reversed(`diode',up_ dimen_/2 from Here+(0,-dimen_/6)) + llabel(,`\scriptstack[r]{$D_4$\\ OMC-V\\ $D_3$}') + DP2: ppair(,1,2) with .E at (DP1.E,Q13.B) + D1: diode(down_ dimen_/2 from DP2.S) + D2: diode(down_ dimen_/2 from Here+(0,dimen_/6)) + rlabel(,`\raisebox{5pt}{\scriptstack[r]{$D_1$\\ $D_2$\\ OMC-V}}') + dot(at (Here,A2)) + line to D2.bottom + line from DP2.G to (A2.Out,DP2.G) then to A2.Out + line from DP2.E to (DP2.E,R2.top); dot + + T: dot(at (DP1.E,A2)+(dimen_,0)) + DP3: npair(,7,8) with .G at (Here,DP1.G)+(dimen_/4,0) + dot(at DP3.E) + line to Q14.B + DP4: ppair(,5,6) with .G at (DP3.G,DP2.G) + dot(at DP4.E) + line to Q13.B + line from DP3.G to (T,DP3.G) then to (T,DP4.G) then to DP4.G + R11: resistor(down_ dimen_ from DP4.S) + rlabel(,`\scriptstack[r]{$R_{11}$\\ $20$}') + D5: diode(up_ from DP3.S to (DP3.S,A2),Z) + llabel(,`\scriptstack[r]{$D_5$\\ 1N4729$_{\vphantom{1}}$}') + line to R11.end + C4: capacitor(right_ dimen_*1.3 from DP3.S,C) + llabel(`C_4'); rlabel(,`0.68\,\mu\hbox{F}') + C3: capacitor(right_ dimen_*1.3 from DP4.S,C) + llabel(`C_3'); rlabel(,`0.68\,\mu\hbox{F}') + dot + dot(at (Here,R6)) + C2: reversed(`capacitor',left_ dimen_*1.3,C) + rlabel(,,`C_2'); llabel(,`0.1\,\mu\hbox{F}') + line to R6.end + + R5: resistor(up_ from R6.end to (R6.end,Q13.B)) + rlabel(,`\scriptstack[l]{$R_5$\\ $100\,$K}') + dot(at R5.top-(0,dimen_/2)) + line left_ dimen_/2 + capacitor(down_ dimen_,C) + rlabel(,`\scriptstack[r]{$C_1$\\ $1\,\mu$F}') + ground(,T) + + line from DP4.E to (DP4.E,R2.bottom) + resistor(up_ to (Here,R2.top)) + rlabel(,`\scriptstack[l]{$R_9$\\ $910$}') + dot + resistor(down_ from DP3.E to (DP3.E,R3.bottom)) + llabel(,`\scriptstack[l]{$R_{10}$\\ $910$}') + dot + + line from R5.top to (R5,Q13.E) + resistor(right_ elen_) + llabel(,`\scriptstack[l]{$R_4$\\ $100\,$K}') + line to (C4.end,Here) then to C4.end + + DP5: npair(L,11,10) with .E at (C4.end,DP1.E)+(elen_*0.8,0) + line from DP5.E to (DP5.E,R3.bottom); dot + line from R3.bottom to Here+(dimen_/2,0) + dot(,,1) + `"${}-E_{CC}$"' ljust + D6: diode(up_ from DP5.S to (DP5.S,A2),Z) + llabel(,`\scriptstack[r]{$D_6$\\ 1N4728}') + DP6: ppair(L,12,9) with .E at (DP5.E,DP2.E) + line from DP6.E to (DP6.E,R2.top); dot + line from R2.top to Here+(dimen_/2,0) + dot(,,1) + `"${}+E_{CC}$"' ljust + resistor(down_ from DP6.S to (DP6.S,C2)) + rlabel(,`\scriptstack[r]{$R_{12}$\\ $20$}') + dot + { line to C2.e } + line to D6.end + + Vr: dot(at (DP6.G,V1.top)+(dimen_/4,0)) + line from DP6.G to (Vr,DP6.G) then to (Vr,DP5.G) then to DP5.G + reversed(`arrowline',right_ dimen_/2 from Vr); llabel(,i_2) + V2: gap(down_ dimen_,1); llabel(+,V_2,-) + line down_ dimen_/4 chop dotrad_ chop 0; ground(,T) + + dot(at (Vr,T)) + resistor(left_ to (DP6.E,Here)) + rlabel(,`\scriptstack[l]{$R_{15}$\\ $200$}') + line to (DP1.E,Here) + dot + + command "ifmpost(verbatimtex) }% ifmpost(etex)" +resetrgb +.PE diff --git a/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Ccurve.m4 b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Ccurve.m4 new file mode 100644 index 00000000000..6f3b537aac5 --- /dev/null +++ b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Ccurve.m4 @@ -0,0 +1,14 @@ +.PS +# Ccurve.m4 +gen_init +scale = 1.5 +# Gosper C curve + +`define' c_curve {if $3==0 then { continue by ($1,$2) } else { + c_curve( ($1-$2)/2, ($1+$2)/2, $3-1) + c_curve( ($1+$2)/2, ($2-$1)/2, $3-1)}} + +line from 0,4 to 0,4 +c_curve(0,4,10) + +.PE diff --git a/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Chuck.m4 b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Chuck.m4 new file mode 100644 index 00000000000..df83a8ce0e1 --- /dev/null +++ b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Chuck.m4 @@ -0,0 +1,226 @@ +.PS +# Chuck.m4 +gen_init s_init(Views) sinclude(tst.dim) +# +################################################################# +divert(-1) + + `r_box(angle,pos,string) + Rotated text on a white background + (requires pstricks)' +define(`r_box', + `ifpstricks(`M4tmp: ifelse(`$2',,Here,`$2') + command sprintf("\rput{%g}(%g,%g){",`$1',crl(M4tmp.x),crl(M4tmp.y)) + f_box(`$3') at Orig + command "}%"')') +define(`crl',`int(`($1)'/scale*1000000)/1000000') + + `r_dimen(linespec,offset,label,tic offset,<->,pos) + dimension_ with rotated text on white background' +define(`r_dimen', + `M4tmp: dimension_(`$1',`$2',,,`$4',`$5') + r_box(rp_ang*rtod_,ifelse(`$6',,M4tmp+vec_(0,`$2'),`$6'),`$3')') + + `ctrline(linespec,len) + Centerline' +define(`cdashl',0.1*scale) +define(`cgapl',0.03*scale) +define(`ctrline',`rpoint_(ifelse(`$1',,`to rvec_(linewid,0)',`$1')) + define(`m4h',ifelse(`$2',,1*scale,`$2'))dnl + m4n = int(rp_len/2/(m4h))*2+1 + for i=1 to m4n do { + line to rvec_(rp_len/m4n/2-cdashl/2-cgapl,0) + move to rvec_(cgapl,0); line to rvec_(cdashl,0); move to rvec_(cgapl,0) + line thick dimensionth to rvec_(rp_len/m4n/2-cdashl/2-cgapl,0) } ') + + `ctrarcr(pos,radius,startang,endang,len) + Arc cr centerline' +define(`ctrarcr',`dnl + define(`m5h',ifelse(`$5',,1*scale,`$5'))dnl + rp_len = abs((`$2')*(`$4'-(`$3'))) + m5n = int(rp_len/2/(m5h))*2+1 + m5a = (rp_len/m5n/2-cdashl/2-cgapl)/(`$2') + m5s = cdashl/(`$2') + m5sa = `$3' + for m4irr=1 to m5n do { + arc from `$1'+(rect_(`$2',m5sa)) to `$1'+(rect_(`$2',m5sa+m5a)) \ + with .c at `$1' + m5sa = m5sa+m5a+cgapl/(`$2') + arc from `$1'+(rect_(`$2',m5sa)) to `$1'+(rect_(`$2',m5sa+m5s)) \ + with .c at `$1' + m5sa = m5sa+m5s+cgapl/(`$2') + arc from `$1'+(rect_(`$2',m5sa)) to `$1'+(rect_(`$2',m5sa+m5a)) \ + with .c at `$1' + m5sa = m5sa+m5a + } ') + +divert(0)dnl +################################################################# + +scale = 25.4*2 +tic = 3.6bp__ + +command "{\sf" + +define(`visible_thick',`linethick_(visibleth)') +define(`hidden_thick',`linethick_(hiddenth)') +define(`dimension_thick',`linethick_(dimensionth) + arrowwid = 1.5*arrowwid; arrowht = 1.5*arrowht; ') + +d1 = 230 +d2 = 204 +d3 = 140 + + visibleth = 1.2 + dimensionth = 0.4 + hiddenth = dimensionth + +Orig: Here +visible_thick + D3: circle diam d3 at Orig + D2: circle diam d2 at Orig + + rr = d1/2 + r = 40 + h = 110/2 + thet = asin((h+r)/(rr+r)) + X1: rect_(rr,thet) + P1: rect_(rr+r,thet) + +dimension_thick + cross(at (P1.x,-P1.y)) + cross(at (-P1.x,P1.y)) + +# Top outer visible line +visible_thick +# top arcs + arc ccw from (-P1.x,h) to (-X1.x,X1.y) with .c at (-P1.x,P1.y) + arc cw to X1 with .c at Orig + arc ccw from X1 to (P1.x,h) with .c at P1 +# right end + line from (P1.x,h) to (305/2,h) then to (305/2,32/2) then left 40-3 + arc ccw rad 3 + line down 32-2*3 + arc ccw rad 3 +dimension_thick { + r_dimen(up 32 with .c at (305/2-5,0),0,32) + arrow <- up 8 right 8 then right 4 from last arc.sw + "3$\,$R" ljust + r_dimen(up h*2 at (305/2,0),-10,110) +}; visible_thick + line right 40-3 then to (305/2,-h) then to (P1.x,-h) +# bottom arcs + arc ccw to (X1.x,-X1.y) with .c at P1.x,-P1.y + arc cw to (-X1.x,-X1.y) with .c at Orig + arc ccw to (-P1.x,-h) with .c at (-P1.x,-P1.y) +# left end + line from (-P1.x,-h) to (-305/2,-h) then to (-305/2,-25/2) then right 25 + down; arc ccw rad 3 + line right 40-25-2*3 + arc ccw rad 3 + line up 25 + {R: line invis down 10 at (2nd last line,last line) } + arc ccw rad 3 + line left 40-25-2*3 + arc ccw rad 3 + line to (-305/2,25/2) then to (-305/2,h) then to (-P1.x,h) + +dimension_thick +# centre + ctrline(right 305-30 with .c at Orig,60) + ctrline(up d1+10 with .c at Orig,) + + {BX: box invis ht 25+2*3 wid 40-25 rad 3 with .w at (-305/2+25,0)} + Q: line invis from BX.n to BX.s; R: line invis from BX.se up 10 left 10 + X: Intersect_(Q,R) + line <-> from BX.se to X then to (X.x,-X.y) then to BX.nw + r_box(90,BX,```3$\,$R''') + +# Drill centres + D[1]: 35,sqrt(85^2-35^2) + D[2]: -D[1].x,D[1].y + D[3]: -D[1].x,-D[1].y + D[4]: D[1].x,-D[1].y + ctrline(from D[3] to D[1] chop 15) + ctrline(to rvec_(2*15,0)) + ctrline(from D[3]+vec_(-15,0) to D[3]+vec_(15,0)) + ctrline(from D[2] to D[4] chop 15) + ctrline(to rvec_(2*15,0)) + ctrline(from D[2]+vec_(-15,0) to D[2]+vec_(15,0)) +visible_thick + for i=1 to 4 do { + circle diam 16 at D[i] + for j = 0 to 7 do { arcr(D[i],23/2,j/8*twopi_,(j+3/4)/8*twopi_) ccw } + } + +hidden_thick + for s=-1 to 1 by 2 do { + line dashed from (-305/2,s*h) to (305/2,s*h) + line dashed from (-305/2,s*30.6) to (305/2,s*30.6) + line dashed from (-305/2,s*21.1) to (305/2,s*21.1) + line dashed from (-305/2+25+2,s*21.1) to (305/2,s*21.1) + line dashed dashwid/2 from (-305/2+25,s*25/2) down -s*(40/2-25/2-2); + if s<0 then { arc dashed dashwid/4 ccw rad 2 } \ + else { up; arc dashed dashwid/4 cw rad 2 } + line dashed to ((305/2,0),Here) + for k = -1 to 1 by 2 do { + move to (k*305/2,s*(30.6+10)) + { dashline(from Here+(0,s*9.5/2) right -k*16,,dashwid/2) + dashline(right -k*9.5/2/2 up -s*9.5/2,,dashwid/3) + dashline(left -k*9.5/2/2 up -s*9.5/2,,dashwid/3) + dashline(left -k*16,,dashwid/2) + dashline(from Here+(-k*16,0) up s*9.5,,dashwid/2.5) } + { dashline(from Here+(0,s*11/2) right -k*36.5,,dashwid/2) + dashline(right -k*11/2/2 up -s*11/2,,dashwid/3) + dashline(left -k*11/2/2 up -s*11/2,,dashwid/3) + dashline(left -k*36.5,,dashwid/2) + dashline(from Here+(-k*36.5,0) up s*11,,dashwid/2.5) } + { dashline(from Here+(0,s*13/2) right -k*32,,dashwid/2) + dashline(down s*13,,dashwid/2) + dashline(left -k*32,,dashwid/2) } + ctrline(right -k*20 chop -3 chop 0); ctrline(right -k*20 chop 0 chop -3) + } + } + +dimension_thick +# bottom + dimension_(from (-305/2,-h) to (305/2,-h),-(rr*1.1-h),"305",20pt__) +# outer radii + r_dimen(from (-P1.x,P1.y) down 40*cosd(30) right 40*sind(30),0,40,,->) + r_dimen(from (P1.x,-P1.y)+(Rect_(40,120)) \ + down 40*cosd(30) right 40*sind(30),0,40,,<-) +# main diameter + r_dimen(from (Rect_(rr,180+50)) to (Rect_(rr,50)),,230,,,(Rect_(50,50))) +# inner circles + r_dimen(from (Rect_(d2/2,180+25)) to (Rect_(d2/2,25)),,204,,,(Rect_(25,25))) + r_dimen(from (Rect_(d3/2,180-12)) to (Rect_(d3/2,-12)),,140,,,(Rect_(25,-12))) + +# bolt hole placement diameter + r_dimen(from Orig to (Rect_(85,-43)),,``85$\,$R'',,->,(Rect_(20,-43))) +# left slot + r_dimen(from (-305/2+6,-25/2) up 25,0,25) + r_dimen(from (-305/2,-26) right 40,0,40) + line from last line.end to (last line.end.x,BX.s.y) chop -tic chop 0 + r_dimen(from (-305/2,26) right 25,0,25) + line from last line.end to (last line.end.x,BX.n.y) chop -tic chop 0 +# right slot + r_dimen(from (305/2-40,-32/2-10) right 40,0,40) + line from (305/2-40,-32/2) down 10+tic +# drill-holes + for i=1 to 4 do { + ctrarcr(Orig,85,atan2(D[i].y,D[i].x)-10*dtor_,atan2(D[i].y,D[i].x)+10*dtor_) + } + ctrarcr(Orig,85,atan2(D[4].y,D[4].x)+10*dtor_,atan2(D[4].y,D[4].x)+25*dtor_) + ctrline(up 30 at D[3]) + ctrline(up 30 at D[4]) + r_dimen(from D[3]+(0,-14) right 35,0,35) + r_dimen(from (0,D[3].y-14) right 35,0,35) + +# arrow <- down 30 left 30 from D[3] chop 16/2 chop 0 then left 5 +# "16 DRILL 23 CBORE" rjust "4 HOLES" rjust + +# arrow <- from (-305/2,30.6+10+2) up 5 left 5 then up 13 +# s_box(SEE (A)) with .sw at Here+(-5pt__,2pt__) + +command "}%" +.PE diff --git a/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Clocks.m4 b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Clocks.m4 new file mode 100644 index 00000000000..2c8cd097daf --- /dev/null +++ b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Clocks.m4 @@ -0,0 +1,229 @@ +.PS +# AntiqueClock.m4 +gen_init +NeedDpicTools +# https://tex.stackexchange.com/questions/236923/generate-analog-clock-with-numbered-face-add-seconds-roman-numerals + +# `hms2deg(hr,min,sec) hr:min:sec to degrees +# blank arg1: degrees for minute hand +# blank arg1 and arg2: degrees for second hand' +define(`hms2deg',`ifelse(`$1',, + `ifelse(`$2',, + `(90-pmod(ifelse(`$3',,0,`$3'),60)/60*360)', + `(90-(pmod(`$2',60)/60 + pmod(ifelse(`$3',,0,`$3'),60)/60/60)*360)')', + `(90-(pmod(`$1',12) + pmod(ifelse(`$2',,0,`$2'),60)/60 + dnl + pmod(ifelse(`$3',,0,`$3'),60)/3600)/12*360)')') + +# `SecondHand(length,hr,min,sec)' +define(`SecondHand',`[ shsf = (`$1')/3.2 + C: Here + { L: rpoint_(to (Rect_(`$1',hms2deg(,,`$4')))) } + line thick 8*shsf to rvec_(`$1',0) + ]') + +# `AntiqueMinuteHand(length,hr,min,sec)' +define(`AntiqueMinuteHand',`[ mhsf = (`$1')/2.84 + L: rpoint_(to (Rect_(`$1',hms2deg(,`$3',`$4')))) + C: circle fill_(0) diam 0.47*mhsf at L.start + move to C + spline from rvec_(0,0.047*mhsf) \ + to rvec_(1.65*mhsf,0.11*mhsf) \ + then to rvec_(`$1',0.018*mhsf) \ + then to rvec_(`$1',-0.018*mhsf) \ + then to rvec_(1.65*mhsf,-0.11*mhsf) \ + then to rvec_(0,-0.047*mhsf) \ + shaded rgbstring(0,0,0) + ]') + +# `AntiqueHourHand(length,hr,min,sec)' +define(`AntiqueHourHand',`[ hhsf = (`$1')/2.2 + L: rpoint_(to (Rect_(`$1',hms2deg(`$2',`$3',`$4')))) + C: circle fill_(0) diam 0.6*hhsf at L.start + move to C + v = 0.25*hhsf + { line to rvec_(1.1*hhsf,0) thick 0.15/(1bp__)*hhsf } + { C1: circle rad v at rvec_(1.25*hhsf,0) fill_(0) } + d = `$1'-1.25*hhsf + q = 1bp__*hhsf + r1 = (d^2 + q^2 - v^2)/(v-q)/2 + h = r1+v + shade(0, + arc ccw from C1+vec_(d/h*v,(r1+q)/h*v) to \ + C1+vec_(d,q) rad r1 with .c at C1+vec_(d,r1+q) + arc ccw from C1+vec_(d,-q) to C1+vec_(d/h*v,-(r1+q)/h*v) rad r1 \ + with .c at C1+vec_(d,-r1-q)) + ]') + +define(`AntiqueClock',`[ # h,m,s,diam +# Clock size parameters + # outer radius + hour = ifelse(`$1',,3,`$1') + minute = ifelse(`$2',,41,`$2') + second = ifelse(`$3',,51,`$3') + ifelse(`$4',,`skale=0.5; r1=2',`r1=(`$4')/2; skale=r1/4') + r2 = r1-0.5*skale + r3 = r2-0.14*skale + r4 = r3 - 0.35*skale + r5 = r4 - 0.17*skale + r6 = r5 - 0.63*skale + r7 = r6 - 0.17*skale + shadethick = 1.0 + +C: circle thick 0.2 rad r1 + +define shadeline { + s = 1-($`'1)*2 + v = r*s + h = sqrt(r^2-v^2) + t = 1-abs(s) + line from (vrot_(-h,v,cost,sint)) to (vrot_(h,v,cost,sint)) \ + thick shadethick outlined rgbstring(t,t,t) + } + + r = r1 # Bezel outer + nlines = int(2*r/(shadethick pt__)*1.1) + cost = cosd(10); sint = sind(10); + ShadeObject(shadeline,nlines, 0, 0,0,0, + 0.5, 1,1,1, + 1, 0,0,0 ) at C + + r = r2 # Bezel inner + nlines = int(2*r/(shadethick pt__)*1.1) + cost = cosd(-10); sint = sind(-10); + ShadeObject(shadeline,nlines, 0, 0,0,0, + 0.25, 0.8,0.8,0.8, + 0.5, 1,1,1, + 0.75, 0.8,0.8,0.8, + 1, 0,0,0 ) at C + +# Clock face +Face: circle thick 0 fill_(1) rad r3 at C + circle rad r4 at C + circle rad r5 at C + circle rad r6 at C + circle rad r7 at C + +define rotext { +sprintf("`$'1 ifpstricks(\rput[C]{%g}(0,0){%g}, +ifpgf(\rotatebox{%g}{%g}))",`$'2,`$'3) } +# Outer numbers + command sprintf("\font\outerfont=cmss12 at %4.2fin",r3-r4) + for mn = -15 to 15 by 5 do { rotext(\outerfont,-mn/60*360,pmod(mn,60)) \ + at C+(Rect_((r3+r4)/2,90-mn/60*360)) } + for mn = 20 to 40 by 5 do { rotext(\outerfont,180-mn/60*360,mn) \ + at C+(Rect_((r3+r4)/2,90-mn/60*360)) } +# Outer tics + for mn = 1 to 60 do { t = 90-mn/60*360 + line from C+(Rect_(r5,t)) to C+(Rect_(r4,t)) } + +# Inner numbers + command sprintf("\font\innerfont=cmss12 at %4.2fin",r5-r6) + Loopover_(`mx',`t = (m4Lx-4)/12*360; + sprintf("\innerfont`'ifpstricks(`\rput[C]{%g}(0,0)', + `\rotatebox{%g}'){\scalebox{0.7}[1.0]{mx}}",-t) \ + at C+(Rect_((r5+r6)/2,90-t))', IX,X,XI,XII,I,II,III) + Loopover_(`mx',`t = (m4Lx+3)/12*360; + sprintf("\innerfont`'ifpstricks(`\rput[C]{%g}(0,0)', + `\rotatebox{%g}'){\scalebox{.7}[1.0]{mx}}",-t+180) \ + at C+(Rect_((r5+r6)/2,90-t))', IV,V,VI,VII,VIII) +# Inner tics + for mn = 5 to 60 by 5 do { t = 90-mn/60*360 + line from C+(Rect_(r7,t)) to C+(Rect_(r6,t)) } + +# Hands + AntiqueHourHand(r6,hour,minute,second) with .C at C + AntiqueMinuteHand(r5,hour,minute,second) with .C at C + SecondHand((r3+r4)/2,hour,minute,second) with .C at C + +# Center + dot(at C,0.1/4*r1,1) + ]') + + Clock1: AntiqueClock +# Clock2: AntiqueClock(4,50,07,2) at Clock1.e+(1.5,0) + Clock2: AntiqueClock(4,50,07,2) with .nw at Clock1.ne+(0.5,0) + Clock3: [ + linethick = 1.5 + arrowwid = 5 pt__ + + rgbfill(255/255,250/255,205/255, + Clock: circle rad 0.75 at (0,0) ) + + command "\newcounter{hour}" + for time=1 to 12 do { + sprintf("\setcounter{hour}{%g}\Roman{hour}",time) \ + at Rect_(Clock.rad*0.85,90-time*30) + } + line <-> from Rect_(Clock.rad*0.95,90-8.5*30) to Clock \ + then to Rect_(Clock.rad*0.7,90-3.5*30) + line thick 1 outline "red" from Clock to Rect_(Clock.rad*0.95,90-0.75*30) + ] with .s at (Clock2,Clock1.s) + +define(`htod',`(90-(`$1')/12*360)') + +# clock1(h:m[:s],diam,color) +define(`ClockA',`[ + clockdiam = ifelse(`$2',,`40 mm__',`$2') + clockrad = clockdiam/2 + stacksplit_(`HMS',ifelse(`$1',,10:10,`$1'),:) + s = HMS; popdef(`HMS') + m = HMS; popdef(`HMS') + ifdef(`HMS',`h = HMS',`h = m; m = s') + C: circle rad clockrad thick 2 shaded ifelse(`$3',,"cyan",`$3') at (0,0) + for t = 1 to 12 do { + if pmod(t,3)==0 then { ticlen = clockrad/5; ticthk = 2 } \ + else { ticlen = clockrad/10; ticthk = 1 } + line thick ticthk from Rect_(clockrad,htod(t)) \ + to Rect_(clockrad-ticlen,htod(t)) + sprintf("\large\sf %g",t) at Rect_(clockrad*3.5/5,htod(t)) + } + line thick 3 from C to Rect_(clockrad*2/5,htod(h+m/60)) + line thick 3 from C to Rect_(clockrad*3/5,htod(m/60*12)) + round(at C, 3) + ifdef(`HMS',`line thick 0.7 outlined "red" from C \ + to Rect_(clockrad*3.5/5,htod(s/60*12)) chop -5bp__ chop 0') + popdef(`HMS') ]') + +[ +CA: ClockA(11:10:35,,"blue!20") + ClockA(10:10,,"blue!20!black!30") + ClockA(10:10:23,,"blue!20!black!30!green!40") + ClockA(10:10,,rgbstring(0.2,0.2,0.7)) + +# calls DrawRoutineName(frac,r,g,b) +# clock2(h:m[:s],diam,color,rim thickness) +define(`ClockB',`[ + clockdiam = ifelse(`$2',,`60 mm__',`$2') + clockrad = clockdiam/2 + stacksplit_(`HMS',ifelse(`$1',,10:10,`$1'),:) + s = HMS; popdef(`HMS') + m = HMS; popdef(`HMS') + ifdef(`HMS',`h = HMS',`h = m; m = s') + rimwd = ifelse(`$4',,9 pt__,`$4') + rimwid = rimwd/(1 pt__) + n = 4 +C: (0,0) + ClockA(`$1',clockdiam-rimwd*2,"green!20") at C +Q:circle diam clockdiam-rimwd thick rimwid \ + outlined rgbstring(0.7,0.7,0.7) at C + Nx: Q.n+(0,Q.thick pt__/2) + +define rimcirc { +#print sprintf("%g: %g,%g,%g",$`'1,$`'2,$`'3,$`'4) + circle diam clockdiam-rimwd thick rimwid/(n+1) \ + outlined rgbstring($`'2,$`'3,$`'4) with .n at Nx-(0,rimwd/(n+1)/2) + Nx : last circle.n+(0,last circle.thick pt__/2) } + + v = 0.1 + ShadeObject(rimcirc, n, + 0,v,v,v, + 1/(n-1),v,v,v, + 1,1,1,1) at C + popdef(`HMS') ]') + +# ClockA(10:10:35,,"green!20") + w = last [].wid + ClockB(10:10:35,w,) with .nw at CA.sw+(10bp__,-0.2) + ] with .nw at 1st [].sw+(0,-0.2) + +.PE diff --git a/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/ControlLoop.m4 b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/ControlLoop.m4 new file mode 100644 index 00000000000..6fd915401b4 --- /dev/null +++ b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/ControlLoop.m4 @@ -0,0 +1,40 @@ +.PS +# ControlLoop.m4 +# https://tex.stackexchange.com/questions/636839/how-to-draw-multi-blocks-block-diagram +gen_init +scale = 25.4 + + boxwid = 18 + boxrad = 3 + define summer { $1: circle diam 10 fill_(0.8) + { line from $1.ne to $1.sw; line from $1.nw to $1.se } + { "$+$" at $1.nw rjust } } + + TPG: box ht 22 shaded "Peach" "Transient" "Profile" "Generator" + arrow <- left_ 8 from TPG.w "r" above + arrow right_ 10 from TPG.e+(0,TPG.ht/4) "$r_1$" above + summer(S1) + line right_ 10 from TPG.e+(0,-TPG.ht/4) "$r_2$" above + arrow right_ S1.diam + summer(S2) + arrow right_ 10 from S2.e "$e_2$" above + arrow from S1.e to (Here,S1) "$e_1$" above + NLSF: box ht 22 "Nonlinear" "State Error" "Feedback" shaded "lime" \ + with .w at (Here,TPG) + arrow right_ 10 "$u_o$" below + summer(S3) + {ESO: box ht 30 shaded "Goldenrod" "Extended" "State" "Observer" \ + with .w at (Here.x+5,NLSF.s.y-15) } + arrow right_ 40 + P: box ht 15 shaded "blue!50!white!50" "Plant" + arrow right_ 10 "$y$" above + arrow <- right_ 10 from ESO.e+(0,-ESO.ht/4) "$y$" above + line to (2nd last arrow,Here) then to 2nd last arrow + arrow <- right_ 10 from ESO.e+(0,ESO.ht/4) "$u$" above; corner + line to (Here,P) + for_(1,3,1, + `arrow from ESO.w+(0,ESO.ht*(m4x-2)/3) left_ ESO.w.x-S`'m4x.x then to S`'m4x.s + "$z_`'m4x$" at last arrow.start-(5,0) above + "$-$" at last arrow.end rjust below ') + +.PE diff --git a/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Counting.m4 b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Counting.m4 new file mode 100644 index 00000000000..18002ba99ff --- /dev/null +++ b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Counting.m4 @@ -0,0 +1,26 @@ +.PS +# Counting.m4 +gen_init + + g = 0.4 # grid size + define grid { (($2)*g,-($1)*g) } + circlerad = 0.1 + +for i=1 to 4 do { + sprintf(`"$S_%g$:"',i) ljust at grid(i,-0.5) + for j=1 to 4 do { if i+j < 8 then { + sprintf(`"$s_{%g%g}$"',i,j) at grid(i,j) } } } + +"$\vdots$" at grid(4.75,0) +for i=1 to 3 do { `"$\cdots$"' at grid(i,5) } +"$\cdots$" at grid(4,4) + +P: grid(1,1) +for k=3 to 5 do { + for i=1 to k-1 do { if (k%2==1) then { m=i; n=k-i } else { m=k-i; n=i } + Q: grid(m,n) + arrow from P to Q chop + P: Q } + } + +.PE diff --git a/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Cruller.m4 b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Cruller.m4 new file mode 100644 index 00000000000..d2c215ae133 --- /dev/null +++ b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Cruller.m4 @@ -0,0 +1,67 @@ +.PS +# Cruller.m4 +threeD_init +NeedDpicTools +scale = 2.54 + +define(`lobe',`(sind(6*(`$1'))+4)/5*2.25') + + viewazimuth = 20 # Set view angles in degrees + viewelevation = 30 + setview(viewazimuth,viewelevation,0) + + dt = 3 # major angle degrees per facet + ds = 10 # minor angle degrees per facet + + tradius = 6 +define(`cruller',`rot3Dz((`$1')*dtor_, + sum3D(0,tradius,0,0,Rect_(lobe(`$2'+2*(`$1')),`$2')))') + +define(`tvisible',`dot3D(View3D, + cross3D(diff3D(cruller(`$1'+dt/2,`$2'),cruller(`$1',`$2')), + diff3D(cruller(`$1',`$2'+ds/2),cruller(`$1',`$2'))))') + + # create the arrays and sort + n = 0 + for t = dt to 360+dt/2 by dt do { + for s=ds/2 to 360.1 by ds do { + if tvisible(t,s) > -0.01 then { + n +=1 + t[n] = t + s[n] = s + d[n] = dot3D(cruller(t,s),view3D1,view3D2,view3D3) # view distance + ix[n] = n + } + } } +# prval(n) + dpquicksort(d,1,n,ix) + + # Background +Bne: (9,6) +Bsw: (-9,-6) +B: 0.5 between Bne and Bsw +iflatex(`line fill_(0.75) \ + from (Bsw,Bne) to Bsw then to (Bne,Bsw) then to Bne then to (Bsw,Bne)', + `ShadedPolygon((Bsw,Bne):Bsw:(Bne,Bsw):Bne,,-30, + 0,1,1,1, + .5,.1,.4,0, + 1,0,0,0) at B') + # draw the facets +thinlines_ +[ + rgbtohsv(0.6,0.4,0,h,s,v) + for i = 1 to n do { + tc = t[ix[i]]; sc = s[ix[i]] + SE: (Project(cruller(tc+dt/2,sc-ds/2))) + SW: (Project(cruller(tc-dt/2,sc-ds/2))) + NW: (Project(cruller(tc-dt/2,sc+ds/2))) + NE: (Project(cruller(tc+dt/2,sc+ds/2))) + f = ((dcosine3D(3,cruller(tc,sc))/2.25+1)/2)^2 + hsvtorgb(h,(1-f)*s,1,r,g,b) + line outlined rgbstring(r,g,b) shaded rgbstring(r,g,b) ifpdf( invis ) \ + from SE to SW then to NW then to NE then to SE } + ] at B + +thicklines_ + +.PE diff --git a/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Cylinder.m4 b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Cylinder.m4 new file mode 100644 index 00000000000..abe9a9bac7a --- /dev/null +++ b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Cylinder.m4 @@ -0,0 +1,43 @@ +.PS +# Cylinder.m4 +gen_init(SIdefaults) # lengths are in mm + +define(`cylinder',`[ angle = ifelse(`$3',,20,`$3') + w = ifelse(`$1',,boxwid,`$1') + h = ifelse(`$2',,boxht,`$2') + B: ellipse wid w ht sind(angle)*w + S: box invis wid w ht h fill_(1) with .s at B + line from S.nw to S.sw + line from S.ne to S.se + T: ellipse wid w ht sind(angle)*w at B+(0,h) + ]') + +define Cylinder { [ dtor = atan2(1,0)/90 + if "$1"=="" then { w = boxwid } else { w = $1 } + if "$2"=="" then { h = boxht } else { h = $2 } + if "$3"=="" then { angle = 20 } else { angle = $3 } + B: ellipse wid w ht sin(angle*dtor)*w + S: box invis wid w ht h fill 1 with .s at B + line from S.nw to S.sw + line from S.ne to S.se + T: ellipse wid w ht sin(angle*dtor)*w at B+(0,h) + ] } + +M4: [ + cylinder + move + cylinder(,,15) + move + cylinder(3,50) + ] +"M4 macro" at last [].s below + +Pic: [ + Cylinder + move + Cylinder(,,15) + move + Cylinder(3,50) + ] with .w at M4.e+(5,0) +"pic macro" at last [].s below +.PE diff --git a/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Egg.m4 b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Egg.m4 new file mode 100644 index 00000000000..3cab249877e --- /dev/null +++ b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Egg.m4 @@ -0,0 +1,42 @@ +.PS +# Egg.m4 +# https://tex.stackexchange.com/questions/74168/how-can-i-draw-an-egg-using-tikz +threeD_init +NeedDpicTools + +define Eggshape { (0.78*cos(($2)/4)*sin($2),-cos($2))*($1) } # -pi < arg2 < pi + + size = 2 + npts = 41 + + HL: Eggshape(size*0.4,-pi_*3/4) # Highlight + P: Eggshape(size,pi_/4) + d = zabs(P) + nlines = int(d/lthick*1.5) + # This way of blending colors is not the + # simplest for a single postprocessor but it + # works for multiple postprocessors, e.g. SVG +define(`Orange',`1, 0.5, 0') +define(`Gray', `0.5, 0.5, 0.5') +define(`White', `1, 1, 1') +define(`eggblend', + `sum3D(sprod3D($1,Orange), + sum3D(sprod3D($2,White), + sprod3D($3,Gray)))') + +define(`normalize',`($1)/($1+$2+$3), ($2)/($1+$2+$3), ($3)/($1+$2+$3)') + +define EggLine { + for i=0 to npts do { + P[i]: HL*(1-($1))+Eggshape(size*($1),i/npts*twopi_-pi_) } + fitcurve(P,npts,outlined rgbstring($2,$3,$4)) + } + + ShadeObject(EggLine, nlines, + 0, eggblend(normalize(0.3, 1, 0)), + 0.2, eggblend(normalize(0.5, 0.5, 0)), + 0.5, eggblend(normalize(0.5, 0.4, 0.2)), + 1, eggblend(normalize(0.5, 0, 0.7)) + ) + +.PE diff --git a/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Euro.m4 b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Euro.m4 new file mode 100644 index 00000000000..26230facbe7 --- /dev/null +++ b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Euro.m4 @@ -0,0 +1,128 @@ +.PS +#Euro.m4 +gen_init +divert(-1) + `euro_simple([height]) + Basic euro symbol with round outer boundary + default height=10pt' +define(`euro_simple', +`[ linethick = 0 + orad = ifelse(`$1',,`5bp__',(`$1')/2) + u = orad/6 + irad = orad - u + C: (0,0) + D: C+(Rect_(irad,40)) + CD: move from C+(0,-orad) to D + DK: move from D down u + Ubot: move from C+(0,u/2) right u + Utop: move from Ubot.start+(0,u) right u + Ltop: move from C+(0,-u/2) right u + Lbot: move from Ltop.start+(0,-u) right u + L_edge: C-(7.5*u,0) + Start: (C,Utop) + slope = (CD.end.y-CD.start.y)/(CD.end.x-CD.start.x) +shade(0, + line from Start to Intersect_(Utop,CD) \ + then to Intersect_(Ubot,CD) \ + then to LCintersect(Ubot,C,irad) + arc to LCintersect(Ltop,C,irad) with .c at C + line to Intersect_(Ltop,CD) \ + then to Intersect_(Lbot,CD) \ + then to LCintersect(Lbot,C,irad) + arc to (D,C)-(0,D.y-C.y) with .c at C + line to LCintersect(DK,C,orad,R) + arc cw to LCintersect(Lbot,C,orad) with .c at C + line to (L_edge,Here) \ + then right u/slope up u \ + then to LCintersect(Ltop,C,orad) + arc cw to LCintersect(Ubot,C,orad) with .c at C + line to (L_edge,Here) \ + then right u/slope up u \ + then to LCintersect(Utop,C,orad) + arc cw to LCintersect(CD,C,orad,R) with .c at C + line to D + arc to LCintersect(Utop,C,irad) with .c at C + line to Start + ) ]') + + `euro_symbol([ht=val; aspect=val; slant=degrees]) + Euro symbol with variable aspect ratio and slant + defaults: ht=10pt, aspect=1, slant=0 + e.g., euro_symbol(ht=14pt__; aspect=1.2)' + +define(`euro_symbol',`[ + setkey_(`$1',ht,10pt__) setkey_(`$1',aspect,1) setkey_(`$1',slant,0) + linethick = 0 + orad = m4ht/2 + u = orad/6 + irad = orad - u + if m4aspect==0 then { squeeze = 1 } else { squeeze = 1/m4aspect } + slant = sind(m4slant) + C: (0,0) + D: C+(Rect_(irad,40)) + CD: move from C+(0,-orad) to D + DK: move from D down u + Ubot: move from C+(0,u/2) right u + Utop: move from Ubot.start+(0,u) right u + Ltop: move from C+(0,-u/2) right u + Lbot: move from Ltop.start+(0,-u) right u + L_edge: C-(7.5*u,0) + Start: (C,Utop) + slope = (CD.end.y-CD.start.y)/(CD.end.x-CD.start.x) + +shade(0, + S: LCintersect(Ubot,C,irad) + line from euro_tr(Start) to euro_tr(Intersect_(Utop,CD)) \ + then to euro_tr(Intersect_(Ubot,CD)) \ + then to euro_tr(S) + euro_arc(S,LCintersect(Ltop,C,irad),irad) + S: LCintersect(Lbot,C,irad) + line to euro_tr(Intersect_(Ltop,CD)) \ + then to euro_tr(Intersect_(Lbot,CD)) \ + then to euro_tr(S) + euro_arc(S,((D,C)-(0,D.y-C.y)),irad) + S: LCintersect(DK,C,orad,R) + line to euro_tr(S) + euro_arc(S,LCintersect(Lbot,C,orad),orad,cw) + S: LCintersect(Ltop,C,orad) + E: LCintersect(Lbot,C,orad) + line to euro_tr((L_edge,E)) \ + then to euro_tr((L_edge,E)+(u/slope,u)) \ + then to euro_tr(S) + E: LCintersect(Ubot,C,orad) + euro_arc(S,E,orad,cw) + S: LCintersect(Utop,C,orad) + line to euro_tr((L_edge,E)) \ + then to euro_tr((L_edge,E)+(u/slope,u)) \ + then to euro_tr(S) + euro_arc(S,LCintersect(CD,C,orad,R),orad,cw) + line to euro_tr(D) + euro_arc(D,LCintersect(Utop,C,irad),irad) + line to euro_tr(Start) +) ]') + + `aspect ratio and slant transformation' +define(`euro_tr',`((`$1').x*squeeze+(`$1').y*slant,(`$1').y)') + `transformed arc, centre C' +define(`euro_arc', +`M4X: `$1'; as = atan2(M4X.y-C.y,M4X.x-C.x) + M4X: `$2'; ae = atan2(M4X.y-C.y,M4X.x-C.x) + ifelse(`$4',cw,`if ae > as then { ae -= twopi_ }', + `if ae < as then { ae += twopi_ }') + ax = ae-as + n = max(5,ceiling_(abs(ax)/(10*dtor_))) + for i=0 to n do { P[i]: euro_tr((rect_(`$3',as+i/n*ax))) } + fitcurve(P,n) + move to P[n] ') + +divert(0)dnl + +euro_simple +move +euro_symbol(slant=15) +move +euro_simple(72bp__) +move +euro_symbol(ht=72bp__*2; aspect=1.0; slant=15) + +.PE diff --git a/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Eye.m4 b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Eye.m4 new file mode 100644 index 00000000000..1251afca095 --- /dev/null +++ b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Eye.m4 @@ -0,0 +1,61 @@ +.PS +# Eye.m4 +# https://getpocket.com/explore/item/pillars-of-fire-truly-adventurous?utm_source=pocket-newtab +gen_init + +define(`eye',`[ u = `$1'; v = 0.47*u; w = 0.25*u +# for pdf, linethick in shade must be environment + lth = linethick; linethick = 0 + shade(1, + arc outlined "red" from (u/2,0) to (-u/2,0) with .c at (0,-u/3) + arc to (u/2,0) with .c at (0,u/3) ) + linethick = lth + circle diam v fill_(0.25) at (0,0) + circle diam w fill_(0) at (0,0) + circle thick 0 diam last circle.diam/2 fill_(1) at last circle.nw + circle diam last circle.diam-lthick at last circle outlined graystring(0.9) + ] ') + + skale = 2/3 + Bx: box wid 11*skale ht 8.5*skale fill_(0) at (0,0) + ane = atan2(Bx.ht,Bx.wid)*rtod_ + d[5] = 0.92*Bx.ht + d[4] = 0.78*Bx.ht + d[3] = 0.62*Bx.ht + d[2] = 0.40*Bx.ht + d[1] = 0.25*Bx.ht + da = 1 + dax = 360/64 + C[0]: Bx.se; C[1]: Bx.nw + for a=-int(ane/dax)*dax to 180-ane by dax do { + T1: (Rect_(1,a+da)); T1: intersect_(Bx.ne,C[(a>ane)],Bx,T1) + T2: (Rect_(1,a)); T2: intersect_(Bx.ne,C[(a>ane)],Bx,T2) + line outlined "white" shaded "white" from Bx to T1 then to T2 then to Bx + line outlined "white" shaded "white" from Bx to T1*(-1) \ + then to T2*(-1) then to Bx + } + for i=5 to 2 by -1 do { + C[i]: circle diam d[i] fill_(0) at Bx + for a=0 to 359 by dax do { + T1: (Rect_(d[i]/2,a)) + T2: (Rect_(d[i]/2,a-da*2)) + lth = linethick; linethick = 0 + shade(1, + arc cw from T1 to T2 with .c at Bx + spline 0.55 thick 0 to 0.8 between Bx and T2 \ + then to (Rect_(d[i]/4,a+30)) + arc cw to (Rect_(d[i]/4,a+32)) with .c at Bx + spline 0.55 thick 0 to 0.8 between Bx and T1 then to T1 ) + linethick = lth + } + } + C[1]: circle thick 2 diam d[1] at Bx fill_(0.1) + eye(d[1]-4bp__) at (0,0) + for a=0 to 359 by dax do { + T1: (Rect_(d[1]/2-1bp__,a)) + T2: (Rect_(d[1]/2-1bp__,a+dax/2)) + line thick 0 from T1 to T2 then to 0.5 between Bx and T2 \ + then to 0.5 between Bx and T1 then to T1 shaded "white" #outlined "white" + } + +.PE diff --git a/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Fefets.m4 b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Fefets.m4 new file mode 100644 index 00000000000..04d624de356 --- /dev/null +++ b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Fefets.m4 @@ -0,0 +1,75 @@ +.PS +# https://github.com/circuitikz/circuitikz/issues/515 +# `Fefets.m4' +cct_init + +textht = 0.1 +define(`rmove',0.75) + +Row1: [ + J: Fe_fet(right_ dimen_) + {`"{\tt $\;$ Fe\_fet}"' at J.s+(0,-0.05) below + "$G$" at J.G rjust + "$S$" at J.S rjust + "$D$" at J.D ljust } + move right_ + J: Fe_fet(up_ dimen_) + {`"{\tt (up\_ dimen\_)}"' at J.s+(0,-0.15) below + "$G$" at J.G rjust + "$S$" at J.S rjust + "$D$" at J.D ljust } + move right_ + J: Fe_fet(left_ dimen_) + {`"{\tt (left\_ dimen\_)}"' at J.s+(0,-0.05) below + "$G$" at J.G rjust + "$S$" at J.S ljust + "$D$" at J.D rjust } + move right_ + J: Fe_fet(down_ dimen_) + {`"{\tt (down\_ dimen\_)}"' at J.s+(0,-0.15) below + "$G$" at J.G ljust + "$S$" at J.S rjust + "$D$" at J.D ljust } + ] +Row2: [ + J: Fe_fet(right_ dimen_,R) + {`"{\tt $\;$ Fe\_fet}"' at J.s+(0,-0.05) below + "$G$" at J.G rjust + "$S$" at J.S rjust + "$D$" at J.D ljust } + move right_ + J: Fe_fet(up_ dimen_,R) + {`"{\tt (up\_ dimen\_,R)}"' at J.s+(0,-0.15) below + "$G$" at J.G ljust + "$S$" at J.S rjust + "$D$" at J.D ljust } + move right_ + J: Fe_fet(left_ dimen_,R) + {`"{\tt (left\_ dimen\_,R)}"' at J.s+(0,-0.05) below + "$G$" at J.G rjust + "$S$" at J.S ljust + "$D$" at J.D rjust } + move right_ + J: Fe_fet(down_ dimen_,R) + {`"{\tt (down\_ dimen\_,R)}"' at J.s+(0,-0.15) below + "$G$" at J.G rjust + "$S$" at J.S rjust + "$D$" at J.D ljust } + ] with .nw at last [].sw+(0,-0.5) +Row3: [ + J: Fe_fet(right_ dimen_) + {`"{\tt $\;$ Fe\_fet}"' at J.s+(0,-0.05) below + "$G$" at J.G rjust + "$S$" at J.S rjust + "$D$" at J.D ljust } + move right_ + J: Fe_fet(right_ dimen_,,TEDQSuB) + {`"{\tt $\;$ Fe\_fet(,,TEDSQuB)}"' at J.s+(0,-0.15) below + "$G$" at J.G rjust + "$S$" at J.S rjust + "$D$" at J.D ljust } + ] with .nw at last [].sw+(0,-0.5) +#Row4: [ +# ] with .nw at last [].sw+(0,-0.5) + +.PE diff --git a/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/FieldLines.m4 b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/FieldLines.m4 new file mode 100644 index 00000000000..0832e20d92a --- /dev/null +++ b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/FieldLines.m4 @@ -0,0 +1,24 @@ +.PS +# https://tex.stackexchange.com/questions/593866/magnetic-field-with-2-coils +cct_init(SIdefaults) + + setdir_(R) + W1: winding(,20,5,8,10) + line dn_ 10 from W1.T1; dot(,,1) + line dn_ 10 from W1.T2; dot(,,1) + W2: winding(,20,5,8,10) with .w_ at W1.e_+vec_(10,0) + line dn_ 10 from W2.T1; dot(,,1) + line dn_ 10 from W2.T2; dot(,,1) + for i=2 to -2 by -1 do { + spline 0.55 \ + from W2.e_+vec_(30,10/4*i*3) \ + to W2.e_+vec_(25,10/4*i*2) \ + then to W2.e_+vec_(0,10/4*i) \ + then to W1.w_+vec_(0,10/4*i) \ + then to W1.w_+vec_(-25,10/4*i*2) \ + then to W1.w_+vec_(-30,10/4*i*3) + arrow wid 2 ht 2 dn_ i*0.66 rt_ 2 at W1.w_+vec_(-25,10/4*i*2.35) + arrow wid 2 ht 2 up__ i*0.66 rt_ 2 at W2.e_+vec_(25,10/4*i*2.35) + } + +.PE diff --git a/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Floor.m4 b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Floor.m4 new file mode 100644 index 00000000000..0f3076174a3 --- /dev/null +++ b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Floor.m4 @@ -0,0 +1,25 @@ +.PS +# Floor.m4 +gen_init + s = 0.25 + s60 = s*sqrt(3)/2 + c60 = s/2 + ni = 9 + nj = 6 + cellw = 3*s + cellh = 2*s60 + B:box wid nj*cellw ht ni*cellh shaded rgbstring(0,1,0) + + for i=1 to ni do { + for j=1 to nj do { + line shaded rgbstring(0,0,1) \ + from B.sw+((j-1)*cellw,(i-1)*cellh) \ + right c60 up s60 then right 2*s then up s60 right c60 then left s \ + then down cellh left 2*c60 then left s + line shaded rgbstring(1,0,0) \ + from B.sw+((j-1)*cellw,i*cellh) \ + right s then down cellh right 2*c60 then right s then up s60 left c60 \ + then left 2*s then left c60 up s60 + } + } +.PE diff --git a/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Flow2.m4 b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Flow2.m4 new file mode 100644 index 00000000000..6f8e2affbf4 --- /dev/null +++ b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Flow2.m4 @@ -0,0 +1,47 @@ +.PS +# https://tex.stackexchange.com/questions/661461/flowchart-with-overlapping-of-the-rows +sinclude(FlowchartDefs.m4def) +sinclude(../FlowchartDefs.m4def) + +down_ + smallsep = boxht/3 + testw = fboxwid*7/4 + testh = fboxht*9/4 + Start: Fbox("Start",,rad boxht/8 shaded "red!30") + arrow down_ smallsep "False" ljust + Input: Fdata(`"Input: $f(), a, b, \epsilon$"',wid boxwid*5/4,, + shaded "blue!30") + arrow down_ smallsep + Formula1: Fbox(`"$c=(a+b)/2$"',,shaded "orange!30") + arrow down_ smallsep + Test1: Ftest("if:" `"$f(a)*f(b) > 0$" "\vphantom{\vrule height6pt}"', + wid testw ht testh, shaded "green!30") + A2: arrow down_ smallsep "False" ljust + Test2: Ftest("while:" `"$f(c)\neq 0 \;\&$" "$|f(b)-f(a)| > \delta$" \ + "\vphantom{\vrule height6pt}"',wid testw ht testh, shaded "green!30") + arrow down_ smallsep "True" ljust + Formula2: Fbox(`"$c=(a+b)/2$"',,shaded "orange!30") + arrow down_ smallsep + Test3: Ftest("if:" `"$f(a)*f(c) < 0$" "\vphantom{\vrule height6pt}"', + wid testw ht testh, shaded "green!30") + { arrow from Test3.W left_ boxht*2/3 "True" below + Formula3: Fbox(`"$b=c$"',,shaded "orange!30") + arrow from Formula3.N to (Formula3.N,A2) } + arrow down_ smallsep "False" ljust then left Test3.x-Formula3.E.x + Formula4: Fbox(`"$a=c$"',,shaded "orange!30") with .E at Here + { arrow from Formula4.W left_ Formula4.W.x-Formula3.W.x + smallsep \ + then up_ A2.y-Formula4.y then to A2 } + down_ + Output: Fdata(`"Output: $H, v, t$"',wid boxwid*5/4,,shaded "blue!30") \ + with .N at (Test1.E+(3*smallsep,0),Formula4.N) + { arrow from Test1.E right_ Output.N.x-Test1.E.x "True" above \ + then to Output.N + arrow from Test2.E right_ Output.N.x-Test1.E.x "False" above } + arrow down_ smallsep + Plot: Fbox(,wid boxwid*5/4,shaded "orange!30") + { ["Plot:" ljust "H on T and V on T" ljust] with .w at Plot.W+(3bp__,0) } + arrow down_ smallsep + Stop: Fbox("Stop",,rad boxht/8 shaded "red!30") + + +.PE diff --git a/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Hexagon.m4 b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Hexagon.m4 new file mode 100644 index 00000000000..c70e865be36 --- /dev/null +++ b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Hexagon.m4 @@ -0,0 +1,64 @@ +.PS +# Hexagon.m4 +# https://tex.stackexchange.com/questions/640000/how-to-draw-hexagonal-lattice-with-links-and-string-using-latex?noredirect=1&lq=1 +gen_init + scale = 4 + circlerad = 1/4 + s3 = sqrt(3) + +define cline { line $1 + { if "$2"=="" then { circle thick 0.8 at last line fill_(1) } \ + else { circle thick 0.8 at last line $2 } } } + +define topline { + cline(from $1 up s3 right 1) + cline(right 2) + cline(down s3 right 1) + } + +define botline { + cline(from $1 down s3 right 1) + cline(right 2) + cline(up s3 right 1) + cline(right 2) + } + +define hexagon { line $2 from $1 \ + for_(1,6,1,`to $1+(2,0)+(Rect_(2,180-m4x*60)) \') + move to $1 + (2,0) + for i=1 to 6 do {{circle $3 at Here+(Rect_(s3,210-i*60))}} + if "$4"!="" then {$4 at $1+(2,0)} + } + + + nrows = 4 + ncols = 3 +for i=1 to nrows do { + for j=1 to ncols do { topline((3+(j-1)*6,-s3*(2*i-1))) + topline((0+(j-1)*6,-s3*2*i)) } + cline(from (6*ncols,-2*i*s3) up s3 right 1) + if i != nrows then { cline(from (0,-2*i*s3) down s3 right 1) } \ + else { for j=1 to ncols do { botline(((j-1)*6,-2*nrows*s3)) } } + } + linethick = 2 + cline(from (3,-s3) outlined "red" down_ s3 right_ 1,fill_(0)) + { "$\sigma^x$" at last circle.w rjust } + { "\large $I$" above ljust } + { cline(right_ 2 outlined "red",fill_(0)) + { "$\sigma^x$" at last circle.n above ljust } } + cline(left_ 1 down_ s3 outlined "red",fill_(0)) + { "$\sigma^x$" at last circle.e ljust } + + hexagon((12,-4*s3),thick 2 outlined "blue",shaded "white",) + for a=90 to 360 by 180 do {{ + "\large $\sigma^x\!{=}{-}1$" at (14,-4*s3)+(Rect_(2.25,a)) }} + for a=30 to 360 by 180 do {{ + "\large $\sigma^x\!{=}{-}1$" at (14,-4*s3)+(Rect_(2.75,a)) }} + for a=150 to 360 by 180 do {{ + "\large $\sigma^x\!{=}{-}1$" at (14,-4*s3)+(Rect_(2.75,a)) }} + hexagon(( 3,-7*s3),thick 2 outlined "red" shaded "gray",shaded "black", + "\large $p$") + for a=30 to 360 by 60 do {{ + "\large $\sigma^z$" at (5,-7*s3)+(Rect_(2.5,a)) }} + +.PE diff --git a/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Highgain.m4 b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Highgain.m4 new file mode 100644 index 00000000000..06bc62985ee --- /dev/null +++ b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Highgain.m4 @@ -0,0 +1,80 @@ +.PS +# Highgain+.m4 +sinclude(tst.dim) +s_init(Highgain) +darrow_init + +fillval = 0.8 +circlerad = 0.35/2 +linewid = linewid*3/4 + +command " +\newcommand{\Ds}{D(s)} +\newcommand{\Gs}{G(s)} +\newcommand{\Hs}{H(s)} +\newcommand{\Ms}{M(s)} +\newcommand{\Ns}{N(s)} +\newcommand{\Ps}{P(s)} +\newcommand{\Qs}{Q(s)} +\newcommand{\Rs}{R(s)} +\newcommand{\Ss}{S(s)} +\newcommand{\Us}{U(s)} +\newcommand{\Ys}{Y(s)} +\newcommand{\Xs}{X(s)} +\newcommand {\mat}[1]{\left[\matrix{#1}\right]} +\newcommand {\adj}{\mathop{\hbox{adj}}\nolimits} +\newcommand {\coldim}{\mathop{\hbox{col dim}}\nolimits} +\newcommand {\colrank}{\mathop{\hbox{column rank}}\nolimits} +\newcommand {\column}{\mathop{\hbox{column}}\nolimits} +\newcommand {\diag}{\mathop{\hbox{diag}}\nolimits} +\newcommand {\trace}{\mathop{\hbox{trace}}\nolimits} +\newcommand {\image}{\mathop{\hbox{image}}\nolimits} +\newcommand {\kernel}{\mathop{\hbox{kernel}}\nolimits} +\newcommand {\opsim}[1]{\mathinner{\raise-.5ex\hbox{\scriptsize #1}\atop% + \raise1.5ex\hbox{$\sim$}}} +\newcommand {\order}{\mathop{\hbox{order}}\nolimits} +\newcommand {\rank}{\mathop{\hbox{rank}}\nolimits} +\newcommand {\rowdim}{\mathop{\hbox{row dim}}\nolimits} +\newcommand {\rowimage}{\mathop{\hbox{row image}}\nolimits} +\newcommand {\row}{\mathop{\hbox{row}}\nolimits} +\newcommand {\rowrank}{\mathop{\hbox{row rank}}\nolimits} +\newcommand {\zeros}{\mathop{\hbox{zeros}}\nolimits} +" + +define(`vectorsize', + `{"$\phantom{\displaystyle `$1'}% + \atop{{\displaystyle /}\atop{\displaystyle `$1'}}$"\ + `$2' }') + +[ +R: darrow(right linewid,,,,,,|-) + { s_box($R$) dabove(at R.start+(5pt__,0)) } +Sum: circle invis "$\sum$" + darrow(right_ linewid*5/4) + { s_box($E$) dabove(at last line) } + vectorsize(p,at 1/4 along_(last line)) +Gain: shadebox(box "$G = \diag\mat{g_i}$" wid boxwid*1.5 ht boxht*0.75 ) + darrow(,,,,,,!-) + { s_box($U^{\prime}$) dabove(at last line) } +Compensator: shadebox(box wid boxwid*1.5 "\sl Compensator" "$K(s)$") + darrow(right_ linewid*5/4,,,,,,!-) + vectorsize(m,at 1/4 along_(last line)) + { s_box($U$) dabove(at last line) } +Plant: shadebox(box "\sl Plant" "$H(s)$" ) + dline(right_ linewid*3/4 from Plant.e,,,,!-) + vectorsize(p,at last line) +Y: dtee(R) + {s_box($Y$) dabove} + darrow(right_ linewid*2/3,t) + + dline(down boxht from Y,t) + dright + dline(to (Sum,Here),,t) + dright + darrow(to Sum.s) + "$-$" at Here+(0.10,-0.05) + + circle at Sum +] +# blockbox(N) +.PE diff --git a/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/IC10107.m4 b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/IC10107.m4 new file mode 100644 index 00000000000..5203f67376f --- /dev/null +++ b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/IC10107.m4 @@ -0,0 +1,48 @@ +.PS +# IC10107.m4 + log_init + +right_ + pinlen = 2*NOT_rad + hunit = AND_wd*L_unit*1.6 +B: box invis wid hunit*4 ht hunit*2 + psep = hunit/2 + nrad = B.ht*0.06 + line from B.w+(0,nrad) to B.nw then to B.ne then to B.se then to B.sw \ + then to B.w-(0,nrad) + arc ccw to Here+(0,2*nrad) with .c at B.w + for i = 1 to 8 do { + line down pinlen from B.sw+(psep/2,0)+((i-1)*psep,0) + sprintf("\small\sf%g",i) below + exec sprintf("P%g: last line.start",i) + line up pinlen from B.ne-(psep/2,0)-((i-1)*psep,0) + sprintf("\small\sf%g",8+i) above + exec sprintf("P%g: last line.start",8+i) + } +G1: OR_gen(2,PIBANEONSEC) with .Out at P12.x-pinlen,B.y+B.ht/4 +G2: OR_gen(2,PIBANNEOSEC) with .Out at B.e.x-4*pinlen,B.y + left_ +G3: OR_gen(2,PIBANEONSEC) with .NE at P3.x,B.y-B.ht/4-AND_ht/6*L_unit + + line from G3.N_NSE.w to (P2,G3.N_NSE) then to P2 + line from P3 to G3.NE + line right pinlen from G3.In1 then down 2*pinlen + contline to (P4,Here) then to P4 + line from G3.In2 to (P5,G3.In2) then to P5 + + line from G2.In2 left pinlen then down 2*pinlen + contline to (P9,Here) then to P9 + line from G2.In1 left pinlen*2 then down G2.In1.y-G2.In2.y+3*pinlen + contline to (P7,Here) then to P7 + line from G2.SE right NOT_rad+2*pinlen then up B.n.y-pinlen-G2.SE.y + contline to (P10,Here) then to P10 + line from G2.N_NNE.e right pinlen then up B.n.y-2*pinlen-G2.N_NNE.y + contline to (P11,Here) then to P11 + + line from P12 to (P12,G1.N_NSE) then to G1.N_NSE.e + line from P13 down pinlen + contline to (G1.NE,Here) then to G1.NE + line from G1.In1 to (P14,G1.In1) then to P14 + line from G1.In2 to (P15,G1.In2) then to P15 + +.PE diff --git a/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Koch.m4 b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Koch.m4 new file mode 100644 index 00000000000..faa46dfff8e --- /dev/null +++ b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Koch.m4 @@ -0,0 +1,32 @@ +.PS +# Koch snowflake +gen_init + + leng = 4 + X: 3,5 + nsides = 3; rot[1] = 0; rot[2] = -120; rot[3] = -120 + depth=4 + + for i=1 to depth do { + for j=1 to nsides do { tmp[j] = rot[j] } + leng = leng/3 + k = 0 + for j=1 to nsides do { + rot[k+1] = tmp[j] + rot[k+2] = 60 + rot[k+3] = -120 + rot[k+4] = 60 + k += 4 + } + nsides = k + } + + a = 0 + line from X to X + for i=1 to nsides do { + a += rot[i] + X: X+(Rect_(leng,a)) + continue to X + } + +.PE diff --git a/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Lyap.m4 b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Lyap.m4 new file mode 100644 index 00000000000..e01d365fc02 --- /dev/null +++ b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Lyap.m4 @@ -0,0 +1,160 @@ +.PS +# Lyap.m4 +threeD_init +scale = 1/1.2 + +viewaz = 30 +viewel = 18 +setview(viewaz,viewel) + +Origin: Project(0,0,0) +# Components of view vector W +w1 = view3D1 +w2 = view3D2 +w3 = view3D3 +# Shape factor of the ellipse on the xy plane +q = Cos(40) + +# cost function +h = 0.5 +c = 1 +# The projected ellipse is (x/q)^2 + y^2 = c. +# The cost is v = c+h +define(`vs',`(`$2')*q*cos(`$1'),(`$2')*sin(`$1')') +define(`vp',`vs(`$1',`$2'),0') +define(`vx',`sum3D(vp(`$1',`$2'),0,0,h+(`$2')^2)') + +# The gradient of v is (2x/q, 2y, -1) and the line +# separating front and back is W^T * grad(v) = 0 +# This line intersects the projected ellipse at +# x1,y1 and x2,y2 + ap = w2^2*q^2/w1^2+1 + bp = -w2*w3*q^2/w1^2 + cp = w3^2*q^2/4/w1^2-c + m = sqrt(bp^2-4*ap*cp) + y1 = (-bp+m)/ap/2 ; x1 = (w3-2*y1*w2)*q/2/w1 + y2 = (-bp-m)/ap/2 ; x2 = (w3-2*y2*w2)*q/2/w1 + t1 = atan2(y1,x1) + t2 = atan2(y2,x2) + theta1 = min(t1,t2) + theta2 = max(t1,t2) + +# tangent curve + nT = 11 + for i = 0 to nT do { + y = y1 + (y2-y1)/nT*i + theta = atan2(y,(w3-2*y*w2)*q/2/w1) + r = y/sin(theta) + T[i]: Project(vx(theta,r)) + } + +# front and back parts of the top curve + n = 12 + for i = 0 to n do { + theta = theta1 + (theta2-theta1)/n*i + F[i]: Project(vx(theta,c)) + Fp[i]: Project(vp(theta,c)) + } + for i = 0 to n do { + theta = theta2 + (theta1+twopi_-theta2)/n*i + B[i]: Project(vx(theta,c)) + Bp[i]: Project(vp(theta,c)) + } + +# trajectory +rotations = 1.55 +nx = 7 +thetas = 75*dtor_ +thetaf = thetas - rotations*twopi_ +rx = c*0.9 +beta = exp(log(.5)/20) + +define(`defX',` rx = `$5' ; np = np-1 + ts = `$1' ; tf = `$2' + for i = 0 to `$3' do { + tha = ts + (tf-ts)*i/(`$3') + for thx = tha to -twopi_ by twopi_ do {} + `$4'[i]: Project(vx(thx,rx)) + Xp[np]: Project(vp(thx,rx)) + np = np+1 + rx = beta*rx + }') + +np = 1 +defX(thetas,theta1,nx,X1,rx) +defX(theta1,theta2-twopi_,nx,X2,rx/beta) +defX(theta2-twopi_,theta1-twopi_,nx,X3,rx/beta) +defX(theta1-twopi_,thetaf,5,X4,rx/beta) + +# First draw the inside back +# B is the back curve +# T is the outline +ifpstricks(` +\psset{gradbegin=lightgray,gradend=darkgray,gradlines=1000} +\pscustom[fillstyle=gradient,gradmidpoint=0.7]{ + fitcurve(B,n) + for i = 0 to nT do {TT[i]: T[nT-i] } + fitcurve(TT,nT) +\relax} ', +` fitcurve(B,n) + for i = 0 to nT do {TT[i]: T[nT-i] } + fitcurve(TT,nT) ') + +# Centre axis +thinlines_ +line from Origin to Project(0,0,h) +# F[0] is the leftmost point of the front curve +line from F[0] to Fp[0] +# F[n] is the rightmost point of the front curve +line from F[n] to Fp[n] +thicklines_ + +# Now draw the outside front +ifpstricks(` +\newgray{gray1}{0.9}% +\newgray{gray2}{0.4}% +\psset{gradbegin=gray1,gradend=gray2,gradlines=1000} +\pscustom[linewidth=0pt,fillstyle=gradient,gradmidpoint=0.99]{ + fitcurve(F,n) + fitcurve(T,nT) +\relax} ', +` shade(1,fitcurve(F,n) + fitcurve(T,nT)) ') +# T is the limit curve of visibility + fitcurve(T,nT) +# F is the top front + fitcurve(F,n) +# Front and back projections of the top on xy + fitcurve(Fp,n) + fitcurve(Bp,n) + +# The trajectory in pieces, to allow dashed parts + fitcurve(X1,nx) + fitcurve(X2,nx,dotted 0.025) + fitcurve(X3,nx) + fitcurve(X4,3,dotted 0.015) + arca(from X4[4] to X4[3],ccw,0.3,<-) + +# Projected trajectory + np = np-2 + fitcurve(Xp,np-1) + arca(from Xp[np] to Xp[np-2],ccw,0.18,<-) + "$X(t)$" at Xp[np]-(2bp__,0) ljust + +# Axes and vertical lines +thinlines_ + line from X1[0] to Xp[0] + line from X4[4] to Xp[np] +arrow from Origin to Project(1.5,0,0) +"$x_1$" rjust below +arrow from Origin to Project(0,1.5,0) +"$x_2$" ljust +line dashed from Project(0,0,h) to F[n/2] chop 0 chop arrowht/4 +arrow from F[n/2] to Project(0,0,2) +"$v(X)$" ljust + +"`${0}$'" at Origin+(0,1 pt__) below +"$\Omega$" at Project(0,0.9*c,0)+(0,3bp__) above +"`$v(X) = c$'" at (Project(vp(100*dtor_,c)))+(2bp__,0) above ljust + +.PE diff --git a/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Makefile b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Makefile new file mode 100644 index 00000000000..5fba20547c6 --- /dev/null +++ b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Makefile @@ -0,0 +1,211 @@ +# Extras Makefile +# +# Type "make" to generate extras.pdf containing examples. +# The examples are in no particular order (well, they are in ls order). +# Type "make clean; make extras.ps" to invoke latex intead of pdflatex. +# Type "make <diag>.ps" to make a postscript file from <diag>.m4 +# It may be necessary to type "make clean" before this or any of the following: +# Type "make <diag>.eps" to make an .eps file from <diag>.m4 +# Type "make <diag>.svg" to make an .svg file from <diag>.m4 using pdf2svg +# The following require ImageMagick convert: +# Type "make <diag>.png" to make a .png file from <diag>.m4 +# Type "make <diag>.tif" to make a .tif file from <diag>.m4 +# +# To test the file test.m4, type "make tst" if boxdims is used, otherwise +# type "make tst1". In either case the file tst.ps is created. +# +# To debug a single diagram in a directory other than this examples +# directory, copy this makefile and tst.tex to where you want to work, +# redefine LIBDIR (below) appropriately, and type "make <diag>.xxx" +# where xxx is one of ps, eps, png, or pdf + +######################################################################### + +# Circuit_macro directory, change this if necessary: +# LIBDIR = $$HOME/lib +LIBDIR = .. + +# The dpic processor: +PIC = dpic + +#MODE = -p +MODE = -g + +#CONF = pstricks.m4 +CONF = pgf.m4 + +# Convert options +EPSOPTS = +PNGOPTS = -quiet -density 400 -scale 25% -alpha Remove + +# M4 = m4 -I $(LIBDIR) +# If environment variable M4PATH has been set to the installation directory: +M4 = m4 + +DOC = extras + +# Files that have to be processed twice: +BOXDIMS = + +######################################################################### + +DVIPSOPTS = -G0 -t letter +DIMFILE = $(DOC).dim +BS = tr '|' '\134' + +# Might be needed (change latex commands to $(LTX) ) +# LTX = latex --shell-escape +LTX = pdflatex --shell-escape + +XTRASRC=printf "|documentclass[11pt]{article}\n\ +|usepackage[dvipsnames]{xcolor}\n\ +|usepackage{times,boxdims,siunitx,amssymb,tikz}\n\ +|setlength{|textwidth}{8in} |setlength{|textheight}{10.5in}\n\ +|setlength{|hoffset}{-2cm} |setlength{|voffset}{-3cm}\n\ +|begin{document}\n" | $(BS) + +PDFLTXSRC=printf "|documentclass[11pt]{standalone}\n\ +|usepackage{times,boxdims,siunitx,amssymb,tikz,geometry}\n\ +|geometry{paperwidth=15in,paperheight=14in,margin=1in}\n\ +|pagestyle{empty}|thispagestyle{empty}\n\ +|begin{document}|noindent|input{"$*".tex}|end{document}\n" | $(BS) + +LTXFILE=printf "|documentclass[11pt]{article}\n\ +|usepackage[dvipsnames]{xcolor}\n\ +|usepackage{times,boxdims,graphicx,pstricks}\n\ +|usepackage{siunitx}\n\ +|setlength{|textwidth}{28cm}|setlength{|textheight}{28cm}\n\ +|setlength{|oddsidemargin}{0pt}|setlength{|evensidemargin}{0pt}\n\ +|setlength{|hoffset}{-1cm}\n\ +|pagestyle{empty}|thispagestyle{empty}\n\ +|newbox|graph\n\ +|begin{document}\n\ +|noindent|input{"$*".tex}|box|graph\n\ +|end{document}\n" | $(BS) + +.SUFFIXES: .ps .dvi .tex .m4 .pic .eps .png .pdf .svg .tif .gif +.m4.pic: + @touch $(DIMFILE) F_$*.dim + $(M4) $(CONF) $(DIMFILE) F_$*.dim $*.m4 > $*.pic +.m4.tex: + @touch $(DIMFILE) F_$*.dim + $(M4) $(CONF) $(DIMFILE) F_$*.dim $*.m4 | $(PIC) $(MODE) > $*.tex +.m4.dvi: + @touch $(DIMFILE) F_$*.dim + $(M4) pstricks.m4 $(DIMFILE) F_$*.dim $*.m4 | $(PIC) -p > $*.tex + @$(LTXFILE) > F_$*.tex + latex --quiet F_$* + touch F_$*.dim $(DIMFILE) + $(M4) pstricks.m4 $(DIMFILE) F_$*.dim $*.m4 | $(PIC) -p > $*.tex + latex --quiet F_$* + mv F_$*.dvi $*.dvi + rm -f F_* +.dvi.ps: + dvips $(DVIPSOPTS) $* -o $*.ps + chmod 644 $*.ps +.m4.ps: + @touch $(DIMFILE) F_$*.dim + $(M4) pstricks.m4 $(DIMFILE) F_$*.dim $*.m4 | $(PIC) -p > $*.tex + @$(LTXFILE) > F_$*.tex + latex --quiet F_$* + dvips $(DVIPSOPTS) F_$* -o $*.ps + chmod 644 $*.ps + rm -f F_* +.m4.eps: + @touch $(DIMFILE) F_$*.dim + $(M4) pstricks.m4 $(DIMFILE) F_$*.dim $*.m4 | $(PIC) -p > $*.tex + @$(LTXFILE) > F_$*.tex + latex --quiet F_$* + $(M4) pstricks.m4 $(DIMFILE) F_$*.dim $*.m4 | $(PIC) -p > $*.tex + latex --quiet F_$* + dvips F_$* -T128cm,28cm -o $*.ps +# Recent changes to PSTricks(?) have clashed with the use of TeXtoEPS +# so use ps2epsi + ps2epsi $*.ps $*.epsi + sed -e '/%%Pages:/d' -e '/BeginPreview/,$$d' $*.epsi \ + | tr '\015' '\012' > $*.eps + sed -e '1,/EndPreview/d' $*.epsi >> $*.eps + rm -f F_* +.m4.pdf: + @touch $(DIMFILE) F_$*.dim + $(M4) pgf.m4 $(DIMFILE) F_$*.dim $*.m4 | $(PIC) -g > $*.tex + @$(PDFLTXSRC) > F_$*.tex + pdflatex --quiet F_$* + $(M4) pgf.m4 $(DIMFILE) F_$*.dim $*.m4 | $(PIC) -g > $*.tex + pdflatex --quiet F_$* + mv F_$*.pdf $*.pdf + rm -f F_* +.m4.png: + make $*.pdf + convert $(PNGOPTS) $*.pdf $*.png + @if test -f $*.png.0 ; then mv $*.png.0 $*.png ; fi +# rm $*.pdf +.m4.gif: + make $*.pdf + convert $(GIFOPTS) $*.pdf $*.gif +# rm $*.pdf +.m4.tif: + make $*.pdf + convert $(EPSOPTS) $*.pdf $*.tif + @if test -f $*.tif.0 ; then mv $*.tif.0 $*.tif ; fi +# rm $*.pdf +.m4.svg: + make $*.pdf + dvisvgm --pdf $*.pdf $*.svg + chmod 644 $*.svg +# rm $*.pdf + + +######################################################################### + +$(DOC).pdf: + @$(XTRASRC) > extras.tex + touch extras.dim + -for fl in `ls *.m4` ; do \ + file=`basename $$fl .m4` ; \ + echo $$file.m4 ; \ + $(M4) pgf.m4 extras.dim $$file.m4 | $(PIC) -g > $$file.tex ; \ + printf "\n\n|parbox{|textwidth}{\n" | $(BS) >> extras.tex ; \ + printf "|input{$$file.tex}\n" | $(BS) >> extras.tex ; \ + printf "\n $$file.m4\n}\n|vspace{|baselineskip}" \ + | sed -e 's/_/|_/g' | $(BS) >> extras.tex ; \ + done + printf "\n|end{document}\n" | $(BS) >> extras.tex + pdflatex extras + -for file in $(XBOXDIMS) ; do \ + rm -f $$file.tex ; \ + $(M4) pgf.m4 extras.dim $$file.m4 | $(PIC) -g > $$file.tex ; \ + done + pdflatex extras + +$(DOC).ps: psmode $(DOC).dvi + +psmode: + printf "|usepackage{pstricks,pst-grad}\n" | $(BS) > mode.tex + +pdfmode: + printf "|usepackage{tikz}\n" | $(BS) > mode.tex + +$(DOC).dvi: $(DOC).tex files.tex header.tex psmode + touch $(DOC).dim + make CONF=pstricks.m4 MODE=-p DIMFILE=$(DOC).dim pics + cp $(LIBDIR)/doc/Version.tex . + latex $(DOC) + rm -f $(BOXDIMS) ${BOXDIMS:%.tex=%.pic} $(DOC).dvi + make CONF=pstricks.m4 MODE=-p DIMFILE=$(DOC).dim $(BOXDIMS) + latex $(DOC) + +tst: + @$(LTXFILE) | sed -e 's/{\.tex}/{test.tex}/' > tst.tex + make CONF=pstricks.m4 PIC=dpic MODE=-p test.tex; latex --quiet tst + rm -f test.tex test.pic + make CONF=pstricks.m4 PIC=dpic MODE=-p test.tex; latex --quiet tst + dvips $(DVIPSOPTS) tst -o tst.ps + +tst1: + @$(LTXFILE) | sed -e 's/{\.tex}/{test.tex}/' > tst.tex + make CONF=pstricks.m4 PIC=dpic MODE=-p test.tex; latex --quiet tst + dvips $(DVIPSOPTS) tst -o tst.ps + +clean: + rm -f *.ps *.pdf *.tex *.dim *.pic *.log *.dms *.aux diff --git a/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Metamodel.m4 b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Metamodel.m4 new file mode 100644 index 00000000000..e5d1ba0b1ca --- /dev/null +++ b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Metamodel.m4 @@ -0,0 +1,78 @@ +.PS +# Metamodel: +# https://tex.stackexchange.com/questions/615463/how-to-draw-meta-models-in-tikz +gen_init + + lineht = 0.4 + arrowht = arrowht*3/2; arrowwid = arrowwid*2 + fillv = 0.9 + define bx {box fill_(fillv) rad 5bp__ $1} + up_ + + Event: bx(ht boxht "Event") + sarrow(,type=D); {"{\tt<}contains{\tt>}" at last arrow rjust} + Trace: bx(ht boxht "Trace") + sarrow(,type=D); {"{\tt<}contains{\tt>}" at last arrow rjust} + Log: bx(ht boxwid "Log") + Att: bx(ht boxwid wid boxwid*5/4 "Attribute" dashed) \ + with .nw at Log.ne + (boxwid*2,0) + + fillv = 0.8 + ww = Log.ht + move to (Att.w,Att.n) - (0,ww/9) + { sarrow(to (Log.e,Here),type=D) + {"{\tt<}trace-global{\tt>}" at last arrow above} } + move down_ ww/3 + { sarrow(to (Log.e,Here),type=D) + {"{\tt<}event-global{\tt>}" at last arrow above} } + move down_ ww/3 + { sarrow(to (Log.e,Here),type=D) } + T: 0.8 between last arrow.start and last arrow.end + move down_ ww/9 + line dashed left ww/3 then down ww/2 then right ww/2 + sarrow(up ww*7/18, type=D;shaft=dashed) + "{\tt<}contains{\tt>}" at (last arrow.end,Att.s)-(ww/4,ww*7/18) below + + line from T to (T,Event); sarrow(to Event.e,type=D) + sarrow(from (T,Trace) to Trace.e,type=D) + + ellipsewid = boxwid*0.9 + ellipseht = ellipsewid/2 + move to (Att.e,Att.s)+(ww/6,-ww/8) + y = Here.x-Att.c.x-boxwid/2 + down_ + Loopover_(`Z',`Z: bx(ht boxht*3/4 "Z") + {sarrow(from Z.e+(y,0) to Z.e,type=D)} + {ifelse(Z,Boolean, + `move to last arrow.start; line to (Here,String) + line from Z.w to (Att,Z.w); sarrow(to Att.s,type=O)', + `line from Z.w to (Att,Z.w)')} + move down_ ww/16', + String,Date,Int,Float,Boolean) + + line from Int.e+(y,0) right_ ww/4; Value: ellipse fill_(fillv) "Value" + Key: ellipse fill_(fillv) "Key" with .w at Att.e+(y*2,0) + sarrow(from last ellipse.w to Att.e,type=D) + + Class: bx(ht boxht*3/4 "Classifier") \ + with .s at (0.5 between Log and Att,Att.n)+(0,boxht/2) + line from Class.w to (Log,Class); sarrow(to Log.n,type=D) + "{\tt<}defines{\tt>}" at (0.5 between Log and Class.w,Class) above + line from Att.n to (Att,Class); sarrow(to Class.e,type=D) + "{\tt<}defines{\tt>}" at (0.5 between Att and Class.e,Class) above + + Ext: bx(ht boxht*3/4 "Extension") with .e at (Att.e,Class+(0,boxht*3/2)) + move to (Att.e,Att.n)-(Att.wid/8,0) + sarrow(to (Here,Ext.s),type=D;shaft=dashed) + "{\tt<}defines{\tt>}" at (last arrow,Ext.s)-(0,y) rjust + line dashed from Ext.w to (Log,Ext) then to (Log,Class) + "{\tt<}declares{\tt>}" at (0.5 between Log and Class,Ext) below + + ellipse fill_(fillv) "name" at (Key,Ext) + sarrow(from last ellipse.w to Ext.e,type=D) + ellipse fill_(fillv) "prefix" with .n at last ellipse.s+(0,-ww/16) + line from last ellipse.w left y + URI: ellipse fill_(fillv) "URI" with .n at last ellipse.s+(0,-ww/16) + line from last ellipse.w left y then up Ext.y - URI.y + +.PE diff --git a/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Obliq.m4 b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Obliq.m4 new file mode 100644 index 00000000000..0c71c6569e0 --- /dev/null +++ b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Obliq.m4 @@ -0,0 +1,72 @@ +.PS +threeD_init +scale = 2.54 + +divert(-1) + `ProjectObliq(x,y,z,x scale,degrees) + oblique projection + arg4= x scale (default 1/2)' +define(`ProjectObliq',`(`$2'-dnl +(`$1')ifelse(`$4',,/2,*(`$4'))*cosd(ifelse(`$5',,obliqueangle_,(`$5'))),dnl +`$3'-(`$1')ifelse(`$4',,/2,*(`$4'))*sind(ifelse(`$5',,obliqueangle_,(`$5'))))') +define(`obliqueangle_',45) + +divert(0)dnl + +define(`Pr',`ProjectObliq(`$1',`$2',`$3')') + + d = 2 +define(`cube',`[ # w, h, d, scale, degrees + define(`cubewd',ifelse(`$1',,linewid,`$1'))dnl + define(`cubeht',ifelse(`$2',,cubewd,`$2'))dnl + define(`cubedp',ifelse(`$3',,cubewd,`$3'))dnl + for_(0,7,1,`P`'binary_(m4x,3): \ + Pr(ifelse(eval(m4x/4),1,cubedp,0), + ifelse(eval((m4x%4)/2),1,cubewd,0), + ifelse(eval(m4x%2),1,cubeht,0))') +# {command "{\small" +# for_(0,7,1,`"binary_(m4x,3)" at P`'binary_(m4x,3)') +# command "}" +# } + {"000" at P000} + if obliqueangle_ > 0 then { + line dashed from P100 to P000 chop linethick bp__ * 2 chop 0 + line dashed from P010 to P000 chop linethick bp__ * 2 chop 0 + line dashed from P001 to P000 chop linethick bp__ * 2 chop 0 + line from P101 to P001 + line to P011 + line to P111 + line to P101 + line to P100 + line to P110 + line to P010 + line to P011 + line from P110 to P111 + } else { + line dashed from P101 to P001 chop linethick bp__ * 2 chop 0 + line dashed from P011 to P001 chop linethick bp__ * 2 chop 0 + line dashed from P000 to P001 chop linethick bp__ * 2 chop 0 + line from P100 to P101 + line to P111 + line to P110 + line to P100 + line to P000 + line to P010 + line to P011 + line to P111 + line from P010 to P110 + } + ]') + + Cube: cube(1,2,3) +# +##{arrow from Cube.P001 to 3/2 between Cube.P000 and Cube.P001; "$z$" ljust } +##{arrow from Cube.P010 to 3/2 between Cube.P000 and Cube.P010; "$y$" below } +##{arrow from Cube.P100 to 3/2 between Cube.P000 and Cube.P100; "$x$" ljust } + + move define(`obliqueangle_',30); cube(1,2,3) + move define(`obliqueangle_',15); cube(1,2,3) + move define(`obliqueangle_',-15); cube(1,2,3) + move define(`obliqueangle_',-30); cube(1,2,3) + +.PE diff --git a/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/OneLine.m4 b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/OneLine.m4 new file mode 100644 index 00000000000..7b451b366aa --- /dev/null +++ b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/OneLine.m4 @@ -0,0 +1,67 @@ +.PS +# OneLine.m4 +# https://tex.stackexchange.com/questions/191598/electric-network-one-line-diagrams/325717#325717 +cct_init +include(libSLD.m4) +First: [ + xgap = 0.6 + dim1 = 1; dim2 = 0.75 ; dim3=0.5 + X: box fill_(0.9) wid 1 "Xingu" "\SI{500}{\kV}" + { "$R_0=\SI{1,682}{\ohm}$" at X.sw below ljust } + sl_transformer(right_ dim2,type=S); rlabel(,\SI{18}{\percent},) + {[Ysymbol;Ysymbol(at last []+(last [].wid,0))] with .s at last [].n+(0,2bp__)} + { B1: line thick 3*linethick up 0.4 with .c at Here + "$s$" wid 0.1 ht 0.1 above } + { arrow right 0.2 from last line.c+(0.1,-0.1) } + { "$I^s$" at last line.start below } + line right 3.0 "$l=\SI{2600}{\km}$" wid 0.1 ht 0.1 above + { B2: line thick 3*linethick up 0.4 with .c at Here; "$r$" above } + sl_transformer(right_ dim2,type=S); rlabel(,\SI{18}{\percent},) + {[Ysymbol;Ysymbol(at last []+(last [].wid,0))] with .s at last [].n+(0,2bp__)} + NI: box fill_(0.9) wid 1 "Nova Igua\c{c}u" "\SI{500}{\kV}" + "$Z_0=a+b$" at NI.sw below ljust + RELE: box wid dimen_/2 ht dimen_/2 with .w at B1+(0.6,0.3) + line left 0.15 from 1/4 between RELE.nw and RELE.sw; "$V^s$" rjust + line left 0.15 from 3/4 between RELE.nw and RELE.sw; "$I^s$" rjust + ] +Second: [ + lstem = dimen_*3/4 + asep = dimen_/3 + sl_grid(U,lgth=dimen_;wdth=dimen_) + sl_transformer(down_ dimen_*7/4,type=S;name=Tr) + llabel(,"$\SI{400}{kVA}$" ljust "$\SI{4}{\percent}$" ljust,,,Tr) + Bus: sl_busbar(right_ dimen_*12, 5) with .P3 at Here +# +define(`loadstring',`[ L: line invis down_ dimen_*5 + line from L.start down_ L.len/4; dot + { arrow <-> down_ last line.len at last line+(asep,0) "\sf $5 m" ljust } + { sl_load(left_ lstem); "\sf $1" at Head.w rjust } + { r_text(90,`\sf\scriptsize NAYY 4x150 mm$^2$', at Here+(-7bp__,0)) } + line down_ L.len/4; dot + { arrow <-> down_ last line.len at last line+(asep,0) "\sf $6 m" ljust } + { sl_load(left_ lstem); "\sf $2" at Head.w rjust } + { box wid dimen_/3 ht dimen_/3 at Here } + line down_ L.len/8-3bp__ + { ACsymbol(at Here+(0,-3bp__),,,2:RA) } + line down_ L.len/8+3bp__ from last line.end chop 6bp__ chop 0; dot + ifelse(`$7',,, + `{ arrow <-> up_ L.len/4 from Here+(asep,0) "\sf $7 m" ljust }') + { sl_load(left_ lstem); "\sf $3" at Head.w rjust } + line down_ L.len/4; dot + { arrow <-> down_ last line.len at last line+(asep,0) "\sf $8 m" ljust } + { sl_load(left_ lstem); Q:"\sf $4" at Head.w rjust } + { box wid dimen_/3 ht dimen_/3 at Here } ]') +# + loadstring(1,2,27,28, 21,21,,21) with .L.start at Bus.P1 + move left_ 13bp__ from last [].Q + loadstring(1,2,15,16, 29,29,,29) with .L.start at Bus.P2 + loadstring(1,2, 8, 9, 40,40,,40) with .L.start at Bus.P3 + loadstring(1,2, 3, 4, 64,64,64,64) with .L.start at Bus.P4 + line down_ last [].L.len/2 from Bus.P5; dot + { r_text(90,`\sf\scriptsize NAYY 4x150 mm$^2$', at last line.c+(-7bp__,0)) } + { arrow <-> down_ last line.len at last line+(asep,0) + "\sf 102 m" wid 30.4 bp__ ljust at last arrow } + { sl_load(left_ lstem)} + ] with .nw at First.sw+(0,-dimen_/2) +#showbox_ +.PE diff --git a/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/OpAmpFilter.m4 b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/OpAmpFilter.m4 new file mode 100644 index 00000000000..8e8f82c9801 --- /dev/null +++ b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/OpAmpFilter.m4 @@ -0,0 +1,69 @@ +.PS +# OpAmpFilter.m4 +cct_init +command "{\small\sf" + + define(`SpecOpAmp',`$1: [ right_ + lwtmp = linewid; linewid = 1*scale + H: opamp + "$2" at H.In1 below rjust + "$3" at H.In2 below rjust + "$4" at H.E below ljust + "V${-}$" at H.E1 below + line up_ dimen_/3 from H.E1 "4" rjust; dot(,,1) + "$\hbox{V}_{\hbox{CC}}$" rjust at last [].w + "V${+}$" at H.E2 above + line down_ dimen_/3 from H.E2 "11" ljust; dot(,,1) + "${-}\hbox{V}_{\hbox{CC}}$" ljust at last [].e + linewid = lwtmp + ifelse($1,U1,,`line left_ jog from H.In2 then down_ jog/2; zground ') + "$1" at H.S below ljust + In1: H.In1; In2: H.In2; Out: H.Out + D: dot(at Out) + V: circle diam 12bp__ "V" at Out+(dimen_/4,dimen_/3) + "V$_{\hbox{\scriptsize $5}}$" at V.n above + open_arrow(from V to D chop last circle.rad chop dotrad_) ] ') + define(`zground',`ground(`$1',,S); "0" at Here+(dimen_/6,-dimen_/2)') + + cscale = 5/4 + linewid = linewid*cscale + jog = dimen_*0.3 + vstep = dimen_*5/4 + SpecOpAmp(U1,2,3,1,hp) + R1: resistor(right_ elen_*3/4 from U1.Out); llabel(,"R1"); rlabel(,"1`\,'k") + dot; line right_ jog + SpecOpAmp(U2,5,6,7,bp) with .In1 at Here + R2: resistor(right_ elen_*3/4 from U2.Out); llabel(,"R2"); rlabel(,"1`\,'k") + dot; line right_ jog + SpecOpAmp(U3,9,10,8,lp) with .In1 at Here + SpecOpAmp(U4,13,12,14,n) with .Out at U3.Out+(0,-dimen_*3.05) + line up vstep from U4.Out + Rf: resistor(left_); rlabel(,"R$_{\hbox{f}}$"); llabel(,"1`\,'k") + line to (U4.In1,Here)-(jog,0) then to U4.In1-(jog,0); dot + line from U3.Out down_ vstep+5bp__ then left_ jog + RL: resistor; rlabel(,"RL"); llabel(,"100") + line to (U4.In1-(2*jog,0),Here) then to U4.In1-(2*jog,0); dot + line from U1.Out to (U1.Out,Here); right_ + R42: resistor(to U4.In1); llabel(,"R42"); rlabel(,"1`\,'k") + line from U2.Out down_ vstep + R41: resistor(left_ to (U1.In2-(jog,0),Here)) + llabel(,"2.2`\,'k"); rlabel(,"R41") + line to (Here,U1.In2); dot; { line to U1.In2 } + line left_ jog; dot + { resistor(down_ elen_); rlabel(,"R0" rjust "10`\,'k"); zground } + R3: resistor(left_ dimen_); rlabel(,"R3","in"); llabel(,"1`\,'k") + source(down_ elen_,AC); llabel("V$_{\hbox{\scriptsize in}\;}$"); zground + line up_ vstep from U1.Out + R5: resistor(left_ to (U1.In1-(jog,0),Here)); rlabel(,"R6\enskip 10`\,'k") + dot + line from U1.In1 left_ jog then to Here+(0,dimen_/2) + resistor(right_ to (U3.Out,Here)); llabel(,"R5"); rlabel(,"1`\,'k") + line to U3.Out; dot(at Here+(0,vstep)) + capacitor(left_ to (U3.In1-(jog,0),Here)); rlabel(,"C2\enskip 100`\,'n") + line to (Here,U3.In1) + line from U2.Out up_ vstep + capacitor(left_ to (U2.In1-(jog,0),Here)); rlabel(,"C1\enskip 100`\,'n") + line to (Here,U2.In1) + +command "}%" +.PE diff --git a/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Optics.m4 b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Optics.m4 new file mode 100644 index 00000000000..d4fadd44652 --- /dev/null +++ b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Optics.m4 @@ -0,0 +1,31 @@ +.PS +# Optics.m4 +# https://tex.stackexchange.com/questions/623201/geometrical-optics +gen_init +scale = 2.54 + + textoffset = 4pt__ + O: dot(at (0,0)) ; "\Large $O$" below rjust + L: line thick 1 right_ 14 with .c at O + S: dot(at (1.8,0)) ; "\Large $S$" below rjust + r = 7 + C: dot(at (S.x-r,0)) ; "\Large $C$" below + F: dot(at (-1.8,0)) ; "\Large $F$" below + I: dot(at (4,0)) ; "\Large $I$" below + arrow dashed from I up_ 3.2 ; It: Here + AS: C.x+sqrt(r^2-3.7^2),3.7 + Arc: arc thick 1 cw from AS to (AS.x,-AS.y) rad r with .c at C + for y=-AS.y to AS.y+0.001 by 0.1 do { line thick 0.4 right 0.5 up 0.1 \ + from (C.x+sqrt(r^2-y^2),y) } + M: move from C to It + A1: arrow outlined "red" from C to LCintersect(M,C,r,R) chop -2 chop 0 + arrow outlined "red" dashed to It chop 0 chop -3 + N: move from It to F + arrow <- outlined "red" dashed from It to LCintersect(N,C,r) chop -2 chop 0 + P: move down_ 1 from A1.start + arrow outlined "red" from last arrow.end to Intersect_(P,N) + Q: move up 1 from O + arrow from O to Intersect_(Q,M) + arrow outlined "red" to (C.x+sqrt(r^2-Here.y^2),Here.y) + +.PE diff --git a/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Orbits.m4 b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Orbits.m4 new file mode 100644 index 00000000000..ef85d279353 --- /dev/null +++ b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Orbits.m4 @@ -0,0 +1,74 @@ +.PS +# Orbits.m4 +threeD_init +NeedDpicTools + + crad = 1.0 + g = 0.65 + +# `orbitpos(long,lat,rad,ang)' +define(`orbitpos', + `rot3Dx((`$2')*dtor_,rot3Dz((`$1')*dtor_,rot3Dy(-(`$4')*dtor_,`$3',0,0)))') + +define(`PO',`B.C+(Project(orbitpos(orbitlong,orbitlat,orbitrad,`$1')))') + +define vis { X: PO($1) + if (distance(X,B.C)>crad) || \ + (dot3D(View3D,orbitpos(orbitlong,orbitlat,orbitrad,$1))>0) \ + then {$2 = 1} else {$2 = -1} } + +# `orbit(long,lat,rad)' +define(`orbit', + `[da = 3 + orbitlong = `$1' + orbitlat = `$2' + orbitrad = `$3' + define(`decorated',`ifelse(`$4',,,`outlined `$4'')') + arrow from PO(0) to PO(da*3) decorated + n=0 + P[n]: PO(0) + vis(0,v) + for d=da to 360 by da do { + vis(d,x) + if x*v < 0 then { + findroot(vis,d-da,d,1e-6,x) + n+=1; P[n]: PO(x) + if v < 0 then { fitcurve(P,n,dashed decorated) } \ + else { fitcurve(P,n,decorated) } + P[0]: P[n] + n = 0; v = -v } + n +=1; P[n]: PO(d) + } + if v < 0 then { fitcurve(P,n,dashed decorated) } \ + else { fitcurve(P,n,decorated) } + ] with .c at B.C') + +# ball(rad,highlight rad,highlight degrees) +define(`ball',`[ + lt = linethick bp__ + C: circle invis rad `$1' at (0,0) + D: C+(Rect_(`$2',`$3')) + rm = `$1'+distance(C,D) + a = 1 # fade rate parameter + for r=lt to rm by lt do { + u = 1-(r/rm*(a*r/rm+(1-a))) + if r < (1-g)*`$1' then { circle outlined rgbstring(u,u,u) rad r at D } \ + else { arc cw outlined rgbstring(u,u,u) from Cintersect(D,r,C,`$1') \ + to Cintersect(D,r,C,`$1',R) with .c at D + } + } + circle rad C.rad at C + ]') + + linethick = 0.8 + B: ball(crad,crad*g,110) + + azimuth = 0 + elevation = 0 + setview(azimuth,elevation) + + orbit(10, 30,crad*1.3,"red") + orbit(10,-30,crad*1.3,"blue") + orbit(10,-90,crad*1.3,"cyan") + +.PE diff --git a/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/PPA.m4 b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/PPA.m4 new file mode 100644 index 00000000000..8d25901310d --- /dev/null +++ b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/PPA.m4 @@ -0,0 +1,40 @@ +.PS +# `PPA.m4 Push-pull amplifier' +cct_init + +Vs: source(up_ elen_,"$V_S$") + line right elen_/2 +T1: transformer(down_ elen_,,,W,10) with .P1 at Here + { dot(at T1.TP+(-dimen_/8,dimen_/3)) } + { dot(at T1.TS+(dimen_/8,dimen_*2/3))} + { dot(at T1.TS+(dimen_/8,-dimen_/8)) } + line from T1.P2 to Vs.start + + line up_ dimen_*3/4 from T1.S1 then right_ dimen_*3/4 + up_ +Q1: bi_tr(,L,,E) with .B at Here + line down_ dimen_*3/4 from T1.S2 then right_ dimen_*3/4 + down_ +Q2: bi_tr(,R,,E) with .B at Here + line from Q1.E to Q2.E +R2: resistor(left_ dimen_ from last line); llabel(,R_2) + dot; {dot(at R2.start) } + line to T1.TS + line down_ dimen_/2 right_ dimen_/2 from R2.start + ground + + line right_ dimen_/6 from R2.start +Vcc: battery(right_ elen_,2); rlabel(,V_{cc}) + dot + line up dimen_*2/3 then to (R2.start.x,Here.y+dimen_*2/3) + resistor(to (R2.end,Here)); rlabel(,R_1); line to R2.end + line right_ dimen_/2 from Vcc.end +T2: transformer(up_ elen_,,,W,10) with .TS at Here + line from T2.S2 to (T2.S2,Q1.C) then to Q1.C + line from T2.S1 to (T2.S1,Q2.C) then to Q2.C + + line right elen_/2 from T2.P2 + resistor(down_ to (Here,T2.P1)); llabel(,R_L) + line to T2.P1 + +.PE diff --git a/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/PerpTo.m4 b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/PerpTo.m4 new file mode 100644 index 00000000000..410ce9605f4 --- /dev/null +++ b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/PerpTo.m4 @@ -0,0 +1,26 @@ +.PS +# PerpTo.m4 +# https://tex.stackexchange.com/questions/666411/repetitive-perpendiculars-in-a-right-angle-triangle +gen_init + + O: (0,0) + A: (5,0) + B: (0,3) + +define drawperp { #( depth, O, A, B ) +[ d = $1; O[d]: $2; A[d]: $3; B[d]: $4 + P[d]: PerpTo(O[d],A[d],B[d]) + if d > 0 then { + exec sprintf("drawperp(%g,P[%g],O[%g],A[%g]) with .O[%g] at P[%g]",\ + d-1,d,d,d,d-1,d) + exec sprintf("drawperp(%g,P[%g],B[%g],O[%g]) with .O[%g] at P[%g]",\ + d-1,d,d,d,d-1,d) + } + line outlined graystring((depth-d)/depth) from O[d] to P[d] + ] } + + depth = 6 + drawperp(depth,O,A,B) with .O[depth] at O + line from O to A then to B then to O + +.PE diff --git a/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Pipe.m4 b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Pipe.m4 new file mode 100644 index 00000000000..0d6512478c1 --- /dev/null +++ b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Pipe.m4 @@ -0,0 +1,40 @@ +.PS +# How about ladder diagrams? +gen_init +NeedDpicTools + + { for x=0 to 5 do { line up 5 from (x,0) } } + { for y=0 to 5 do { line right 5 from (0,y) } } + posarray(A, + (1,0.5), + (4,0.5), + (4.5,1), + (4.5,3), + (4,3.5), + (3.5,3), + (3,2.5), + (1,2.5), + (0.5,3), + (0.5,4), + (1,4.5), + (4,4.5)) + P[0]: 1,0.5 + P[1]: 4.5,0.5 + P[2]: 4.5,3.5 + P[3]: 3.5,3.5 + P[4]: 3.5,2.5 + P[5]: 0.5,2.5 + P[6]: 0.5,4.5 + P[7]: 4,4.5 + + r = 0.4 + define(`curve', + ` move to P[0] + for i_c=1 to 6 do { arcto(P[i_c],P[i_c+1],r,`$1') } + line to P[7] `$1'') + + lw = 0.3/(1bp__) + lt = 1.8 + for i=0 to 6 do { + curve(thick lw-lt*i outlined rgbstring(0.1+i/10,0.1+i/10,0.1+i/10))} +.PE diff --git a/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Planes.m4 b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Planes.m4 new file mode 100644 index 00000000000..9344bd2ddad --- /dev/null +++ b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Planes.m4 @@ -0,0 +1,175 @@ +.PS +# Planes.m4 +threeD_init +NeedDpicTools + +# These 3D diagrams are like many others: define the surface facets, +# use normal vectors to determine visibility, sort and plot the visible +# facets from back to front. + +# Store a point as x_[i], y_[i], z_[i] +define(`mktriple',` + x_[$1] = $2 + y_[$1] = $3 + z_[$1] = $4') +# Recover point coordinates +define(`triple',`x_[$1], y_[$1], z_[$1]') + +define(`facetnormal',`cross3D( + diff3D(triple($1*3+1),triple($1*3)), + diff3D(triple($1*3+2),triple($1*3+1)))') + +define(`facetcenter',`sprod3D(0.5,sum3D(triple($1*3),triple($1*3+2)))') + +# Create npositive, arrays dcosine[1..npositive] +# and index ix[1..npositive] of sorted facets +# Uses macros facetnormal(i) and facetcenter(i) +define(`processfacets',` + npositive = 0 + for i=1 to `$1' do { + mktriple(0,facetnormal(i)) + dx = dot3D(triple(0),View3D) + if dx > 0 then { + dcosine[i] = dx/length3D(triple(0)) # direction cosine normal wrt View3D + npositive +=1 + dist[npositive] = dot3D(facetcenter(i),View3D) # distance + ix[npositive] = i + } + } + dpquicksort(dist,1,npositive,ix) ') + +ifelse(1,1,` +Threeplanes: [ +# Size parameters + a = 3/2 + b = 0.4 + d = 1 +# Define intersecting lines in the plane + A0: -a,-b + A1: a,-b + B0: Rot_(A0,120) + B1: Rot_(A1,120) + C0: Rot_(A0,240) + C1: Rot_(A1,240) + +# Intersections +define(`lintersect',`intersect_(`$1'0,`$1'1,`$2'0,`$2'1)') + AB: lintersect(A,B) + BC: lintersect(B,C) + CA: lintersect(C,A) + +# Facets are rectangles here; store 3 corners +define(`mkfacet',` + mktriple((`$1')*3, 0,`$2'.x,`$2'.y) + mktriple((`$1')*3+1, 0,`$3'.x,`$3'.y) + mktriple((`$1')*3+2,-d,`$3'.x,`$3'.y) + ') +# Define the facets + mkfacet(m4inx,A0,CA) mkfacet(m4inx,CA,A0) + mkfacet(m4inx,CA,AB) mkfacet(m4inx,AB,CA) + mkfacet(m4inx,AB,A1) mkfacet(m4inx,A1,AB) + + mkfacet(m4inx,B0,AB) mkfacet(m4inx,AB,B0) + mkfacet(m4inx,AB,BC) mkfacet(m4inx,BC,AB) + mkfacet(m4inx,BC,B1) mkfacet(m4inx,B1,BC) + + mkfacet(m4inx,C0,BC) mkfacet(m4inx,BC,C0) + mkfacet(m4inx,BC,CA) mkfacet(m4inx,CA,BC) + mkfacet(m4inx,CA,C1) mkfacet(m4inx,C1,CA) + nfacets = m4x + +# Wierd color +define(`colr',`ifelse(`$1',,"white", + `rgbstring(`$1',ifelse(`$2',,`$1',`$2'),ifelse(`$3',,`$1',`$3'))')') + +# Recover the 4th corner and draw +define(`drawfacet',` + NW_facet: project(triple(($1)*3)) + NE_facet: project(triple(($1)*3+1)) + SE_facet: project(triple(($1)*3+2)) + SW_facet: project(x_[($1)*3+2],y_[($1)*3],z_[($1)*3]) + N_facet: 0.5 between NW_facet and NE_facet + line from N_facet to NE_facet then to SE_facet then to SW_facet \ + then to NW_facet then to N_facet shaded colr(`$2',`$3',`$4') +# fill_(ifelse(`$2',,1,`(1-`$2')')) + ') + +# View angles azimuth, elevation, rotation (degrees) + setview( 10, 40 ) + +# Draw facets, shading with view cosines + processfacets(nfacets) + for i=1 to npositive do { drawfacet(ix[i],max(0,1-2*dcosine[ix[i]]), + dcosine[ix[i]], + dcosine[ix[i]]) +# for i=1 to npositive do { drawfacet(ix[i],dcosine[ix[i]]) + } + +] # Threeplanes +') + +# Bowl +# vertx_(facet_no,vertex_no) + define vertx_ { ($1-1)*nvertices + $2 } + +# Normal vector to a facet +define(`facetnormal',`cross3D( + diff3D(triple(vertx_($1,2)),triple(vertx_($1,1))), + diff3D(triple(vertx_($1,4)),triple(vertx_($1,1))))') + +# Facet center +define(`facetcenter',`sprod3D(1/4,sum3D( + sum3D(triple(vertx_(`$1',1)),triple(vertx_(`$1',2))), + sum3D(triple(vertx_(`$1',3)),triple(vertx_(`$1',4)))))') + +define(`drawplane',` + NW_plane: project(triple(vertx_($1,1))) + SW_plane: project(triple(vertx_($1,2))) + SE_plane: project(triple(vertx_($1,3))) + NE_plane: project(triple(vertx_($1,4))) + N_plane: 0.5 between NW_plane and NE_plane + shd = (`$2')^(1/4) + line from N_plane to NE_plane then to SE_plane then to SW_plane \ + then to NW_plane then to N_plane \ + fill_(ifelse(`$2',,1,shd)) outlined rgbstring(shd,shd,shd) +# line from NW_plane to NE_plane + line from SW_plane to SE_plane + ') + +ifelse(1,1,` + nvertices = 4 # vertices per facet +Bowl: [ + elevation = 30 + setview( 0, 30 ) + nplanes = 40 + bigradius = 2 + smallradius = 1 + cupht = 1.5 + thin = smallradius/10 +# Define the facet corners + for i=1 to nplanes do { + mktriple(vertx_(i,1),rot3Dz((i-1)/nplanes*twopi_,bigradius,0,0)) + mktriple(vertx_(i,2),rot3Dz((i-1)/nplanes*twopi_,smallradius,0,-cupht)) + mktriple(vertx_(i,3),rot3Dz((i )/nplanes*twopi_,smallradius,0,-cupht)) + mktriple(vertx_(i,4),rot3Dz((i )/nplanes*twopi_,bigradius,0,0)) + mktriple(vertx_(nplanes+i,1),triple(vertx_(i,4))) + mktriple(vertx_(nplanes+i,2),triple(vertx_(i,3))) + mktriple(vertx_(nplanes+i,3),triple(vertx_(i,2))) + mktriple(vertx_(nplanes+i,4),triple(vertx_(i,1))) + } +# for i=1 to nplanes do { +# mktriple(vertx_(i,1),rot3Dz((i-1)/nplanes*twopi_,bigradius,0,0)) +# mktriple(vertx_(i,2),rot3Dz((i-1)/nplanes*twopi_,smallradius,0,-cupht)) +# mktriple(vertx_(i,3),rot3Dz((i-1)/nplanes*twopi_,smallradius-thin,0,-cupht)) +# mktriple(vertx_(i,4),rot3Dz((i-1)/nplanes*twopi_,bigradius-thin,0,0)) +# } +# Find the visible facets and sort + processfacets(nplanes*2) + + for i=1 to npositive do { drawplane(ix[i],dcosine[ix[i]]) } + ellipse wid 2*bigradius ht 2*bigradius*sin(elevation*dtor_) at project(0,0,0) + +] #with .sw at Threeplanes.se +') + +.PE diff --git a/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/README_extras b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/README_extras new file mode 100644 index 00000000000..140802fb682 --- /dev/null +++ b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/README_extras @@ -0,0 +1,6 @@ + +THIS DIRECTORY contains a Makefile and .m4 sources for diagrams +not included in the examples files. Type "make" and, to clean up, +"make clean". This directory is assumed to be a subdirectory of +the examples directory in order to include the necessary definition +files. diff --git a/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/RandomNodes.m4 b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/RandomNodes.m4 new file mode 100644 index 00000000000..f14973204f2 --- /dev/null +++ b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/RandomNodes.m4 @@ -0,0 +1,19 @@ +.PS +# RandomNodes.m4 +gen_init +NeedDpicTools + + scale = 2.54 + n = 300 + msiz = 4.90*2 + maxdist = 1.0 + + box wid msiz ht msiz with .sw at (0,0) + for i=1 to n do { X[i] : (rand(), rand())*msiz } + for i=1 to n-1 do { for j=i+1 to n do { + if distance(X[i],X[j]) <= maxdist then { + line outlined "green" from X[i] to X[j] + } } } + for i=1 to n do { circle rad dotrad_ at X[i] shaded "green" } + +.PE diff --git a/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Region.m4 b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Region.m4 new file mode 100644 index 00000000000..e4cde354917 --- /dev/null +++ b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Region.m4 @@ -0,0 +1,38 @@ +.PS +# Region.m4 +# https://tex.stackexchange.com/questions/606088/how-can-i-plot-in-latex +gen_init + + grsize = 3.3 + maxaxis = 4.5 + define Grid { (($1+maxaxis)/(2*maxaxis)*grsize-grsize/2,\ + ($2+maxaxis)/(2*maxaxis)*grsize-grsize/2) } + +thinlines_ + box wid grsize ht grsize with .c at (0,0) + tic = 0.05 + for x=-maxaxis to maxaxis by 0.5 do { + line up tic from Grid(x,-maxaxis) + y = abs(x) + { if y/2 == int(y/2+0.5) then { sprintf("%g",x) at last line.start below } } + line down tic from Grid(x,maxaxis) + line right tic from Grid(-maxaxis,x) + { if y/2 == int(y/2+0.5) then { sprintf("%g",x) at last line.start rjust } } + line left tic from Grid(maxaxis,x) + } +thicklines_ + + n = 10 + ylim = 3 + for i=0 to n do { y = i/n*ylim + P[i]: Grid(sqrt(1+y^2),y) + P[-i]:( P[i].x,-P[i].y) + Q[i]: (-P[i].x, P[i].y) + Q[-i]:(-P[i].x,-P[i].y) } + rgbfill(0.6,0.6,0.8, + fitcurve(P,n,,-n) + line to (P[n].x,P[n].x) then to (Q[-n].x,Q[-n].x) then to Q[-n] + fitcurve(Q,n,,-n) + line to (Q[n].x,-Q[n].x) then to (P[-n].x,-P[-n].x) then to P[-n] ) + +.PE diff --git a/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Resolver.m4 b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Resolver.m4 new file mode 100644 index 00000000000..b6ca93047a7 --- /dev/null +++ b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Resolver.m4 @@ -0,0 +1,49 @@ +.PS +# `Resolver.m4' +cct_init +s_init(tst) +sinclude(tst.dim) + +iflatex(`latexcommand({\scriptsize\sf)') + +[ +linewid = linewid*1.25 +define(`dotrad_',dotrad_/2) + + T1: transformer(down_ dimen_/2) + line left from T1.P1; dot; move left 15bp__ "RH" + line left from T1.P2; dot; "RL" rjust + "Rotor ($r$)" at T1.TP rjust + line right_ dimen_*3/4 from T1.S2 + C: Here + phi = 35 + move right_ 0.1 from T1.S1; move from C to C+(Rect_(0.1,90+phi)) + Q: Intersect_(last move,2nd last move) + Lr: inductor(from Q to C) + S1: line from T1.S1 to Q + A: C+(Rect_(dimen_*0.9,90+phi)) + thinlines_ + line dashed from Q to A chop 2bp__ chop 0 + "Rotor shaft" at last line.end rjust "angle" rjust "" rjust + line dashed from C up_ dimen_*0.9 chop 2bp__ chop 0 + arcd(C,dimen_*0.85,90,90+phi) -> + thicklines_ + f_box($\phi$) at C+(Rect_(dimen_*0.85,90+phi/2)) + + d = distance(T1.P1,T1.P2) + Ls: inductor(up_ d from C+(d/2,0)) + line right_ from Ls.end + D2: dot; "S2" ljust + line from Ls.start to (D2,Ls.start); dot; "S4" ljust + "$Kr\cos(\phi)$" at 0.5 between last "" and 2nd last "" + Lq: inductor(right_ d at (Lr,(C+(0,-d/3)))) + line from Lq.end down_ d/4 + K: Here; corner; line to (D2,K); dot; "S3" ljust + line from Lq.start down_ d*5/4 + L: Here; corner; line to (D2,L); dot; "S1" ljust + "$Kr\sin(\phi)$" at 0.5 between last "" and 2nd last "" +] +"Resolver essentials" at last [].s below + +iflatex(`latexcommand(})') +.PE diff --git a/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/SPM.m4 b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/SPM.m4 new file mode 100644 index 00000000000..0b3fdb642c4 --- /dev/null +++ b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/SPM.m4 @@ -0,0 +1,59 @@ +.PS +# `SPM.m4 Salient-pole machine' +gen_init + + outerrad = 1 + medrad = 11/16 + windings = 6 + polewid = 3/8 + twid = (outerrad-medrad)/3 + srad = twid/4 + halfline = ifgpic(0,linethick/2 pt__) + + C: circle rad outerrad at 0,0 + line from Rect_(outerrad,180+60) to (C.w,C.s) then down polewid/2 \ + then right 2*outerrad then up polewid/2 then to Rect_(outerrad,-60) + + line from C+(medrad,-twid/2) right twid then up twid then left twid \ + chop -halfline + E: Here+(halfline,0) + for i = 1 to windings*2 do { + Point_(i*360/(windings*2)) + arc ccw from E to C+vec_(medrad,-twid/2) with .c at C + E: rvec_(0,twid) + line to rvec_(twid,0) then to rvec_(twid,twid) then to E chop -halfline + } + move to C + for i = 0 to 3 do {{ + Point_(i*90) + for_(-1,1,2, + `{ line from rvec_(polewid/2,m4x*polewid/2) \ + to rvec_(medrad*2/3,m4x*polewid/2) \ + then to rvec_(medrad*2/3,m4x*(polewid/2+polewid/5)) \ + chop -halfline chop 0 + { move to rvec_(0,-(m4x*polewid/5)) + line from rvec_(-twid/2,m4x*twid/4) to rvec_(-twid/4,m4x*twid/4) \ + then to rvec_(-twid/4,m4x*twid*3/4) \ + then to rvec_(-twid*7/4,m4x*twid*3/4) \ + then to rvec_(-twid*7/4,m4x*twid/4) \ + then to rvec_(-twid/2,m4x*twid/4) } + T: rvec_(srad,0) + arc ifelse(m4x,-1,c)cw to (1+srad/distance(T,C))<C,T> with .c at T + }') + arc cw from last arc.end to 2nd last arc.end with .c at C + }} + + t = distance(C,last arc.s) + "\sf N" at C+(0, t) below + "\sf N" at C+(0,-t) above + "\sf S" at C+(-t,0) ljust + "\sf S" at C+( t,0) rjust + + for i = 0 to windings/2-1 do { + for j = 1 to 2 do { sprintf("$\char%g_%g$",97+i,j) \ + at Rect_(outerrad-twid,180*(2-j)-i*360/windings) } + for j = 1 to 2 do { sprintf("$\char%g_%g'$",97+i,j) \ + at Rect_(outerrad-twid,180*(2-j)-90-i*360/windings) } + } + +.PE diff --git a/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/SampleFlow.m4 b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/SampleFlow.m4 new file mode 100644 index 00000000000..077a0ba6e3c --- /dev/null +++ b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/SampleFlow.m4 @@ -0,0 +1,35 @@ +.PS +# SampleFlow.m4 +darrow_init + +boxwid = 1.9 +boxht = 1.0 +linethick = 1.2 + + define(`dlthick',0.25) + define(`dfillcolor',`0.7,0.7,0.7') + + define rbox {box rad boxht/10} + define offset { with .nw at last box.se+(-0.15,-0.125)} + define indent { at last box.w+(0.1,0)} + define connect { + { Dline(from 2nd last box.s to (2nd last box,last box),E;ends=!-) + dleft + darrow(to last box.w) } } + + command "{\sf\huge" + + B1: rbox + { "Sample" ljust indent "Acquisition" ljust } + B2: rbox offset + {"Sample" ljust indent "Checking" ljust } + connect + B3: rbox offset + {"Dimensionality" ljust at last box.w "Sample Check" ljust } + connect + B4: rbox offset + {"Sample" ljust indent "Synthesis" ljust "Techniques" ljust } + connect + + command "}%" +.PE diff --git a/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/ShadeSector.m4 b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/ShadeSector.m4 new file mode 100644 index 00000000000..0632fdb14f4 --- /dev/null +++ b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/ShadeSector.m4 @@ -0,0 +1,14 @@ +.PS +# ShadedSector.m4 +# https://tex.stackexchange.com/questions/635327/multi-color-circular-gradient-in-tikz + +gen_init +NeedDpicTools + + rx = 4 + n = int(rx/lthick) + for i=1 to n do { left_ + hsvtorgb((1-i/n)*180,1,1,r,g,b) + arc rad i/n*rx with .c at (0,0) outlined rgbstring(r,g,b) } + +.PE diff --git a/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Shadow.m4 b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Shadow.m4 new file mode 100644 index 00000000000..1ad65d8eb43 --- /dev/null +++ b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Shadow.m4 @@ -0,0 +1,129 @@ +.PS +# Shadow.m4 +gen_init +NeedDpicTools +s_init(HSV) + +divert(-1) + `shadowellipse(options,text) + Draws a shadowed ellipse + with gradient from white at the top to + hsv-specified color at the bottom + Default is uniform lightgray shade + Arg 2 is a text label written at the center' +define(`shadowellipse',`[ Orig: Here + m4shadow_keys(`$1') + [ + ellipse wid m4wid ht m4ht invis shaded m4shadow ] wid 0 ht 0 \ + at (m4shadowthick+m4thick bp__/2,-(m4shadowthick+m4thick bp__/2)) +# at ((m4shadowthick)/2,-(m4shadowthick)/2) +ifelse(m4hue,,,` + define pElBshade { v = m4ht*($`'1) + if v < m4rad then { h = (m4wid/2-m4rad)+sqrt(m4rad^2-(m4rad-v)^2) } \ + else { if v < m4ht-m4rad then { h = m4wid/2 } \ + else { h = (m4wid/2-m4rad)+sqrt(m4rad^2-(m4rad-(m4ht-v))^2) } } + line from (-h,v) to (h,v) thick m4thick outlined rgbstring($`'2,$`'3,$`'4) + } + nsteps = rnd(m4ht/(m4thick bp__)*1.1) + hsvtorgb(m4hue,m4sat,m4val,r,g,b) + ShadeObject(pElBshade,nsteps, + 0, r, g, b, + 1, 1, 1, 1) with .c at Orig ') + Ellipse: ellipse ht m4ht wid m4wid thick m4thick outline m4outlined \ + at Orig ifelse(m4hue,,shaded m4shaded) + ifelse(`$2',,,`m4lstring(`$2',"`$2'") at Ellipse') + `$3']') + `shadowbox(options,text) Draws a shadowed box + with gradient from white at the top to + hsv-specified color at the bottom + Default is uniform lightgray shade + Arg 2 is a text label written at the center' +define(`shadowbox',`[ Orig: Here + m4shadow_keys(`$1') + [ + box invis rad m4rad ht m4ht wid m4wid shaded m4shadow ] wid 0 ht 0 \ + at (m4shadowthick+m4thick bp__/2,-(m4shadowthick+m4thick bp__/2)) +# box rad m4rad+m4thick bp__/2+m4shadowthick/2 ht m4ht wid m4wid \ +# thick m4shadowthick/(1bp__) outlined m4shadow ] wid 0 ht 0 \ +# at ((m4shadowthick+m4thick bp__)/2,-(m4shadowthick+m4thick bp__)/2) +ifelse(m4hue,,,` + define pBxBshade { v = m4ht*($`'1) + if v < m4rad then { h = (m4wid/2-m4rad)+sqrt(m4rad^2-(m4rad-v)^2) } \ + else { if v < m4ht-m4rad then { h = m4wid/2 } \ + else { h = (m4wid/2-m4rad)+sqrt(m4rad^2-(m4rad-(m4ht-v))^2) } } + line from (-h,v) to (h,v) thick m4thick outlined rgbstring($`'2,$`'3,$`'4) + } + nsteps = rnd(m4ht/(m4thick bp__)*1.1) + hsvtorgb(m4hue,m4sat,m4val,r,g,b) + ShadeObject(pBxBshade,nsteps, + 0, r, g, b, + 1, 1, 1, 1) with .c at Orig ') + Box: box rad m4rad ht m4ht wid m4wid thick m4thick outline m4outlined \ + at Orig ifelse(m4hue,,shaded m4shaded) + ifelse(`$2',,,`m4lstring(`$2',"`$2'") at Box') + `$3']') +define(`m4shadow_keys', +# Box size parameters +`setkey_(`$1',ht,boxht)dnl + setkey_(`$1',wid,boxwid)dnl + setkey_(`$1',rad,boxht/8)dnl + setkey_(`$1',thick,linethick)dnl +# Shadow thickness + setkey_(`$1',shadowthick,2*lthick)dnl +# HSV color for gradient shading + setkey_(`$1',hue)dnl Default is blank for a shade fill; + setkey_(`$1',sat,1)dnl + setkey_(`$1',val,1)dnl +# Named colors + setkey_(`$1',shaded,"lightgray",N)dnl + setkey_(`$1',outlined,"gray",N)dnl + setkey_(`$1',shadow,"lightgray",N)dnl +') + +divert(0)dnl + +w = 0.3 +boxwid = w +dh = 30 +# Hue from 0 to 360 +T:[ for i=0 to 361 by dh do { shadowbox(hue=i) } ] + { s_box(hue=0) at T.w rjust; s_box(hue=360) at T.e ljust } + { for i=0 to 361 by dh do { s_box("%g",i) at T.nw+(w/2+i/dh*w,0) above } } + { s_box(hue) at T.n+(0,12bp__) above } + +# Hue from 0 to 360; sat=0.5; val=0.5 +Ta:[ for i=0 to 361 by dh do { shadowbox(hue=i;sat=0.5;val=0.5) } ] \ + with .nw at last [].sw + { s_box(`\shortstack[r]{sat=0.5\\val=0.5}') at Ta.w rjust } + +# Hue = 0; sat=0 to 1 +U:[ for i=0 to 361 by dh do { shadowbox(hue=0;sat=i/360) } ] \ + with .nw at last [].sw + { s_box(`\shortstack[r]{hue=0\\sat=0}') at U.w rjust + s_box(sat=1) at U.e ljust } + +# Hue = 0; val=0 to 1 +V:[ for i=0 to 361 by dh do { shadowbox(hue=0;val=i/360) } ] \ + with .nw at last [].sw + { s_box(`\shortstack[r]{hue=0\\val=0}') at V.w rjust + s_box(val=1) at V.e ljust } + +# Miscellaneous +W:[ + shadowbox + DefineRGBColor(verylight,0.95,0.95,0.95); shadowbox(shaded=verylight) + shadowbox(hue=0;val=0) + DefineHSVColor(cx,110,0.5,0.5); shadowbox(shaded=cx) + shadowbox(shaded="yellow") + DefineHSVColor(lx,120,0.4,0.5); shadowbox(hue=120;sat=0.3;val=0.2;shadow=lx) + ] with .nw at last [].sw + +ellipsewid = w +#linethick = 5 +X:[ + shadowellipse(shadowthick=lthick) + ellipse thick 5 + ellipse thick 5 shaded "gray" + ] with .nw at last [].sw+(0,-0.1) + +.PE diff --git a/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Shaky.m4 b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Shaky.m4 new file mode 100644 index 00000000000..81364cf515e --- /dev/null +++ b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Shaky.m4 @@ -0,0 +1,115 @@ +.PS +# Shaky.m4 +gen_init +NeedDpicTools +divert(-1) + `An attempt to draw shaky hand-drawn lines' + + `shakyline(linespec,type,shake=val,[shakevals]) + Draw a line with a tremor + arg3: shake parameter (default 1) + arg4=normal(0,1) perturbations used if given' +define(`shakyline', +`rpoint_(ifelse(`$1',,`to rvec_(linewid,0)',`$1')) + L_start_: last line.start + L_end_: last line.end + [ Start: L_start_ + End: L_end_ + llen = distance(Start,End) + npts = round_(llen/linewid*4) + pushkey_(`$3',shake,1)dnl + sval = m4shake*llen/npts/8 + if "$4"=="" then { randn(d,npts-1,0,sval) }\ + else { for i=1 to npts-1 do { d[i] = $4[i]*sval) }} + P[0]: Start + for i=1 to npts-1 do { P[i]: i/npts between Start and End + vec_(0,d[i]) } + P[npts]: End + spline ifdpic(ifelse(`$2',,ctension_)) $2 from P[0] to P[1] + for i=2 to npts do { continue to P[i] } popdef(`m4shake') + ] with .Start at L_start_; move to L_end_') + + `shakyarc(arcspec,type,shake=val,[shakevals]) + Draw an arc with a tremor + arg3: s=shake parameter (default 1) + arg4=normal(0,1) perturbations used if given' +define(`shakyarc', +`arc invis $1 + A_start_: last arc.start + A_end_: last arc.end + A_C_: last arc.c + [ Start: A_start_ + End: A_end_ + C: A_C_ + as = atan2(Start.y-C.y,Start.x-C.x) + ae = atan2(End.y-C.y,End.x-C.x) + ar = distance(Start,C) + llen = abs(ar*(ae-as)) + npts = round_(llen/linewid*4) + pushkey_($3,shake,1)dnl + sval = m4shake*llen/npts/8 + if "$4"=="" then { randn(d,npts-1,0,sval) }\ + else { for i=1 to npts-1 do { d[i] = $4[i]*sval }} + P[0]: Start + for i=1 to npts-1 do { P[i]: C + (rect_(ar+d[i],as+i/npts*(ae-as))) } + P[npts]: End + spline ifdpic(ifelse(`$2',,ctension_)) $2 from P[0] to P[1] + for i=2 to npts do { continue to P[i] } popdef(`m4shake') + ] with .Start at last arc.start; move to last arc.end') + + `shakyfitcurve(V,n,linetype, + m (default 0),shake=val,[shakevals]) + Like fitcurve but the control points + are perturbed + arg5: s=shake parameter (default 1) + arg6=normal(0,1) perturbations used if given' +define(`shakyfitcurve',` + [ m4fn = ifelse(`$2',,2,`$2'); m4fm = ifelse(`$4',,0,`$4') + pushkey_($5,shake,1)dnl + if "$6"=="" then { randn(d,2*(m4fn-m4fm-1),0,m4shake) }\ + else { for i=1 to 2*(m4fn-m4fm-1) do { d[i] = $6[i]*m4shake }} + M4PP_[0]: `$1'[m4fm] + for i=m4fm+1 to m4fn-1 do { M4PP_[i-m4fm]: `$1'[i] dnl + +(d[2*(i-m4fm-1)+1],d[2*(i-m4fm-1)+2])\ + *distance(M4PP_[i-m4fm-1],`$1'[i])/16 } + M4PP_[m4fn-m4fm]: `$1'[m4fn]; End: M4PP_[m4fn-m4fm] + fitcurve(M4PP_,m4fn-m4fm) popdef(`m4shake') + ] with .M4PP_[0] at `$1'[ifelse(`$4',,0,`$4')]; move to last [].End ') + + +divert(0) + +P1: [ + linethick = 2.5 + round(,,colored "gray") + nl = 10 + for i=0 to nl do { + shakyline(right 6/nl up 2*(2*pmod(i,2)-1),,shake=2) + {sprintf("%g",2-i/nl*2) at 1/2 between L_start_ and L_end_ } + round(,,colored "gray") } + ] + +P2: [ + linethick = 2.5 + na = 3 + arcrad = 1 + for i=1 to na do { + shakyarc(,colored "gray",shake=2) + } + ] with .nw at last [].sw +(0,-1) + +P3: [ + linethick = 2.5 + na = 3 + arcrad = 2 + for i=1 to na do { + shakyarc(,colored "gray",shake=2) + } + ] with .w at last [].e +(1,0) +P4: [ + n = 0 + for a=0 to 359 by 30 do { V[n]: (Rect_(1,a)); n+=1 } + V[n]: V[0] + shakyfitcurve(V,n,,,shake=1) + ] with .nw at P2.sw + (0,-0.5) + +.PE diff --git a/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Star.m4 b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Star.m4 new file mode 100644 index 00000000000..0817236d19f --- /dev/null +++ b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Star.m4 @@ -0,0 +1,38 @@ +.PS +# Star.m4 +# https://tex.stackexchange.com/questions/605132/how-can-i-insert-a-nine-pointed-star-in-a-latex-document +gen_init + +# star(keys) +# keys: size=expr; +# points=expr; +# angle=expr; last convex vertex ang +# depth=expr; inner vertex fraction +# line=attributes; +define(`star',`[ pushkeys_(`$1', + `size:linewid; points:5; angle:90; depth:1/(m4points-1); line::N') + dang = 360/m4points + T: (Rect_(m4size/2*m4depth,m4angle+dang/2)) # concave inner vertex + S: 1/2 between T and (Rect_(m4size/2,m4angle)) + U: (Rect_(m4size/2,m4angle+dang)) # convex outer vertex + line m4line from S to T then to U + for i=1 to m4points-1 do { + T: (Rect_(m4size/2*m4depth,m4angle+i*dang+dang/2)) + U: (Rect_(m4size/2,m4angle+(i+1)*dang)) + continue to T then to U } + continue to S; popdef(`size',`points',`angle',`depth',`m4line')]') + +linewid = linewid*2 +ifelse(1,1,` +star +star(size=1) +star(points=4) +star(depth=1/4) +star(line=outlined "red") +star(points=8) +star(points=9;line=outlined "red" shaded "magenta") +') +#for_(3,8,1,` +#star(points=m4x;line=outlined "red" shaded "magenta")') + +.PE diff --git a/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Stator.m4 b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Stator.m4 new file mode 100644 index 00000000000..fc74a111e7d --- /dev/null +++ b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Stator.m4 @@ -0,0 +1,54 @@ +.PS +# Stator.m4 +# https://tex.stackexchange.com/questions/612620/how-to-paint-inside-a-set-of-lines +gen_init +scale = 0.5 + + outerwid = 5/2 + innerwid = 3.7/2 + nteeth = 32 + toothdepth = (innerwid/2)*(twopi_/nteeth) + statordepth = toothdepth*4 + viewangle = 30 + outershade = 0.9 + topshade = 0.8 + innershade = 0.6 + toothshade = 0.5 + + cv = cosd(viewangle) + sv = sind(viewangle) + define ang { ($1)/nteeth*twopi_ } + + T: (0,statordepth*cv) + Tc: (0,toothdepth*cv) + for i = 0 to nteeth/2 do { for j=1 to -1 by -2 do { # Shaded tooth walls + P: (cos(ang(i)+pi_/2)*j,sin(ang(i)+pi_/2)*sv)*outerwid/2 + Q: P*innerwid/outerwid + line from P to P+Tc then to Q+Tc then to Q then to P \ + shaded rgbstring(toothshade,toothshade,toothshade) } } + shade(innershade, # inner arc and teeth + E: ellipsearc(innerwid,innerwid*sv,pi_,0,0,cw) with .C at T + move to (innerwid/2,0) + toothht = toothdepth*cv + for i = 0 to nteeth/2 do { + line up toothht + ellipsearc(innerwid,innerwid*sv,ang(i),ang(i+1),0,ccw) with .Start at Here + move to last [].End + toothht = -toothht } ) + shade(outershade, # outer arc and teeth + E: ellipsearc(outerwid,outerwid*sv,0,pi_,0,cw) with .C at T + line down statordepth*cv from E.End + toothht = toothdepth*cv + for i = nteeth/2 to nteeth-1 do { + line up toothht + ellipsearc(outerwid,outerwid*sv,ang(i),ang(i+1),0,ccw) with .Start at Here + move to last [].End + toothht = -toothht } + line up statordepth*cv from E.Start-T ) + for r=innerwid to outerwid by lthick*2 do { # shade the top + ellipse wid r ht r*sv with .c at T \ + outlined rgbstring(topshade,topshade,topshade) } + ellipse wid outerwid ht outerwid*sv with .c at T + ellipse wid innerwid ht innerwid*sv with .c at T + +.PE diff --git a/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/TR_fill.m4 b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/TR_fill.m4 new file mode 100644 index 00000000000..bf3fae888c0 --- /dev/null +++ b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/TR_fill.m4 @@ -0,0 +1,17 @@ +.PS +# TR_fill.m4 +# https://tex.stackexchange.com/questions/654117/fill-parts-of-a-shape +gen_init + + B: (0,0); "B" at B below + C: (5,0); "C" at C below + A: Cintersect(B,4,C,3); "A" at A above + line from B to C then to A then to B + RightAngle(B,A,C,0.25) + + rgbfill(0.5,0.5,0.5, + arc from A to B rad 2 + arc cw to C rad 2.5 + arc to A rad 1.5 ) + +.PE diff --git a/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Views.m4 b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Views.m4 new file mode 100644 index 00000000000..c02c9a48172 --- /dev/null +++ b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Views.m4 @@ -0,0 +1,304 @@ +.PS +# Views.m4 +threeD_init + +sinclude(Lettering.m4def) +sinclude(../Lettering.m4def) +Letter_init + +define(`textwidth',5.5) + +`# Perspective transformations +# mult4( matrix, vector, vector ) + define mult4 { for i=1 to 4 do { + $3[i] = 0 + for j=1 to 4 do { $3[i] = $3[i] + $1[(j-1)*4+i]*$2[j] }}} +# eye4 make unit matrix + define eye4 { for i=1 to 4 do { for j=1 to 4 do { $1[(j-1)*4+i] = 0 }}} +# rotx4( theta, vector, vector ) + define rotx4 { $3[1] = $2[1] + $3[2] = cos($1)*$2[2]-sin($1)*$2[3] + $3[3] = sin($1)*$2[2]+cos($1)*$2[3] + $3[4] = $2[4] } +# roty4( theta, vector, vector ) + define roty4 { $3[1] = cos($1)*$2[1]-sin($1)*$2[3] + $3[2] = $2[2] + $3[3] = sin($1)*$2[1]+cos($1)*$2[3] + $3[4] = $2[4] } +# rotz4( theta, vector, vector ) + define rotz4 { $3[1] = cos($1)*$2[1]-sin($1)*$2[2] + $3[2] = sin($1)*$2[1]+cos($1)*$2[2] + $3[3] = $2[3] + $3[4] = $2[4] } +# add4( vector, vector, vector ) + define add4 { + if (($1[4]==0) && ($2[4]==0)) then { + for i=1 to 4 do { $3[i] = $1[i]+$2[i] } } \ + else { if $1[4]==0 then { for i=1 to 4 do { $3[i] = $1[i] } } \ + else { if $2[4]==0 then { for i=1 to 4 do { $3[i] = $2[i] } } \ + else { for i=1 to 3 do { $3[i] = $1[i]/$1[4]+$2[i]/$2[4] }; $3[4] = 1 } + } } } + +# vec4( x,y,z, vector ) + define vec4 { $4[1] = $1; $4[2] = $2; $4[3] = $3; $4[4] = 1 } +# copy4( vector, vector ) + define copy4 { $2[1] = $1[1]; $2[2] = $1[2]; $2[3] = $1[3]; $2[4] = $1[4] } +# pr4( vector, label ) + define pr4 { if $1[4]==0 then { print "Divide by zero" } \ + else { $2: pr($1[1]/$1[4],$1[2]/$1[4],$1[3]/$1[4]) }} + + define print4 { print sprintf("%g,%g,%g,%g",$1[1],$1[2],$1[3],$1[4]) } +' +# Basic dimensions + u = 1*27/28.7*0.7 ifdef(`xsnotes',`*1.14') + a = 2*u + b = 1*u + c = 1.2*u + d = c*1/2 + e = c/3 + f = u*1/4 + r = c/3 + + visibleth = 1.2 + dimensionth = 0.4 + hiddenth = dimensionth + linethick_(visibleth) + +# Iso diagram viewing angle +dazim = 45 +delev = -30 +setview(dazim,delev) + +define(`pr',`(project(`$3',`$1',`$2'))') +define(`xpnd',$1) + + define(`X0', `0,0,0') + define(`X1', `0,b,0') + define(`X2', `a,b,0') + define(`X3', `a,0,0') + define(`X4', `0,0,c') + define(`X5', `0,b,c') + define(`X6', `a,b,c') + define(`X7', `a,0,c') + define(`X8', `-e,0,c/2-f/2') + define(`X9', `-e,d,c/2-f/2') + define(`X10',`0,d,c/2-f/2') + define(`X11',`0,0,c/2-f/2') + define(`X12',`-e,0,c/2+f/2') + define(`X13',`-e,d,c/2+f/2') + define(`X14',`0,d,c/2+f/2') + define(`X15',`0,0,c/2+f/2') + define(`X16',`0,b*1.25,c') + define(`X17',`a/4,b*1.25,c') + define(`X18',`a/4,b,c') + define(`X19',`0,b,c/2') + define(`X20',`a/4,b,c/2') + define(`xn',20) + + define(`ncirc',18) + dt = 360/ncirc + tx = a*2/3; ty = b; tz = c/2 + define(`TR',`tx,ty,tz') + +define(`loopX',`ifelse(eval(`$1'>=0),1, + `define(`X'eval(`$1'+xn+1),`tx+r*cosd(`$1'*dt),ty,tz+r*sind(`$1'*dt)') + loopX(eval($1-1))')') + + loopX(ncirc) + +define(`loopTT',`ifelse(eval(`$1'>=0),1, + `TT[`$1']: ifelse(`$3',0,`pr(X$2)',`Y$2') + loopTT(eval(`$1'-1),eval(`$2'-1),`$3')')') + +define(`drawobj',` + line from pr(xpnd(`$1'0)) to pr(xpnd(`$1'1)) to pr(xpnd(`$1'2)) + line to pr(xpnd(`$1'3)) to pr(xpnd(`$1'0)) + line from pr(xpnd(`$1'0)) to pr(xpnd(`$1'11)) to pr(xpnd(`$1'8)) \ + to pr(xpnd(`$1'12)) to pr(xpnd(`$1'13)) + line to pr(xpnd(`$1'9)) to pr(xpnd(`$1'8)) + line from pr(xpnd(`$1'13)) to pr(xpnd(`$1'14)) to pr(xpnd(`$1'10)) + line to pr(xpnd(`$1'9)) + line from pr(xpnd(`$1'10)) to pr(xpnd(`$1'11)) + ifelse(`$2',0, + `shade(0.92,line width 0 from pr(xpnd(`$1'1)) to pr(xpnd(`$1'5)) \ + to pr(xpnd(`$1'6)) to pr(xpnd(`$1'2)) to pr(xpnd(`$1'1))) + perspective(X1,Z) + ellipse fill_(0.7) ht 2*r*tmx[2]/tmx[4]/b wid 2*r at pr(TR) + shade(1,line width 0 from pr(xpnd(`$1'19)) to pr(xpnd(`$1'16)) \ + to pr(xpnd(`$1'17)) to pr(xpnd(`$1'20)) to pr(xpnd(`$1'19))) + shade(0.7,line width 0 from pr(xpnd(`$1'0)) to pr(xpnd(`$1'1)) \ + to pr(xpnd(`$1'2)) to pr(xpnd(`$1'3)) to pr(xpnd(`$1'0))) + shade(0.6,line width 0 from pr(xpnd(`$1'0)) to pr(xpnd(`$1'1)) \ + to pr(xpnd(`$1'19)) to pr(xpnd(`$1'16)) to pr(xpnd(`$1'4)) \ + to pr(xpnd(`$1'0))) + shade(0.9,line width 0 from pr(xpnd(`$1'13)) to pr(xpnd(`$1'14)) \ + to pr(xpnd(`$1'10)) to pr(xpnd(`$1'9)) to pr(xpnd(`$1'13))) + shade(0.7,line width 0 from pr(xpnd(`$1'8)) to pr(xpnd(`$1'9)) \ + to pr(xpnd(`$1'10)) to pr(xpnd(`$1'11)) to pr(xpnd(`$1'8))) + shade(0.6,line width 0 from pr(xpnd(`$1'8)) to pr(xpnd(`$1'9)) \ + to pr(xpnd(`$1'13)) to pr(xpnd(`$1'12)) to pr(xpnd(`$1'8))) + A: line invis from pr(xpnd(`$1'4)) to pr(xpnd(`$1'0)) + B: line invis from pr(xpnd(`$1'12)) to pr(xpnd(`$1'13)) + line from Intersect_(A,B) to pr(xpnd(`$1'4)) + line from pr(xpnd(`$1'4)) to pr(xpnd(`$1'16))', + + `A: line invis from pr(xpnd(`$1'4)) to pr(xpnd(`$1'16)) + B: line invis from pr(xpnd(`$1'14)) to pr(xpnd(`$1'13)) + line from Intersect_(A,B) to pr(xpnd(`$1'16)) + line thick dimensionth from pr(xpnd(`$1'2)) to -0.5 between \ + pr(xpnd(`$1'2)) and pr(xpnd(`$1'1)) chop 0.05 + line thick dimensionth from pr(xpnd(`$1'3)) to -0.5 between \ + pr(xpnd(`$1'3)) and pr(xpnd(`$1'0)) chop 0.05 + line thick dimensionth from pr(xpnd(`$1'5)) to -1.0 between \ + pr(xpnd(`$1'5)) and pr(xpnd(`$1'1)) chop 0.05 + line thick dimensionth from pr(xpnd(`$1'4)) to -1.0 between \ + pr(xpnd(`$1'4)) and pr(xpnd(`$1'0)) chop .1 chop 0.05 + loopTT(ncirc,eval(xn+ncirc+1),`$2') + fitcurve(TT,ncirc) + ') + line from pr(xpnd(`$1'16)) to pr(xpnd(`$1'19)) \ + to pr(xpnd(`$1'20)) to pr(xpnd(`$1'17)) to pr(xpnd(`$1'16)) + line from pr(xpnd(`$1'19)) to pr(xpnd(`$1'1)) + A: line invis from pr(xpnd(`$1'5)) to pr(xpnd(`$1'6)) + B: line invis from pr(xpnd(`$1'17)) to pr(xpnd(`$1'20)) + line from Intersect_(A,B) to pr(xpnd(`$1'6)) + line from pr(xpnd(`$1'6)) to pr(xpnd(`$1'2)) + ') + + dp = 1.0*a + s4f = 1.6 + fth = 180*dtor_ + +# perspective(x,y,z,position) +`define perspective { + vec4($3,$1,$2,tmp) + roty4(180*dtor_,tmp,tmx) + rotz4(90*dtor_,tmx,tmp) + rotx4(-90*dtor_,tmp,tmx) + roty4(-45*dtor_,tmx,tmp) + tmp[4] = tmp[3]/dp+tmp[4] + rotx4(55*dtor_,tmp,tmx) + $4: (tmx[1]/tmx[4],tmx[2]/tmx[4]) + } +' +lu = 0.1/6 * 0.8 + +# Handle forward referencing of lettering guide line lengths + nguides = 0 + sh "touch Views.dms" + for i=1 to 10 do { w[i] = 1 } + copy "Views.dms" + sh "rm -f Views.dms" + +define(`guideletter',`[ nguides += 1 + line thick grthick from (0,0) right w[nguides]*lu outlined "lightgridgray" + line thick grthick from (0,-6*lu) right w[nguides]*lu outlined "lightgridgray" + T: $1 with .nw at (0,0) + print sprintf("w[%g]=%g",nguides,T.wid/lu) >> "Views.dms" +]') + +define(`pfront',`(`$1',`$2')') +define(`ptop',`(`$1',`$3')') +define(`pside',`(-(`$3'),`$2')') + sep = 0.6*u +define(`centreline',`rpoint_(ifelse(`$1',,`to rvec_(linewid,0)',`$1')) + line thick dimensionth to rvec_(rp_len/2-.08,0) + move to rvec_(.03,0) + line thick dimensionth to rvec_(.1,0) + move to rvec_(.03,0) + line thick dimensionth to rvec_(rp_len/2-.08,0)') + +Orthographics: [ +Top: [ + line from ptop(X1) to ptop(X5) to ptop(X6) to ptop(X2) to ptop(X1) + line from ptop(X17) to ptop(X20) to ptop(X19) + line from ptop(X10) to ptop(X9) to ptop(X13) to ptop(X14) + circle rad r at ptop(TR) + centreline(from ptop(TR)+(0,r) down 2*r chop -.1) + centreline(from ptop(TR)+(-r,0) right 2*r chop -.1) + W: ptop(X9) + E: ptop(X2) + ] +Front: [ + line from pfront(X0) to pfront(X1) to pfront(X2) to pfront(X3) to pfront(X0) + line from pfront(X0) to pfront(X8) to pfront(X9) to pfront(X10) + line from pfront(X19) to pfront(X16) to pfront(X17) to pfront(X20) + line thick hiddenth dashed from pfront(TR)+(-r,0) down b + line thick hiddenth dashed from pfront(TR)+( r,0) down b + centreline(from pfront(TR) down b chop -.1) + W: pfront(X9) + E: pfront(X2) + N: pfront(X16) + S: pfront(X8) + ] with .nw at Top.sw+(0,-sep) + +Side: [ + line from pside(X0) to pside(X4) to pside(X16) to pside(X19) to pside(X1) \ + to pside(X0) to pside(X4) + line from pside(X12) to pside(X13) to pside(X9) to pside(X8) + line thick hiddenth dashed from pside(X5) to pside(X19) + line thick hiddenth dashed from pside(TR)+(-r,0) down b + line thick hiddenth dashed from pside(TR)+( r,0) down b + centreline(from pside(TR) down b chop -.1) + N: pside(X16) + S: pside(X0) + ] with .ne at Front.nw+(-sep,0) + +if 1 then { + linethick_(0.8) + guideletter([Letters(`F R O N T8V I5E1W')]) with .n at Front.s+(0,-.05) + guideletter([Letters(`S4I5D4E8V I5E1W')]) with .n at Side.s+(0,-.05) + guideletter([Letters(`T O4P8V I5E1W')]) with .n at Top.s+(0,-.10) + linethick_(visibleth) +} + + line thick dimensionth from Side.N to Front.N chop 0.05 + line thick dimensionth from Side.S to Front.S chop 0.05 + line thick dimensionth from Top.W to Front.W chop 0.05 + line thick dimensionth from Top.E to Front.E chop 0.05 + + ] # End Orthographics + +define(`looppersp',`ifelse(eval(`$1'>=0),1,`perspective(xpnd(X`$1'),Z`$1') + Y`$1': (cos(fth)*Z`$1'.x-sin(fth)*Z`$1'.y,\ + sin(fth)*Z`$1'.x+cos(fth)*Z`$1'.y)*s4f + looppersp(eval($1-1))')') + +if 1 then { +Perspective: [ + pushdef(`pr',`$1') + right_ + looppersp(eval(xn+ncirc+1)) + drawobj(Y,1) + popdef(`pr') +# ] with .sw at Isometric.ne+(-3.5*sep,0) + ] with .se at Orthographics.sw+(-1.5*sep,0) + + linethick_(0.8) + guideletter([[Letters(T2W O)]; move right lu; line right 4*lu; move right lu + [Letters(P O4I5N T8P E R S P E C T I V E)]])\ + with .w at Perspective.s+(.2*u,0) + linethick_(visibleth) +} + +if 1 then { +# Pictorials: +Isometric: [ + drawobj(X,0) +# command "{\small" +# define(`loopprt',`ifelse(eval(`$1'>=0),1,`"`$1'" at pr(X$1) +# loopprt(eval($1-1))')') +# loopprt(xn) +# for i=0 to ncirc do { sprintf("%g",i) at TT[i] } +# command "}%" +#] with .sw at (Orthographics.e+(-textwidth,0),Orthographics.Side.sw+(0,0.1)) +#] at Orthographics.nw + ] with .s at Perspective.n+(0,0.2) + + linethick_(0.8) + guideletter([Letters(`S4H2A2D E D8I S O M5E2T2R5I C8V I5E1W')])\ + with .w at Isometric.s+(.2*u,0) #(0,-.2) + linethick_(visibleth) +} + +.PE diff --git a/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Wheat.m4 b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Wheat.m4 new file mode 100644 index 00000000000..c70fa8fc74d --- /dev/null +++ b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Wheat.m4 @@ -0,0 +1,21 @@ +.PS +# `Wheat.m4' +gen_init + +boxwid = boxht + +[ for j = 0 to 7 do { + for i = 0 to 7 do { + x = 2^(j+8*i) + box fill_((i+j)%2) at (j*boxwid,-i*boxwid) + k = ((i+j)%2==0); setrgb(k,k,k) + if x < 10000 then { sprintf("\Large$%g$",x) at last box } \ + else { y = int(log(x)) + sprintf("{\Large$%g$}$\cdot 10^{%g}$",round_(x/(10^y)),y) at last box } + resetrgb + } + } + ] +box wid 8*boxwid ht 8*boxwid at last [] + +.PE diff --git a/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Wheel.m4 b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Wheel.m4 new file mode 100644 index 00000000000..934c4c46dbd --- /dev/null +++ b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Wheel.m4 @@ -0,0 +1,20 @@ +.PS +# Wheel.m4 +# https://tex.stackexchange.com/questions/605178/drawing-a-directed-wheel-graph-with-tikz +gen_init + + linethick = 1.6 + nnodes = 9 + brad = 2 + srad = circlerad/2 + P: circle rad srad at (1,0.5) fill_(0.75) + A: Rect_(brad,90+360/nnodes) + for i=1 to nnodes do { + B: circle invis shaded "lightgray" at Rect_(brad,90-(i-1)/nnodes*360) \ + sprintf("\Huge %g",i) + line from B to P chop circlerad chop srad + line from B to A chop + A: B + } + +.PE diff --git a/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Y14-5_example.m4 b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Y14-5_example.m4 new file mode 100644 index 00000000000..cb4397516c3 --- /dev/null +++ b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Y14-5_example.m4 @@ -0,0 +1,53 @@ +.PS +# Y14-5_example.m4 +# https://en.wikipedia.org/wiki/Geometric_dimensioning_and_tolerancing +cct_init +textht = 11bp__*2/3 +command "{\sf" +sinclude(ASME_Y14-5.m4def) +sinclude(../ASME_Y14-5.m4def) + + boxht = 7.5/0.5*textht + boxwid = 15/7.5 * boxht + circlerad = 2.3/0.5*textht*0.5 + thicklines_(1) + arrowht = textht*0.8 + arrowwid = textht*0.6 + + Box: box + Circle: circle at Box.c; {CM: move from Circle.se down textht right textht} +thinlines_ +CLV: ctrline( up_ Box.ht with .c at Box.c, Box.ht/2 ) +CLH: ctrline( right Box.ht with .c at Box.c, Box.ht/2 ) + + dimension_(from Box.nw to Box.n,Box.ht/6) + thicklines_(1) + {Y14_frame("10") with .s at AS_C+(0,textht/2)} + thinlines_ + line from 3rd last line.start to CLV.end + dimension_(from Box.w to Box.nw,Box.ht/6) + thicklines_(1) + {Y14_frame("5") with .e at AS_C+(-textht/2,0)} + thinlines_ + line from 4th last line.start to CLH.start + +thicklines_ + DA: Y14_frame("A") at Box.ne+(-textht*1.5,textht*5) + datumarrow(from DA.s to (DA,Box.n)) + DB: Y14_frame("B") at Box.sw+(-textht*5,textht*2) + datumarrow(from DB.e to (Box.w,DB)) + + F: Y14_frame(Y14_pos_, + Y14_dia_;"0.03";"(M)", + "A","B","C") with .w at Box.se+(-textht*4,-textht*2) + G: Y14_frame(Y14_fla_,Y14_cyl_,Y14_lin_, + Y14_sur_,Y14_per_,Y14_ang_, + Y14_par_) with .nw at F.sw+(0,-0.1) + H: Y14_frame(Y14_pos_,Y14_cir_,Y14_tot_,Y14_dia_) \ + with .nw at G.sw+(0,-0.1) + + { CB: move left textht from F.w } + arrow <- from Circle.se to Intersect_(CM,CB) then to F.w + + command "}" +.PE diff --git a/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Zcos.m4 b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Zcos.m4 new file mode 100644 index 00000000000..cbf63fd8f39 --- /dev/null +++ b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/Zcos.m4 @@ -0,0 +1,29 @@ +.PS +# Zcos.m4 +gen_init +NeedDpicTools + +# define f1 { ee = expe(8*x*`$1'*(x^2 - (`$1')^2)); +# $2 = ee + 1/ee + 2*cos(2*x^4 + 2*(`$1')^4 - 12*x^2*(`$1')^2) - 4; +# } + +# alternative: |cos(z^4)| = 1 + define f1 { Z: (x,$1) + Z4: Zprod(Zprod(Z,Z),Zprod(Z,Z)) + $2 = zabs(Zcos(Z4)) - 1 + } + + ni = 200 + for i=10 to ni do { x = i/ni*3 + findroot( f1, 0, 0.2, 1e-8, y ) + P[i-10]: x,y } + np = ni-10 + + for deg=0 to 359 by 45 do { + for i=0 to np do { Z[i]: rot_(P[i].x,P[i].y,deg*dtor_) } + fitcurve(Z,np,thick 2 outlined "blue") + for i=0 to np do { Z[i]: rot_(P[i].x,-P[i].y,deg*dtor_) } + fitcurve(Z,np,thick 2 outlined "blue") + } + +.PE diff --git a/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/birds.m4 b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/birds.m4 new file mode 100644 index 00000000000..4b42ea35af6 --- /dev/null +++ b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/birds.m4 @@ -0,0 +1,36 @@ +.PS +# Birds.m4 +gen_init + +scale = 50 +linethick = 2*linethick + +define bird {[ + line shaded "$1" from (0,0) to \ + (10,-5) to (19,8) to (35,7) to (38,-12)+(0,2) to (60,0) to\ + (75,23) to (80,40) to (52,37)+(2,2) to (74,50) to (52,50) to \ + (60,60) to (38,48)+(0,2) to (35,67) to (19,68) to (10,55) to \ + (0,60) to (-8,50) to (14,50) to (-8,37)+(2,2) to (20,40) to \ + (15,23) to (0,0) +E: (80,40) +W: (20,40) +N: (19,68) +S: (19,8) + line outlined "gray" from (35,15) down 10 right 25 + line outlined "gray" from (40,20) right 25 down 8 + line outlined "gray" from (42,25) right 28 down 6 + line outlined "gray" from (40,30) right 32 down 4 + circle outlined "gray" rad 1 at (1,55) + circle outlined "gray" rad 4 at (24,55) +]} + + ncols = 4 + nrows = 4 + right + for i=0 to nrows-1 do { + for j=0 to ncols-1 do { move to (j*60,-i*60) + if (i+j)%2==0 then { bird(black) } else { bird(white) } + } + } + +.PE diff --git a/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/bistable.m4 b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/bistable.m4 new file mode 100644 index 00000000000..ac49023863b --- /dev/null +++ b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/bistable.m4 @@ -0,0 +1,35 @@ +.PS +# `bistable.m4' +cct_init # Default initialization + + up_ +rgbdraw(1,0,0, +Q1: bi_tr(,R) # Q1 upward with base to the right + llabel(,Q_1) ) # Label to left of last [] +rgbdraw(0,0,1, +Q2: bi_tr with .C at Q1.C+(elen_*7/4,0) # Q2 with base to left + rlabel(,Q_2) ) + + ground(at Q1.E) + ground(at Q2.E) + + line right_ dimen_/3 from Q1.B # Extend the base conductors +B1: Here + line left_ dimen_/3 from Q2.B +B2: Here + + resistor(up_ elen_*0.75 from Q1.C); llabel(,"$R_L$" wid 0.16) # Load resistors + line to (Q2.C,Here) "$V_{\hbox{cc}}$" below + resistor(down_ to Q2.C); llabel(,R_L) + + move to Q1.C+(0,dimen_/5) + { resistor(right_ to (B1,Here)); llabel(,R_1) +X: line to B2 } # Label the line to be jumped + resistor(from (Q2.C,Here) left_ to (B2,Here)); rlabel(,R_1) + crossover(to B1,R,X) + + resistor(down_ elen_*0.75); rlabel(,R_2) # Bias resistors + {"$-V_{\hbox{cc}}$" rjust} + line to (B2,Here) + resistor(up_ to B2); rlabel(,R_2) +.PE diff --git a/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/brace.m4 b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/brace.m4 new file mode 100644 index 00000000000..b0089fe96d7 --- /dev/null +++ b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/brace.m4 @@ -0,0 +1,115 @@ +.PS +# brace.m4 +gen_init +NeedDpicTools + +divert(-1) + `bracket(linespec, end depth, + thickness, end thickness, attributes) + Square bracket along linespec + default depth is linewid/5 + attributes = eg + thick 0.4 outlined "string" shaded "string" + (default black)' +define(`bracket',`rpoint_(ifelse(`$1',,`to rvec_(linewid,0)',`$1')) + M4brS: last line.start; M4brE: last line.end + [ brdepth = ifelse(`$2',,linewid/5,`($2)') + brthick = ifelse(`$3',,brdepth/6,`($3)') + endthick = ifelse(`$4',,brthick/3,`($4)') + define(`m4brackattribs', + `ifelse(`$5',,`thick 0.4 shaded rgbstring(0,0,0)',`$5')')dnl + {line m4brackattribs \ + from M4brS+vec_(0,brdepth) to M4brS+vec_(0,brdepth+brthick) \ + then to M4brE+vec_(0,brdepth+brthick) \ + then to M4brE \ + then to M4brE+vec_(-endthick,0) \ + then to M4brE+vec_(-endthick,brdepth) \ + then to M4brS+vec_( endthick,brdepth) \ + then to M4brS+vec_( endthick,0) \ + then to M4brS \ + then to M4brS+vec_(0,brdepth) } + S: M4brS + ] with .S at Here') + + `brace(linespec,depth,arm thickness,attributes) + Curly brace along linespec + default depth is linewid/5 + attributes = eg + thick 0.4 outlined "string" shaded "string" + (default black)' +define(`brace',`rpoint_(ifelse(`$1',,`to rvec_(linewid,0)',`$1')) + M4brS: last line.start; M4brE: last line.end + [ brdepth = ifelse(`$2',,linewid/5,`$2') + brthick = ifelse(`$3',,brdepth/6,`$3') + define(`m4braceattribs', + `ifelse(`$4',,`thick 0.4 shaded rgbstring(0,0,0)',`$4')')dnl + tension = 0.55 + halfwid = distance(M4brS,M4brE) + smallrad = brdepth-brthick + bigrad = brdepth+brthick + for sgn=1 to -1 by -2 do { + S: rvec_(sgn*halfwid/2,0) + A: S+vec_(0,smallrad/2) + B: vec_(0,smallrad/2) + T: vec_(0,brdepth) + C: vec_(0,bigrad/2) + D: vec_(sgn*halfwid/2,bigrad/2) + {spline tension m4braceattribs \ + from S to tension between S and A \ + then to tension between A-vec_(sgn*bigrad/2,0) and A \ + then to A-vec_(sgn*bigrad/2,0) \ + then to B+vec_(sgn*bigrad/2,0) \ + then to tension between B+vec_(sgn*bigrad/2,0) and B \ + then to tension between T and B \ + then to T \ + then to tension between T and C \ + then to tension between C+vec_(sgn*bigrad/2,0) and C \ + then to C+vec_(sgn*bigrad/2,0) \ + then to D-vec_(sgn*bigrad/2,0) \ + then to tension between D-vec_(sgn*bigrad/2,0) and D \ + then to tension between S and D \ + then to S } + } + E: (0,0) +] with .E at 0.5 between M4brS and M4brE') +divert(0)dnl + + del = 0.2 + maxht = 2 + minht = 0.3 + n = 16 + hmax = 360 +R1: [ + for i=0 to n-1 do { + x = i/n + y = minht*(1-x)+maxht*x + hsvtorgb(x*hmax,1,1,r,g,b) + brace(from ( -i*del,-y/2) up y,,,thick 0.4 shaded rgbstring(r,g,b)) + brace(from ((i+1)*del, y/2) down y,,,thick 0.4 \ + outlined rgbstring(r,g,b) shaded rgbstring(r,g,b)) + } + ] +R2: [ + for i=0 to n-1 do { + x = i/n + y = minht*(1-x)+maxht*x + hsvtorgb(x*hmax,1,1,r,g,b) + brace(from ( -i*del,-y/2) up y,5bp__+x*20bp__,2bp__+x*13bp__,thick 0.4 \ + shaded rgbstring(r,g,b)) + brace(from ((i+1)*del, y/2) down y,5bp__+x*20bp__,2bp__+x*13bp__,thick 0.4 \ + outlined rgbstring(r,g,b) shaded rgbstring(r,g,b)) + } + ] with .n at R1.s+(0,-0.2) +R3: [ + for i=0 to n-1 do { + x = i/n + y = minht*(1-x)+maxht*x + hsvtorgb(x*hmax,1,1,r,g,b) + bracket(from ( -i*del,-y/2) up y, 5bp__+x*20bp__, 2bp__+x*13bp__,, + thick 0.4 shaded rgbstring(r,g,b)) + bracket(from ((i+1)*del, y/2) down y, 5bp__+x*20bp__, 2bp__+x*13bp__,, + thick 0.4 outlined rgbstring(r,g,b) shaded rgbstring(r,g,b)) + } + ] with .n at R2.s+(0,-0.2) + +.PE diff --git a/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/chaos.m4 b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/chaos.m4 new file mode 100644 index 00000000000..17ae070e58d --- /dev/null +++ b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/chaos.m4 @@ -0,0 +1,39 @@ +.PS +# chaos.m4 +# Example simulation of chaos equations. +gen_init +scale = 10 +define(`FF',`dnl + `$4' = `$1'+dt*10*(-`$1'+`$2') + `$5' = `$2'+dt*(28*`$1'-`$2'-`$1'*`$3') + `$6' = `$3'+dt*(-8*`$3'/3+`$1'*`$2') ') +[ +x0 = 1 +y0 = 0 +z0 = 0 +dt = 0.005 +nN = 100 +for i = 1 to nN do { + for j = 1 to 8 do { + FF(x0,y0,z0,x1,y1,z1) + FF(x1,y1,z1,x2,y2,z2) + FF(x2,y2,z2,x3,y3,z3) + FF(x3,y3,z3,x4,y4,z4) + spline from x0,y0 to x1,y1 then to x2,y2 then to x3,y3 then to x4,y4 + x0 = x4; y0 = y4; z0 = z4 + } + } +arrow from (-15,0) to (15,0); "$x$" ljust +line up 1 from (10,0); "$ 10$" at last line.start below +line up 1 from (-10,0); "$-10$" at last line.start below +arrow from (0,-15) to (0,15); "$y$" above +line right 1 from (0,10); "$ 10$" at last line.start rjust +line right 1 from (0,-10); "$-10$" at last line.start rjust +"$ 0$" at (0,0) below rjust +] +`"\parbox{2.5in}{\begin{eqnarray*} + \dot{x}_1 & = & 10(-x_1+x_2)\\ + \dot{x}_2 & = & 28x_1-x_2-x_1x_3\\ + \dot{x}_3 & = & -8x_3/3+x_1x_2 + .\end{eqnarray*}}"' at last [].s below +.PE diff --git a/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/hsv.m4 b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/hsv.m4 new file mode 100644 index 00000000000..662184dd7dd --- /dev/null +++ b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/hsv.m4 @@ -0,0 +1,26 @@ +.PS +# hsv.m4 +gen_init +NeedDpicTools + +define grid { (($2)*boxwid,($1)*boxht) } +r = 0 +g = 0 +b = 1 +rgbtohsv(r,g,b,h,s,v) +nstep = 4 +{ for j=0 to nstep do { + sprintf("%g",j/nstep) at ((0.5+j)*boxwid,-boxht/2) below } } + { "S" at ((0.5+nstep/2)*boxwid, -boxht) } +{ for i=0 to nstep do { sprintf("%g",i/nstep) at (-boxht/3,(i)*boxht) } } + { "V" at (-boxht,(nstep/2)*boxht) \ + "or" \ + "L" } +right_ +for v = 0 to nstep do { + { for s = 0 to nstep do { hsvtorgb(h,s/nstep,v/nstep,r,g,b) + box shaded rgbstring(r,g,b) } } + move up_ boxht; right_ } + + +.PE diff --git a/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/person.m4 b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/person.m4 new file mode 100644 index 00000000000..4fdf09d3878 --- /dev/null +++ b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/person.m4 @@ -0,0 +1,45 @@ +.PS +# person.m4 +gen_init + +divert(-1) + `person( + hght=expr;wdth=expr;fill="colorname") + e.g. person(hght=1;fill="gray")' +define(`person', + `[ pushkeys_(`$1',hght:linewid;wdth:m4hght*2/5;fill:"black":N)dnl + bodywid = m4wdth/2 + bodyrad = bodywid/8 + bodyht = (m4hght - bodywid - bodywid/16 + bodyrad*2)/2 + tmplth = linethick; linethick = 0 + Head: circle diam bodywid colored m4fill + Body: box rad bodyrad ht bodyht wid bodywid colored m4fill \ + with .n at Head.s+(0,-Head.diam/16) + armwid = bodywid/3 + Armleft: box wid armwid rad armwid/2 ht Body.ht-bodyrad colored m4fill \ + with .w at Body.e + (armwid/2,0) + Armright: box same with .e at Body.w + (-armwid/2,0) + Legleft: box wid bodywid/2.5 rad armwid/2 ht Body.ht colored m4fill \ + with .n at (Body.w,Body.s)+(bodywid/5,bodyrad*2) + Legright: box same with .n at (Body.e,Body.s)+(-bodywid/5,bodyrad*2) + linethick_(tmplth) popdef(`m4hght',`m4wdth',`m4fill') ]') + +divert(0)dnl + + linewid = 3*linewid + movewid = 0.2 + + setrgb(0.54,0.81,0.94,babyblue) + person(fill="babyblue") + move + person(wdth=linewid*3/4;fill="babyblue") + move + person(wdth=linewid;fill="babyblue") + move + person + move + resetrgb + person(hght=1;fill="gray") + + line up linewid with .c at last [].e+(linewid/10,0) +.PE diff --git a/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/rotellipse.m4 b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/rotellipse.m4 new file mode 100644 index 00000000000..a49ce308b3b --- /dev/null +++ b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/rotellipse.m4 @@ -0,0 +1,20 @@ +.PS +# `rotellipse.m4' +gen_init + +[ + E: ellipse shaded "red" outlined "blue" + + A: rotellipse(1,1,outlined "red" shaded "blue") with .w at E.e + Point_(45) + B: rotellipse(,,dotted fill_(0.9)) + C: rotellipse(,,colored "red") with .s at last [].n + thinlines_ + showbox_(A) + showbox_(B) + showbox_(C) + thicklines_ + +] with .sw at 1,1 + +.PE diff --git a/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/squiggle.m4 b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/squiggle.m4 new file mode 100644 index 00000000000..671ae2addd0 --- /dev/null +++ b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/squiggle.m4 @@ -0,0 +1,26 @@ +.PS +# squiggle.m4 +gen_init + +divert(-1) +dnl Should this macro be in libgen.m4 or would that be just adding clutter? + + `squiggle(linespec, + amplitude,wavelength,attributes)' + `squiggly line (sinusoid), e.g. + squiggle(up_ 1 right_ 2,,,outlined "red")' +define(`squiggle',`rpoint_(ifelse(`$1',,linewid,`$1')) + m4dist = lin_leng(last line) + m4cycles = int(m4dist/(ifelse(`$3',,0.25*scale,`$3'))+0.5) + define(`squiggleampl',`ifelse(`$2',,0.04*scale,`$2')')dnl + define(`squigglefreq',`(twopi_*m4cycles/m4dist)')dnl + sinusoid(squiggleampl,squigglefreq,-twopi_/4,0,m4dist,`$4') \ + with .Origin at last line.start + move to last line.end') +divert(0)dnl + +squiggle(up_ 1 right_ 2,,,outlined "red") +squiggle(up 2 right_ 2,0.1,0.15,outlined "red" <-> wid 0.06 ht 0.05) +squiggle(right_ 1,,,thick 2 dotted outlined "blue" ) + +.PE diff --git a/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/venus.m4 b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/venus.m4 new file mode 100644 index 00000000000..676cd98143d --- /dev/null +++ b/Master/texmf-dist/doc/latex/circuit-macros/examples/extras/venus.m4 @@ -0,0 +1,74 @@ +.PS +# venus.m4 +# https://tex.stackexchange.com/questions/576423/a-more-precise-dance-of-planets-with-metapost-and-tikz +# https://tex.stackexchange.com/questions/575986/dance-of-venus-and-variations-in-tikz-pgf + +gen_init +NeedDpicTools +maxpsht = 20 + +thinlines_ + +define(`venus', +`setkeys_(`$1', + outerlength:4; + innerlength:2.8933; + outerrate:8; + innerrate:13; + maxtimes:2880; + increment:2; + changephase:0 ) + sizefactor = 165/200 + nmaxtimes = 360*m4outerrate + for x=0 to nmaxtimes by m4increment do { + if "$2" != "" then { hue = \ + abs(sind(360*x/nmaxtimes*abs(m4innerrate-m4outerrate)+m4changephase-60)) + hsvtorgb(hue*360,1,1,r,g,b) + line from (Rect_(m4outerlength,x))*sizefactor \ + to (Rect_(m4innerlength,x/m4outerrate*m4innerrate))*sizefactor \ + outlined rgbstring(r,g,b) } \ + else { + line from (Rect_(m4outerlength,x))*sizefactor \ + to (Rect_(m4innerlength,x/m4outerrate*m4innerrate))*sizefactor + } + } ') + +AA:[ + sizefactor = 1/2.54 + define(`venusA',`[ + setkeys_(`$1', + iterations:270; + outerdistance:5.41; + innerdistance:7.48; + outerperiod:123; + innerperiod:200; + step:5) + for x=0 to m4iterations by m4step do { + line from (Rect_(m4outerdistance,x))*sizefactor \ + to (Rect_(m4innerdistance,x/m4outerperiod*m4innerperiod))*sizefactor \ + outlined "gray" + } + ]') + +# 3 columns, 5 rows + sizefactor /= 3 + Orig:(0,0) + for i=1 to 5 do { + iteri = 180 + (i-1)*540 + for j=1 to 3 do { + if (i==1) && (j==1) then { iter = 270 } \ + else { iter = iteri + (j-1)*180 } + V[i,j]: venusA(iterations=iter) with .sw at Orig + sprintf("%g",iter) at last [] #colored rgbstring(1,0,0) + Orig: V[i,j].se + } + Orig: V[i,1].sw-(0,V[i,1].ht) + } + ] + +BB:[ + venus(outerrate=8;innerrate=17;increment=2;innerlength=3.5;changephase=60,T) + ] at AA +# ] with .nw at AA.sw+(0,-0.5) + +.PE |