From 5d0d256ebb84087346f4046cf6e9012fd284e888 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Wed, 12 Aug 2009 04:17:15 -0400 Subject: [PATCH] Combined Circ.wire() and Circ.wireU(). Also added wire tests to Circ-test.asy. --- asymptote/Circ-test.asy | 18 +++++++++++++++++ asymptote/Circ.asy | 45 +++++++++++++++++++---------------------- 2 files changed, 39 insertions(+), 24 deletions(-) diff --git a/asymptote/Circ-test.asy b/asymptote/Circ-test.asy index 4c11d1e..f36dc04 100644 --- a/asymptote/Circ-test.asy +++ b/asymptote/Circ-test.asy @@ -80,3 +80,21 @@ TwoTerminal Cpos = capacitor((0,0), normal, 0, "-2offset", "4 F",draw=false); Cpos.centerto(Spos.beg, Spos.end, offset=-2u); Cpos.draw(); v -= u; + +write("wires"); +dot("nsq", (0,v), N); +dot("b", (u/2,v-u/2), S); +wire((0,v), (u/2,v-u/2), nsq); +dot("udsq", (u,v), N); +dot("b", (3u/2,v-u/2), S); +wire((u,v), (3u/2,v-u/2), udsq); +dot("rlsq", (2u,v), N); +dot("b", (5u/2,v-u/2), S); +wire((2u,v), (5u/2,v-u/2), rlsq); +dot("udsq w/d", (3u,v), N); +dot("b", (7u/2,v-u/2), S); +wire((3u,v), (7u/2,v-u/2), udsq, -u/4); +dot("rlsq w/d", (4u,v), N); +dot("b", (9u/2,v-u/2), S); +wire((4u,v), (9u/2,v-u/2), rlsq, u/4); +v -= u; diff --git a/asymptote/Circ.asy b/asymptote/Circ.asy index f78507e..86dfd1e 100644 --- a/asymptote/Circ.asy +++ b/asymptote/Circ.asy @@ -84,33 +84,30 @@ path txtahead (path p) // function to wire the symbols together -int nsq=0, udsq=2, rlsq=3, usq=4; +int nsq=0, udsq=2, rlsq=3; -void wire(pair pin_beg, pair pin_end, int type) +void wire(pair pin_beg, pair pin_end, int type=nsq, real dist=0) { - if (type==nsq) { - draw(pin_beg--pin_end, line); - } else if (type==udsq) { - draw(pin_beg--(pin_beg.x,pin_end.y)--pin_end, line); - } else if (type==rlsq) { - draw(pin_beg--(pin_end.x,pin_beg.y)--pin_end, line); - } else { - write("Error, unrecognized wire type",type); - } -} - -// function to connect two branches in parallel - -void wireU(pair pin_beg, pair pin_end, real dist, int type) -{ - if (type==udsq) { - draw(pin_beg--(pin_beg+(0,dist))--(pin_end.x,pin_beg.y + dist) - --pin_end, line); - } else if (type==rlsq) { - draw(pin_beg--(pin_beg+(dist,0))--(pin_beg.x + dist,pin_end.y) - --pin_end, line); + if (dist == 0) { + if (type==nsq) { + draw(pin_beg--pin_end, line); + } else if (type==udsq) { + draw(pin_beg--(pin_beg.x,pin_end.y)--pin_end, line); + } else if (type==rlsq) { + draw(pin_beg--(pin_end.x,pin_beg.y)--pin_end, line); + } else { + write("Error, unrecognized wire type ",type); + } } else { - write("Error, unrecognized wireU type",type); + if (type==udsq) { + draw(pin_beg--(pin_beg+(0,dist))--(pin_end.x,pin_beg.y + dist) + --pin_end, line); + } else if (type==rlsq) { + draw(pin_beg--(pin_beg+(dist,0))--(pin_beg.x + dist,pin_end.y) + --pin_end, line); + } else { + write("Error, unrecognized wireU type",type); + } } } -- 2.26.2