You are on page 1of 15

PSTricks

pst-coil
Special node connections
v.1.07

May 13, 2015

Documentation by Package author(s):


Herbert Voß Timothy Van Zandt
Herbert Voß
Michael Sharpe
2

Coils, springs and zigzag curves do not really count to the ordinary when
creating graphics. They are of some importance though when dealing with
the creation of coilish connections. They can also be used for node connec-
tions which will be shown at the end of this chapter.
The parameters especially for the coil variants are only easy to under-
stand when keeping in mind that three dimensional helixes are dealt with,
which are only projected onto the two dimensional paper plane. This will be
elaborated on at the corresponding places.

Thanks to: Marco Daniel, Denis Girou, Uwe Siart.


Contents 3

Contents

1 Parameters 4
1.1 coilwidth . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.2 coilheight . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.3 coilarm, coilarmA and coilarmB . . . . . . . . . . . . . . . . . . . . . . . 6
1.4 coilaspect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.5 coilinc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.6 bow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.7 ppoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.8 periods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.9 amplitude . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
1.10 function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

2 Makros 10
2.1 \pscoil . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.2 \psCoil . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.3 \pszigzag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

3 Node connections 11

4 List of all optional arguments for pst-coil 13

References 13
1 Parameters 4

1 Parameters

Table 1 shows a compilation of the special parameters valid for pst-coil.

Table 1: Compilation of all parameters for pst-coil

name value default


coilwidth <value[unit]> 1cm
coilheight <value> 1
coilarm <value[unit]> 0.5cm
coilarmA <value[unit]> 0.5cm
coilarmB <value[unit]> 0.5cm
coilaspect <angle> 45
coilinc <angle> 45
periods <value> 1
amplitude <value> 1
function <PS code> sin
ppoints <dots per periods> 360
bow <value[unit]> 0cm

1.1 coilwidth

coilwidth denotes the diameter of the coil resp. the height of a zigzag line. The diame-
ter corresponds to the height with a perpendicular parallel projection transverse to the
length.
1.2 coilheight 5

\begin{pspicture}(0,-5)(5,5)
\pscoil(0,4)(3.5,4)
coilwidth {\psset{linewidth=0.2pt}
\psline[arrowscale=2,tbarsize=3mm]{|<->|}(4.5,3.5)
(4.5,4.5)
0.75cm \psline[linestyle=dashed](3.25,4.5)(4.5,4.5)
\psline[linestyle=dashed](2.75,3.5)(4.5,3.5)}
0.50cm \uput*[0](3.5,4){coilwidth}
0.25cm \pscoil[coilwidth=0.75cm](0,2.6)(3.6,2.6)
\uput*[0](3.5,2.6){0.75cm}
0.50cm \pscoil[coilwidth=0.5cm](0,1.8)(3.5,1.8)
\uput*[0](3.5,1.8){0.50cm}
0.50cm \pscoil[coilwidth=0.25cm](0,1.2)(3.5,1.2)
\uput*[0](3.5,1.2){0.25cm}
0.25cm
\pscoil*[coilwidth=0.5cm](0,0.5)(3.5,0.5)
0.50cm \uput*[0](3.5,0.5){0.50cm}
% zigzag
0.75cm \pszigzag(0,-4)(3.5,-4)

[ ... ]
coilwidth

1.2 coilheight

coilheight is in contrast to coilwidth no length but only a factor, whereat the distance
between two windings resp. jags is composed as follows: dx = coilheight · coilwidth

\begin{pspicture}(0,-3)(5,4)
\pscoil(0,4)(3.5,4)
{\psset{linewidth=0.2pt}
coilwidth
\psline[arrowscale=2,tbarsize=3mm]{|<->|}(4.5,3.5)
(4.5,4.5)
coilheight×coilwidth
\psline[linestyle=dashed](3.25,4.5)(4.5,4.5)
\psline[linestyle=dashed](2.75,3.5)(4.5,3.5)
\psline[arrowscale=2,tbarsize=3mm]{|<->|}(1.75,3.2)
0.75 (2.5,3.2)
\uput[-90](2.15,3){\footnotesize\texttt{coilheight$\
times$coilwidth}}}
\uput*[0](3.5,4){coilwidth}
0.50
\pscoil[coilheight=0.75](0,1.5)(3.6,1.5)
\uput*[0](3.5,1.5){0.75}
\pscoil[coilheight=0.5](0,0)(3.5,0)
1.25 \uput*[0](3.5,0){0.50}
\pscoil[coilheight=1.25](0,-1.5)(3.5,-1.5)
\uput*[0](3.5,-1.5){1.25}
0.50 \pscoil*[coilheight=0.5](0,-3)(3.5,-3)
\uput*[0](3.5,-3){0.50}
\end{pspicture}
1.3 coilarm, coilarmA and coilarmB 6

