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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
|
\section{Tubes}
This section is about to substitute a curve in two or three dimensions (2D or 3D),
that are setup parameterised, by a \Index{tube}, where the initial curve is the axes and
we can choose the radius and grid. We find some mathematical elements concerning
these objects on the following websites:
\centerline{\url{http://fr.wikipedia.org/wiki/Tube_(math\%C3\%A9matiques)}}
\centerline{\url{http://www.mathcurve.com/surfaces/tube/tube.shtml}}
As usual, the \texttt{pst-solides3d} package offers two possibilities to draw the tubes:
\begin{itemize}
\item via PSTricks and the argument \Lkeyword{object} of \Lcs{psSolid}
\item directly with \verb+\codejps+
\end{itemize}
\encadre{It is often advisable to calculate in advance, by hand or with a preferred software, the first derivatives of the parametric functions which define the coordinates.}
However, if this derivative isn't defined explicitly by the user, the package makes some approximate calculations, but the result then is not always sufficient.
\subsection{Usage with PSTricks}
\subsubsection{Give your curves a relief}
``\textit{Donnez du relief \`{a} vos courbes}'', this is the title of the article
from Robert \textsc{Ferr\'{e}ol}, available on:
\url{http://mapage.noos.fr/r.ferreol/atelecharger/textes/relief/courbes\%20en\%20relief.html}
from who the following functions were borrowed and which are analogous to a
Lissajous figure enrolled around a cylinder.
\begin{LTXexample}[pos=t]
\begin{pspicture}(-3.5,-4)(4,4)
\psset{lightsrc=80 30 30,viewpoint=100 45 30 rtp2xyz,Decran=110,linewidth=0.2pt}
\defFunction[algebraic]{Func}(t){2.5*cos(t)}{2.5*sin(t)}{2*cos(5*t)}
\defFunction[algebraic]{Func'}(t){-2.5*sin(t)}{2.5*cos(t)}{-10*sin(5*t)}
\psSolid[object=courbe,range=0 6.28,hue=0 1 0.7 1,
ngrid=360 8,function=Func,r=0.15]
\end{pspicture}
\end{LTXexample}
The argument \texttt{\Lkeyword{object}=\Lkeyval{courbe}} with the parameters
\Lkeyword{r}, \Lkeyword{function} and \Lkeyword{range} is used to specify
the radius of the tube, the name of the function to be used and the range.
We can also refine the grid with the optional argument
\texttt{\Lkeyword{ngrid}=$n_1$ $n_2$} where $n_1$ represents the number of
vertices of a section of a tube (if $n_1 = 6$, this gives a tube with a
hexagonal section) and $n_2$ represents the number of divisions along it.
\subsubsection{A \Index{hairline curve} is produced with the radius \texttt{r=0}}
And thus, no fear to specify the derived function.
\begin{LTXexample}[pos=t]
\begin{pspicture}(-3.5,-4)(4,4)
\psset{lightsrc=80 30 30,viewpoint=100 45 30 rtp2xyz,Decran=110}
\defFunction[algebraic]{FI}(t){2.5*cos(t)}{2.5*sin(t)}{2*cos(5*t)}
\psSolid[object=courbe,range=0 6.28,linewidth=2pt,linecolor=blue,function=FI,r=0]
\end{pspicture}
\end{LTXexample}
\subsection{Usage with \texttt{\textbackslash{}codejps}}
The syntax is \texttt{\textbackslash{}codejps\{t\_min t\_max (name\_function)
radius\_tube [n1 n2] newtube\}}.
\begin{LTXexample}[pos=t]
\begin{pspicture}(-3.5,-3.5)(4,3.5)
\psset{lightsrc=80 30 30,viewpoint=100 45 90 rtp2xyz,Decran=100,linewidth=0.2pt}
\codejps{
/rpn {tx@AlgToPs begin AlgToPs end cvx exec} def
/xc {((2+1*cos(2.75*t))*cos(t)) rpn } def
/yc {((2+1*cos(2.75*t))*sin(t)) rpn } def
/zc {(1*sin(2.75*t)) rpn } def
/xc' {(-2.75*sin(2.75*t)*cos(t)-(2+cos(2.75*t))*sin(t)) rpn } def
/yc' {(-2.75*sin(2.75*t)*sin(t)+(2+cos(2.75*t))*cos(t)) rpn } def
/zc' {(2.75*cos(2.75*t)) rpn } def
/g { 3 dict begin /t exch def xc yc zc end } def
/g' { % first derivative
3 dict begin /t exch def xc' yc' zc' end } def
/solenoide{
% t_min t_max (name_function) radius_tube [resolution]
0 25.2 (g) 0.1 [360 8] newtube dup [0 1] solidputhuecolors} def
solenoide
drawsolid**
}%
\end{pspicture}
\end{LTXexample}
\subsection{Improving the speed of readout}
The curve with the name ``\textit{horopter}'' is the subject of this website:
\centerline{\url{http://www.mathcurve.com/courbes3d/horoptere/horoptere.shtml}}
\subsubsection{Obtaining the curve directly}
The following lines allow us to calculate the points and draw the curve.
The \Index{resolution} \texttt{\Lkeyword{ngrid}=72 12} of the curve was increased, so some
more calculation time to produce the result, which some will judge as very long.
\begin{verbatim}
\begin{pspicture}(-7,-2)(7,4)
\psset{lightsrc=80 30 30}
\psset{viewpoint=1000 60 20 rtp2xyz,Decran=1000}
\psframe(-7,-2)(7,4)
\psset{solidmemory}
\codejps{/a 2 def /b 2 def}%
\defFunction[algebraic]{F3}(t)
{a*(1+cos(t))}
{b*tan(t/2)}
{a*sin(t)}
\defFunction[algebraic]{F3'}(t)
{-a*sin(t)}
{b*(1+tan(1/2*t)^2)}
{a*cos(t)}
\psSolid[object=courbe,
range=-2.7468 2.7468,
ngrid=72 12,
function=F3,hue=0 1 0.7 1,
action=none,name=H1,
r=1]%
\psSolid[object=cylindrecreux,
h=20,r=1,RotX=90,
incolor=green!30,action=none,
name=C1,
ngrid=36 36](2,10,0)
\psSolid[object=fusion,
base=H1 C1]
\composeSolid
\end{pspicture}
\end{verbatim}
\subsubsection{Saving the parameters of the curve}
If this curve is used several times, it is advisable to backup all the
characteristics of that curve, like:
coordinates of the vertices, list of colours of the faces with placing
the last command \texttt{\Lkeyword{action}=\Lkeyval{writesolid}}:
\begin{verbatim}
\psSolid[object=fusion,
base=H1 C1,
file=horoptere,
action=writesolid]
\end{verbatim}
The following sequence \Cadre{LaTeX fichier.tex->dvips->GSview
(Windows) or gv (Linux)} will generate 4 files:
\begin{itemize}
\item \texttt{horoptere-couleurs.dat} $\rightarrow$ the colours of the faces;
\item \texttt{horoptere-faces.dat} $\rightarrow$ the list of faces;
\item \texttt{horoptere-sommets.dat} $\rightarrow$ the list of vertices;
\item \texttt{horoptere-io.dat} $\rightarrow$ the number of faces and vertices.
\end{itemize}
then read and execute the files with the command:
\texttt{\textbackslash{}psSolid[object=datfile,file=horoptere]}, the time saved can be quite significant
\encadre{By default, under Windows and Linux, the security of files on the hard drive is activated and doesn't allow to write on the drive.
To deactivate that security option, more or less temporarily, here the two corresponding procedures:
\begin{description}
\item[Linux:] The advice from Jean-Michel \textsc{Sarlat}: the simplest will be to use GhostScript directly, within the console. As there is no image to wait for:
\$$>$ gs -dNOSAFER monfichier.ps quit.ps
\item[Windows:] Within the menue \texttt{Options}, the option
\textsf{Security of files} must be turned to unchecked.
\end{description}}
\subsubsection{The plot of the curve}
\begin{LTXexample}[width=9cm]
\begin{pspicture}(-5,-3.5)(4,3)
\psset{lightsrc=80 30 30}
\psset{viewpoint=100 60 20 rtp2xyz,
Decran=75}
\psframe*[linecolor=cyan!30](-4.5,-3)(3.5,3)
\psSolid[object=datfile,file=./horoptere]
\end{pspicture}
\end{LTXexample}
\subsection{Some other examples}
\subsubsection{A straight line}
\begin{LTXexample}[width=7cm]
\begin{pspicture}(-3.5,-2)(3.5,2)
\psset{viewpoint=100 -20 20 rtp2xyz,
Decran=75,unit=0.8}
\psSolid[object=grille,base=-4 4 -4 4]%
\defFunction[algebraic]{FIV}(t){t}{t}{0.5}
\defFunction[algebraic]{FIV'}(t){1}{1}{0}
\psSolid[object=courbe,
range=-4 4, ngrid=16 16,
function=FIV, r=0.5]
\end{pspicture}
\end{LTXexample}
\subsubsection{A \Index{hypocycloid}}
\begin{LTXexample}[width=7cm]
\begin{pspicture}(-3.5,-3)(3.5,3)
\psset{viewpoint=100 20 45 rtp2xyz,
Decran=75,unit=0.7}
\psSolid[object=grille,base=-5 5 -5 5]%
\defFunction[algebraic]{FII}(t)
{4*cos(t)+cos(4*t)/2}
{4*sin(t)-sin(4*t)/2}
{1}
\defFunction[algebraic]{FII'}(t)
{-4*sin(t)-2*sin(4*t)}
{4*cos(t)-2*cos(4*t)}
{0}
\psSolid[object=courbe,
range=0 6.28,ngrid=90 16,
function=FII,r=1]
\end{pspicture}
\end{LTXexample}
\subsubsection{The spring of Gaston}
\begin{LTXexample}[width=7cm]
\begin{pspicture}(-3.5,-4)(3.5,4.5)
\psset{lightsrc=80 30 30,
viewpoint=100 20 20 rtp2xyz,Decran=50}
\defFunction[algebraic]{FIII}(t)
{(t^2+3)*sin(15*t)}
{(t^2+3)*cos(15*t)}{2*t}
\defFunction[algebraic]{FIII'}(t)
{2*t*sin(15*t)+15*(t^2+3)*cos(15*t)}
{2*t*cos(15*t)-15*(t^2+3)*sin(15*t)}{2}
\psSolid[object=courbe,
range=-2 2,ngrid=360 6,
function=FIII,hue=0.2 0.3,
linewidth=0.1pt,r=0.2]
\end{pspicture}
\end{LTXexample}
\endinput
|