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");
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) --->%%%