coilwidth \begin{pspicture}[shift=2cm](0,-3)(5,4)
\pszigzag(0,4)(3.5,4)
{ \psset{linewidth=0.2pt}
coilheight×coilwidth \psline[arrowscale=2,tbarsize=3mm]{|<->|}(4.5,3.5)
(4.5,4.5)
\psline[linestyle=dashed](2.5,4.5)(4.5,4.5)
0.75 \psline[linestyle=dashed](2.75,3.5)(4.5,3.5)
\psline[arrowscale=2,tbarsize=3mm]{|<->|}(1.75,3.2)
(2.75,3.2)
0.50 \uput[-90](2.15,3){\footnotesize\texttt{coilheight$\
times$coilwidth}} }
\uput*[0](3.5,4){coilwidth}
\pszigzag[coilheight=0.75](0,1.5)(3.6,1.5)
1.25 \uput*[0](3.5,1.5){0.75}
\pszigzag[coilheight=0.5](0,0)(3.5,0)
\uput*[0](3.5,0){0.50}
0.50 \pszigzag[coilheight=1.25](0,-1.5)(3.5,-1.5)
\uput*[0](3.5,-1.5){1.25}
\pszigzag*[coilheight=0.5](0,-3)(3.5,-3)
\uput*[0](3.5,-3){0.50}
\end{pspicture}

As can be seen in the above example, not the same physical distance is yielded. This is
caused by the internal three dimensional representation of the coil; it is not seen under
an angle of 90◦ but 45◦ . (Section 1.4)

1.3 coilarm, coilarmA and coilarmB

coilarm, coilarmA, and coilarmB denotes the part of a straight line made left and right.
Negative values are possible, but do not make a lot of sense as a rule. As can be gathered
from the example, the coil is lenghtened by a negative value in this case, so that the
part of a straight line is led back to the specified starting point resp. endpoint and
consequently has a negative “direction”. This parameter is not available for \psCoil.

\begin{pspicture}(4,4.5)
\pscoil(0,4)(4,4)
\psset{coilwidth=0.5}
\pscoil[coilarm=0](0,3)(4,3)
\pscoil[coilarmA=1cm,coilarmB=0.2cm](0,2)(4,2)
\pscoil[coilarm=-10pt](0,1)(4,1)
\end{pspicture}
1.4 coilaspect 7

\begin{pspicture}(4,4.5)
\pszigzag(0,4)(4,4)
\psset{coilwidth=0.5}
\pszigzag[coilarm=0](0,3)(4,3)
\pszigzag[coilarmA=1cm,coilarmB=0.2cm](0,2)(4,2)
\pszigzag[coilarm=-10pt](0,1)(4,1)
\end{pspicture}

1.4 coilaspect

In Section 1.2 the three dimensional representation of the coil has been pointed out
already. If it was regarded right-angled to its axis, the windings would not be recogniz-
able. With coilaspect this “perspective” can be influenced, which is only possible for
the “coil” variants of course. coilaspect=0 yields a sine curve.

\begin{pspicture}(4,4.5)
\pscoil(0,4)(4,4)
\psset{coilwidth=0.75}
\pscoil[coilaspect=0](0,3)(4,3)
\pscoil[coilaspect=30,coilheight=0.3](0,2)(4,2)
\pscoil[coilaspect=-30,coilheight=0.3](0,1)(4,1)
\end{pspicture}

1.5 coilinc

The curve is drawn with the lineto procedure of PostScript, whereat coilinc speci-
fies the rotation angle in the angular measure at which the next point is calculated. It
has already been mentioned that the calculation is done as a three dimensional coil and
is projected onto the two dimensional plane only in the end.
coilinc does also not make sense for zigzag lines, so that this parameter again only
is available for the coil variant. Large angles result in a polygon line, small angles in
harmonic progressions with increased calculation effort.

