From 957c819b753dda5b798777721a260a2fcb8660df Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Mon, 30 Apr 2012 13:51:16 -0400 Subject: [PATCH] Add lamp symbols (normal and illuminating) to Circ.asy. --- asymptote/Circ-test.asy | 5 ++++ asymptote/Circ.asy | 61 ++++++++++++++++++++++------------------- 2 files changed, 38 insertions(+), 28 deletions(-) diff --git a/asymptote/Circ-test.asy b/asymptote/Circ-test.asy index e8030e0..44bfc7c 100644 --- a/asymptote/Circ-test.asy +++ b/asymptote/Circ-test.asy @@ -65,6 +65,11 @@ TwoTerminal Sdc = source((0,v), 0, DC, "DC", "5 V"); TwoTerminal Sac = source((u,v), 0, AC, "AC", "5 V$_{pp}$"); TwoTerminal Si = source((2u,v), 0, I, "I", "5 A"); TwoTerminal Sv = source((3u,v), 0, V, "V", "5 V"); +v -= u; + +write("lamp"); +TwoTerminal Ln = lamp((0,v), 0, normal, "indicator", "5\ohm"); +TwoTerminal Li = lamp((u,v), 0, illuminating, "illuminator", "5\ohm"); v -= 1.5u; write("positioning"); diff --git a/asymptote/Circ.asy b/asymptote/Circ.asy index a10cffb..fac3337 100644 --- a/asymptote/Circ.asy +++ b/asymptote/Circ.asy @@ -867,35 +867,40 @@ vardef impedance@#(expr z,ang,name,val)= putlabel(Z@#.l,Z@#.r,.2implth,.2implth,ang,name,val); enddef; -vardef lamp@#(expr z,ang,name,val)= - save ampl, p, q, r, s; - pair La@#.l,La@#.r; % pines % - La@#.l=z; La@#.r=(z+(2ssize,0)) rotatedaround(z,ang); - - picture ampl; ampl=nullpicture; - - addto ampl doublepath z--(z+(.5ssize,0)); - addto ampl doublepath fullcircle scaled ssize shifted (z+(ssize,0)); - addto ampl doublepath (z+(1.5ssize,0))--(z+(2ssize,0)); - - pair p, q, r, s; - p=(-ssize*dir 45 shifted (z+(ssize,0))--(z+(ssize,0))) intersectionpoint - (fullcircle scaled ssize shifted (z+(ssize,0))); - q=(ssize*dir 45 shifted (z+(ssize,0))--(z+(ssize,0))) intersectionpoint - (fullcircle scaled ssize shifted (z+(ssize,0))); - r=(-ssize*dir (-45) shifted (z+(ssize,0))--(z+(ssize,0))) intersectionpoint - (fullcircle scaled ssize shifted (z+(ssize,0))); - s=(ssize*dir (-45) shifted (z+(ssize,0))--(z+(ssize,0))) intersectionpoint - (fullcircle scaled ssize shifted (z+(ssize,0))); - - addto ampl doublepath p--q; - addto ampl doublepath r--s; - - draw ampl rotatedaround(z,ang) withpen line; - - putlabel(La@#.l,La@#.r,.5ssize,.5ssize,ang,name,val); -enddef; +*/ + +real lampsize = ssize; +int illuminating = 1; + +TwoTerminal lamp(pair beg=(0,0), real ang=0, int type=normal, + string name="", string val="", bool draw=true) +{ + path pLine[]={}, pMisc[]={}; + real len, lchar, lcharv, r = 0.5*lampsize; + pair c = (2r,0); + TwoTerminal term; + len = 2*lampsize; + lchar = lcharv = r; + c = (lampsize, 0); + pLine.push((0,0)--(r,0)); + pLine.push(shift(c)*scale(r)*(E..N..W..S..E)); + pLine.push((1.5*lampsize,0)--(2*lampsize,0)); + if (type==normal) { + pLine.push((c - r*dir(45)) -- (c + r*dir(45))); + pLine.push((c - r*dir(-45)) -- (c + r*dir(-45))); + } else if (type==illuminating) { + pLine.push((c - (r,0)) -- (c - (r/2,0))); + pLine.push((c + (r/2,0)) -- (c + (r,0))); + pLine.push(shift(c)*scale(r/2)*(E..N..W)); + } + term = TwoTerminal(beg, len, ang, lchar, lcharv, name, val, pLine, pMisc); + if (draw == true) + term.draw(); + return term; +} + +/* //%%<--- Mesh current (corriente de malla) --->%%% -- 2.26.2