summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/latex-graphics-companion/4-10-10.ltx
blob: d6b93e2c3e1f41b650b109ebb7dda72c0b73a983 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
\documentclass{ppex}
\nonstopmode
\usepackage {pstcol,pst-node,pst-coil}
\pagestyle{empty}

\begin{document}
\ResetPreambleCommands
\ReadyForTheFray
\usepackage {pstcol,pst-node,pst-coil}
\makeatletter
\newdimen\CurX
\newdimen\CurY \newdimen\Cir@temp
\newcount\Cir@direction % 0 right, 1 left, 2 up, 3 down
\Cir@direction0
\def\SetX#1{\CurX=#1pt}
\def\SetY#1{\CurY=#1pt}
\def\ShowDirection{%
 \typeout{Direction:
 \ifcase\Cir@direction right\or left\or up\or down\fi,
    now at (\strip@pt\CurX,\strip@pt\CurY)}%
}
\def\ShowXY{\message{(\strip@pt\CurX,\strip@pt\CurY)}}

\def\Down#1{\advance\CurY  by -#1\p@\Cir@direction3%\ShowDirection
}
\def\Up#1{\advance\CurY  by #1\p@\Cir@direction2%\ShowDirection
}
\def\Left#1{\advance\CurX by -#1\p@\Cir@direction1%\ShowDirection
}
\def\Right#1{\advance\CurX by #1\p@\Cir@direction0%\ShowDirection
}
\def\MyBox#1#2{% width,height
 \pssetlength{\Cir@temp}{#1}%
 \rule{\Cir@temp}{\z@}%
 \pssetlength{\Cir@temp}{#2}%
 \rule{\z@}{\Cir@temp}%
}
\def\Point#1{%
\rput(\strip@pt\CurX,\strip@pt\CurY){\pnode{#1}}%
}
\def\Switch#1{%
\message{[Switch] #1}\ShowXY
\relax
\ifcase\Cir@direction % right
   \rput[b](\strip@pt\CurX,\strip@pt\CurY){\rnode[b]{#1}{%
   \psline(.5,.4)%
   \psarc{<-}{.4}{-10}{70}%
   \MyBox{.5}{.4}%
   }}%
   \advance\CurX by .5\p@
\or % left
   \advance\CurX by -.5\p@
   \rput[b](\strip@pt\CurX,\strip@pt\CurY){\rnode[b]{#1}{%
   \psline(0,0)(.5,.4)%
   \psarc{<-}{.4}{-10}{70}%
   \MyBox{.5}{.4}%
  }}%
\fi
}

\def\Battery#1{%
\message{[Battery] #1}\ShowXY
\relax
\ifcase\Cir@direction % right
   \rput[r](\strip@pt\CurX,\strip@pt\CurY){\rnode{#1}{%
     \psline(0,-.4)(0,.4)%
     \psline(.2,-.2)(.2,.2)%
     \MyBox{.2}{.8}%
    }}%
   \advance\CurX by .2\p@
\or % left
   \advance\CurX by -.2\p@
   \rput[r](\strip@pt\CurX,\strip@pt\CurY){\rnode{#1}{%
     \psline(0,-.4)(0,.4)%
     \psline(.2,-.2)(.2,.2)%
     \MyBox{.2}{.8}%
    }}%
\or % up
   \advance\CurY by .2\p@
   \rput[b](\strip@pt\CurX,\strip@pt\CurY){\rnode{#1}{%
     \psline(.1,.2)(.9,.2)%
     \psline(0.3,0)(0.7,0)%
     \MyBox{1}{.2}%
    }}%
\or % down
   \rput[b](\strip@pt\CurX,\strip@pt\CurY){\rnode{#1}{%
     \psline(-.4,0)(.4,0)%
     \psline(-.2,-.2)(.2,-.2)%
     \MyBox{1}{.2}%
    }}%
   \advance\CurY by -.2\p@
\fi
}

\def\Resistor{\message{[Resistor]}\ShowXY
  \@ifnextchar[{\@ResInd}{\@ResInd[1]{pszigzag}}}
\def\Inductor{\message{[Inductor]}\ShowXY
  \@ifnextchar[{\@ResInd}{\@ResInd[1]{pscoil}}}

\def\@ResInd[#1]#2#3{%
 \ifcase\Cir@direction % right
   \rput[l](\strip@pt\CurX,\strip@pt\CurY){\rnode{#3}{%
   \csname #2\endcsname[coilarm=.01,coilwidth=.3](0,.15)(#1,.15)%
   \MyBox{#1}{.3}%
    }}%
   \advance\CurX by #1\p@
 \or % left
   \advance\CurX by -#1\p@
   \rput[l](\strip@pt\CurX,\strip@pt\CurY){\rnode{#3}{%
   \csname #2\endcsname[coilarm=.01,coilwidth=.3](0,.15)(#1,.15)%
   \MyBox{#1}{.3}%
    }}%
 \or % up
   \rput[b](\strip@pt\CurX,\strip@pt\CurY){\rnode{#3}{%
   \csname #2\endcsname[coilarm=.01,coilwidth=.3](.15,0)(.15,#1)%
   \MyBox{.3}{#1}%
    }}%
   \advance\CurY by #1\p@
 \or % down
   \advance\CurY by -#1\p@
   \rput[b](\strip@pt\CurX,\strip@pt\CurY){\rnode{#3}{%
   \csname #2\endcsname[coilarm=.01,coilwidth=.3](.15,0)(.15,#1)%
   \MyBox{.3}{#1}%
    }}%
 \fi
}
\makeatother

\begin{pspicture}(5,5)
\SetX{1}
\Up{1}
\Battery{A}
\Up{1}
\Right{2}
\Resistor{B}
\Right{1}
\Down{.3}
\Inductor{C}
\Down{.5}
\Left{1}
\Switch{D}
\ncangle[angleA=90,angleB=180,armB=0]{A}{B}
\ncangle[angleA=0,angleB=90,armB=0]{B}{C}
\ncput[ref=l]{~~~$i=i_{\mbox{max}}(1-w^{-t/3})$}
\ncangle[angleA=-90,armB=0,angleB=0]{C}{D}
\ncangle[angleA=180,armB=0,angleB=-90]{D}{A}
\nput{180}{A}{10V}
\nput{90}{B}{R}
\nput{0}{C}{3mH}
\nput{270}{D}{S}
\end{pspicture}
\end{document}