\begin{pspicture}(4,4.5)
\psset{coilwidth=0.8}
\pscoil(0,4)(4,4)
\psset{coilinc=0}
\pscoil[coilinc=5](0,3)(4,3)
\pscoil[coilinc=30](0,2)(4,2)
\pscoil[coilinc=60](0,1)(4,1)
\end{pspicture}
1.6 bow 8

1.6 bow

The default value for bow is 0pt which leads to the shown direct connections between
the two given point. With a positive or negative value circular zigzags are possible. This
option is not available for coils.
9

7
\psset{unit=0.6}
6
\begin{pspicture}[showgrid,shift=2cm](-1,-1)
5 (9,9)
4 \pszigzag[bow=-0.4cm,coilheight=.3,
coilwidth=.75cm]{*->}(0,0)(4,4)
3
\pczigzag[linecolor=red,bow=2.5cm,
2 coilheight=0.3,
1 coilwidth=.75cm]{*->}(0,2)(6,6)
\pnode(3,5){A}\pnode(5,0){B}
0
\nczigzag[bow=2cm,
-1 coilheight=0.3,]{A}{B}
-1 0 1 2 3 4 5 6 7 8 9 \end{pspicture}

1.7 ppoints

By default a line or node connection divides the total length into 360 segments. This
should be increased for long distances or a large number of periodss.

\begin{pspicture}(5,2)
\pssin[ppoints=2000,
periods=30](0,1)(5,1)
\end{pspicture}

1.8 periods

The line from A to B is plotted by default as one period, which is the same as the relative
periods=1. A setting of periods=3.3 plots the function 3.3 times for the given length.

\begin{pspicture}(5,2)
\pssin[linecolor=blue](0,1)(5,1)
\pssin[periods=3.3](0,1)(5,1)
\end{pspicture}

A value without an unit for the period is always relative, with an unit it will be an
absolute value.
1.9 amplitude 9

\begin{pspicture}(5,2)
2 \psaxes(5mm,0)(4.5,2)
\psset{coilarm=5mm}
\pssin[linecolor=blue](0,1)(5,1)
1
\pssin[periods=1cm](0,1)(5,1)
\pssin[periods=2cm,linestyle=dashed](0,1)(5,1)
0 \end{pspicture}
0 1 2 3 4
With a star as prefix the absolute real value will be truncated to get an integer number
of periods.
\begin{pspicture}(5,2)
\psset{coilarm=5mm}
\psaxes(5mm,0)(4.5,2)
2 \pssin[periods=1.1cm,linestyle=dotted,
linecolor=red](0,1)(5,1)
1 \pssin[periods=*1.1cm,linecolor=red](0,1)(5,1)
\pssin[periods=2.2cm,linestyle=dotted,
0 linecolor=blue](0,1)(5,1)
0 1 2 3 4 \pssin[periods=*2.2cm,linecolor=blue](0,1)(5,1)
\end{pspicture}

With a double star as prefix the absolute real value will be rounded instead of trun-
cated to get an integer number of periods.
\begin{pspicture}(5,2)
\psset{coilarm=5mm}
\psaxes(5mm,0)(4.5,2)
2 \pssin[periods=1.1cm,linestyle=dotted,
linecolor=red](0,1)(5,1)
1 \pssin[periods=**1.1cm,linecolor=red](0,1)(5,1)
\pssin[periods=2.2cm,linestyle=dotted,
0 linecolor=blue](0,1)(5,1)
0 1 2 3 4 \pssin[periods=**2.2cm,linecolor=blue](0,1)(5,1)
\end{pspicture}

1.9 amplitude

As usual the amplitude is the maximum of the plotted curve and preset to \psyunit, eg
1cm.
\begin{pspicture}(5,2)
\pssin[linecolor=blue](0,1)(5,1)
\pssin[amplitude=0.5,
linecolor=red](0,1)(5,1)
\end{pspicture}

1.10 function

By default the curve is plotted as y = sin(x), The optional argument function allows to
define any other object in PostScript notation. The value of the variable x is already
on the stack! The following example plots the defualt curve and one with the function
y = cos(x · sin(x)):
2 Makros 10

\begin{pspicture}(\linewidth,2)
\pssin[linecolor=blue](0,1)(\linewidth,1)
\pssin[function=dup sin mul cos,
linecolor=red,ppoints=10000,
periods=6](0,1)(\linewidth,1)
\end{pspicture}

2 Makros

pst-coil defines three macros, which make the creation of coil or zigzag shaped lines
possible.

\pscoil * [Options] {arrows } (x0 , y0 ) (x1 , y1 )


\psCoil * [Options] {angle1 }{angle2 }
\pszigzag * [Options] {arrows } (x0 , y0 ) (x1 , y1 )
\pssin * [Options] {arrows } (x0 , y0 ) (x1 , y1 )

• If only one coordinate pair is specified, the first point is automatically set to the
origin of ordinates (0, 0).

• Arrows may be set with the own parameter or with the optional parameter with
arrows=<...-...>.

• For \psCoil the coils are principally drawn without “arms”.

The asterisk version are in principle pointless, since they do not allow a meaningful
representation. Some could be seen with the description of parameters, but will not be
described further in the following.

2.1 \pscoil

Since \pscoil is nothing else than a polygon line, also all parameters are available
which apply for lines.

\begin{pspicture}(4,4)
\pscoil[coilarm=.5cm,linewidth=1.5pt,coilwidth=.5cm
]{|->}(4,3)
\pscoil[linecolor=red,coilheight=0.25](3,4)(3,1)
\pscoil[doubleline=true,linecolor=cyan,coilheight
=0.75](0,4)(3,0)
\end{pspicture}
2.2 \psCoil 11

2.2 \psCoil

\psCoil draws starting at the current point to the angle α an invisible line and then from
α to β a helix. \rput has to be used if they are to be placed at a particular position. The
advantage is that with \psCoil the number of helixes to draw can be specified exactly.

\begin{pspicture}(4,4)
\psCoil[linewidth=1.5pt,coilwidth=.5cm]{1800}{3600}
\rput{-90}(3,4){\psCoil[linecolor=red,coilheight
=0.25]{0}{3600}}
\rput{-45}(0,3.5){\psCoil[doubleline=true,linecolor=cyan,
coilheight=0.75]{100}{2700}}
\end{pspicture}

2.3 \pszigzag

This macro represents the two dimensional variant and is correspondly easy to use. Es-
pecially the linearc option can bring good results for \pszigzag. The specification of
the “arm length” is not absolute here, since the line is principally ended in the geomet-
rical middle and then led to the specified arm length.

\begin{pspicture}(4,4)
\pszigzag[coilarm=.5cm,linewidth=1.5pt,coilwidth=.5cm
]{|->}(4,3)
\pszigzag[linecolor=red,coilheight=0.2](3,4)(3,1)
\pszigzag[doubleline,linecolor=cyan,coilheight=0.75](0,4)
(3,0)
\end{pspicture}

\begin{pspicture}(4,4)
\pszigzag[coilarm=.5cm,
linewidth=1.5pt,bow=5mm,
coilwidth=.5cm]{|->}(4,3)
\pszigzag[linecolor=red,bow=-1cm,
coilheight=0.2](3,4)(3,1)
\pszigzag[doubleline,
linecolor=cyan,bow=1cm,
coilheight=0.75](0,4)(3,0)
\end{pspicture}

3 Node connections

Prerequisite for this macro is that pst-node is loaded, then the following node connec-
tions are available:
3 Node connections 12

\nccoil * [Options] {arrows } {nodeA }{nodeB }


\nczigzag * [Options] {arrows } {nodeA }{nodeB }
\pccoil * [Options] {arrows } {nodeA }{nodeB }
\pczigzag * [Options] {arrows } {nodeA }{nodeB }
\ncsin * [Options] {arrows } {nodeA }{nodeB }
\pcsin * [Options] {arrows } {nodeA }{nodeB }

\begin{pspicture}(4,3)
\pnode(0.5,0.5){A}
\pnode(3.5,2.5){B}
\ncsin{<->}{A}{B}
\end{pspicture}

\begin{pspicture}(5,2)
\pnode(0,1){A}
\pnode(5,1){B}
\ncsin[amplitude=0.5,periods=30,coilarm=5pt,
function=dup 0.1 mul sin exch sin add]{A}{B}
\end{pspicture}

Th other connections behave completely analogue to those dealt with the package
pst-node so that no further explanations are needed here.
References 13

4 List of all optional arguments for pst-coil

Key Type Default


coilwidth ordinary 1cm
coilheight ordinary 1
coilarmA ordinary 0.5cm
coilarmB ordinary 0.5cm
coilarm ordinary 0.5cm
coilaspect ordinary 45
coilinc ordinary 10
bow ordinary 0
periods ordinary 1
amplitude ordinary 1
ppoints ordinary 360
function ordinary sin

References

[1] Denis Girou. Présentation de PSTricks. Cahier GUTenberg, 16:21–70, April 1994.

[2] Michel Goosens, Frank Mittelbach, Sebastian Rahtz, Denis Roegel, and Herbert
Voß. The LATEX Graphics Companion. Addison-Wesley Publishing Company, Read-
ing, Mass., 2007.

[3] Laura E. Jackson and Herbert Voß. Die Plot-Funktionen von pst-plot. Die
TEXnische Komödie, 2/02:27–34, June 2002.

[4] Nikolai G. Kollock. PostScript richtig eingesetzt: vom Konzept zum praktischen
Einsatz. IWT, Vaterstetten, 1989.

[5] Herbert Voß. Chaos und Fraktale selbst programmieren: von Mandelbrotmengen
über Farbmanipulationen zur perfekten Darstellung. Franzis Verlag, Poing, 1994.

[6] Herbert Voß. Die mathematischen Funktionen von PostScript. Die TEXnische
Komödie, 1/02, March 2002.

[7] Herbert Voß. PSTricks – Grafik für TEX und LATEX. DANTE – Lehmanns, Heidel-
berg/Berlin, 6. edition, 2010.

[8] Herbert Voß. Typesetting mathematics with LATEX. UIT, Cambridge, 2010.

[9] Herbert Voß. PSTricks – Graphics for TEX and LATEX. UIT, Cambridge, 2011.

[10] Herbert Voß. LATEX quick reference. UIT, Cambridge, 2012.

[11] Timothy van Zandt. PSTricks - PostScript macros for generic TEX. http://www.
tug.org/application/PSTricks, 1993.
References 14

[12] Timothy van Zandt. multido.tex - a loop macro, that supports fixed-point addi-
tion. CTAN:/graphics/pstricks/generic/multido.tex, 1997.

[13] Timothy van Zandt. pst-plot: Plotting two dimensional functions and data.
CTAN:graphics/pstricks/generic/pst-plot.tex, 1999.

[14] Timothy van Zandt and Denis Girou. Inside PSTricks. TUGboat, 15:239–246,
September 1994.
Index
amplitude, 4, 9 \pczigzag*, 12
arrows, 10 \psCoil*, 10
\psCoil, 6, 10, 11
bow, 4, 8 \pscoil*, 10
\pscoil, 10
coil, 4
\pssin*, 10
coil, 7
\psyunit, 9
coilarm, 4, 6
\pszigzag*, 10
coilarmA, 4, 6
\pszigzag, 11
coilarmB, 4, 6
\rput, 11
coilaspect, 4, 7
coilheight, 4, 5 \nccoil*, 12
coilinc, 4, 7 \ncsin*, 12
coilwidth, 4, 5 \nczigzag*, 12

diameter, 4 Package
pst-coil, 4, 10
function, 4, 9
pst-node, 11, 12
Keyword \pccoil*, 12
amplitude, 4, 9 \pcsin*, 12
arrows, 10 \pczigzag*, 12
bow, 4, 8 periods, 4, 8
coil, 7 PostScript
coilarm, 4, 6 lineto, 7
coilarmA, 4, 6 ppoints, 4
coilarmB, 4, 6 \psCoil, 6, 10, 11
coilaspect, 4, 7 \pscoil, 10
coilheight, 4, 5 \psCoil*, 10
coilinc, 4, 7 \pscoil*, 10
coilwidth, 4, 5 \pssin*, 10
function, 4, 9 pst-coil, 4, 10
linearc, 11 pst-node, 11, 12
periods, 4, 8 \psyunit, 9
ppoints, 4 \pszigzag, 11
\pszigzag*, 10
linearc, 11
lineto, 7 \rput, 11

Macro three dimensional representation, 6


\nccoil*, 12
winding, 5
\ncsin*, 12
\nczigzag*, 12 zigzag line, 4, 10
\pccoil*, 12
\pcsin*, 12

15

You might also like