3 This section is about to substitute a curve in two or three dimensions (
2D or
3D),
4 that are setup parameterised, by a
\Index{tube
}, where the initial curve is the axes and
5 we can choose the radius and grid. We find some mathematical elements concerning
6 these objects on the following websites:
8 \centerline{\url{http://fr.wikipedia.org/wiki/Tube_(math\%C3\%A9matiques)
}}
10 \centerline{\url{http://www.mathcurve.com/surfaces/tube/tube.shtml
}}
12 As usual, the
\texttt{pst-solides3d
} package offers two possibilities to draw the tubes:
14 \item via PSTricks and the argument
\Lkeyword{object
} of
\Lcs{psSolid
}
15 \item directly with
\verb+
\codejps+
18 \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.
}
20 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.
23 \subsection{Usage with PSTricks
}
25 \subsubsection{Give your curves a relief
}
26 ``
\textit{Donnez du relief \`
{a
} vos courbes
}'', this is the title of the article
27 from Robert
\textsc{Ferr\'
{e
}ol
}, available on:
29 \url{http://mapage.noos.fr/r.ferreol/atelecharger/textes/relief/courbes\%
20en\%
20relief.html
}
31 from who the following functions were borrowed and which are analogous to a
32 Lissajous figure enrolled around a cylinder.
35 \begin{LTXexample
}[pos=t
]
36 \begin{pspicture
}(-
3.5,-
4)(
4,
4)
37 \psset{lightsrc=
80 30 30,viewpoint=
100 45 30 rtp2xyz,Decran=
110,linewidth=
0.2pt
}
38 \defFunction[algebraic
]{Func
}(t)
{2.5*cos(t)
}{2.5*sin(t)
}{2*cos(
5*t)
}
39 \defFunction[algebraic
]{Func'
}(t)
{-
2.5*sin(t)
}{2.5*cos(t)
}{-
10*sin(
5*t)
}
40 \psSolid[object=courbe,range=
0 6.28,hue=
0 1 0.7 1,
41 ngrid=
360 8,function=Func,r=
0.15]
46 The argument
\texttt{\Lkeyword{object
}=
\Lkeyval{courbe
}} with the parameters
47 \Lkeyword{r
},
\Lkeyword{function
} and
\Lkeyword{range
} is used to specify
48 the radius of the tube, the name of the function to be used and the range.
50 We can also refine the grid with the optional argument
51 \texttt{\Lkeyword{ngrid
}=$n_1$ $n_2$
} where $n_1$ represents the number of
52 vertices of a section of a tube (if $n_1 =
6$, this gives a tube with a
53 hexagonal section) and $n_2$ represents the number of divisions along it.
56 \subsubsection{A
\Index{hairline curve
} is produced with the radius
\texttt{r=
0}}
58 And thus, no fear to specify the derived function.
60 \begin{LTXexample
}[pos=t
]
61 \begin{pspicture
}(-
3.5,-
4)(
4,
4)
62 \psset{lightsrc=
80 30 30,viewpoint=
100 45 30 rtp2xyz,Decran=
110}
63 \defFunction[algebraic
]{FI
}(t)
{2.5*cos(t)
}{2.5*sin(t)
}{2*cos(
5*t)
}
64 \psSolid[object=courbe,range=
0 6.28,linewidth=
2pt,linecolor=blue,function=FI,r=
0]
69 \subsection{Usage with
\texttt{\textbackslash{}codejps
}}
71 The syntax is
\texttt{\textbackslash{}codejps\
{t
\_min t
\_max (name
\_function)
72 radius
\_tube [n1 n2
] newtube\
}}.
75 \begin{LTXexample
}[pos=t
]
76 \begin{pspicture
}(-
3.5,-
3.5)(
4,
3.5)
77 \psset{lightsrc=
80 30 30,viewpoint=
100 45 90 rtp2xyz,Decran=
100,linewidth=
0.2pt
}
79 /rpn
{tx@AlgToPs begin AlgToPs end cvx exec
} def
80 /xc
{((
2+
1*cos(
2.75*t))*cos(t)) rpn
} def
81 /yc
{((
2+
1*cos(
2.75*t))*sin(t)) rpn
} def
82 /zc
{(
1*sin(
2.75*t)) rpn
} def
83 /xc'
{(-
2.75*sin(
2.75*t)*cos(t)-(
2+cos(
2.75*t))*sin(t)) rpn
} def
84 /yc'
{(-
2.75*sin(
2.75*t)*sin(t)+(
2+cos(
2.75*t))*cos(t)) rpn
} def
85 /zc'
{(
2.75*cos(
2.75*t)) rpn
} def
86 /g
{ 3 dict begin /t exch def xc yc zc end
} def
87 /g'
{ % first derivative
88 3 dict begin /t exch def xc' yc' zc' end
} def
90 % t_min t_max (name_function) radius_tube [resolution]
91 0 25.2 (g)
0.1 [360 8] newtube dup
[0 1] solidputhuecolors
} def
98 \subsection{Improving the speed of readout
}
100 The curve with the name ``
\textit{horopter
}'' is the subject of this website:
102 \centerline{\url{http://www.mathcurve.com/courbes3d/horoptere/horoptere.shtml
}}
104 \subsubsection{Obtaining the curve directly
}
106 The following lines allow us to calculate the points and draw the curve.
107 The
\Index{resolution
} \texttt{\Lkeyword{ngrid
}=
72 12} of the curve was increased, so some
108 more calculation time to produce the result, which some will judge as very long.
110 \begin{pspicture
}(-
7,-
2)(
7,
4)
111 \psset{lightsrc=
80 30 30}
112 \psset{viewpoint=
1000 60 20 rtp2xyz,Decran=
1000}
115 \codejps{/a
2 def /b
2 def
}%
116 \defFunction[algebraic
]{F3
}(t)
120 \defFunction[algebraic
]{F3'
}(t)
124 \psSolid[object=courbe,
125 range=-
2.7468 2.7468,
127 function=F3,hue=
0 1 0.7 1,
130 \psSolid[object=cylindrecreux,
132 incolor=green!
30,action=none,
135 \psSolid[object=fusion,
141 \subsubsection{Saving the parameters of the curve
}
143 If this curve is used several times, it is advisable to backup all the
144 characteristics of that curve, like:
145 coordinates of the vertices, list of colours of the faces with placing
146 the last command
\texttt{\Lkeyword{action
}=
\Lkeyval{writesolid
}}:
148 \psSolid[object=fusion,
153 The following sequence
\Cadre{LaTeX fichier.tex->
dvips->GSview
154 (Windows) or gv (Linux)
} will generate
4 files:
156 \item \texttt{horoptere-couleurs.dat
} $
\rightarrow$ the colours of the faces;
157 \item \texttt{horoptere-faces.dat
} $
\rightarrow$ the list of faces;
158 \item \texttt{horoptere-sommets.dat
} $
\rightarrow$ the list of vertices;
159 \item \texttt{horoptere-io.dat
} $
\rightarrow$ the number of faces and vertices.
162 then read and execute the files with the command:
163 \texttt{\textbackslash{}psSolid
[object=datfile,file=horoptere
]}, the time saved can be quite significant
167 \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.
168 To deactivate that security option, more or less temporarily, here the two corresponding procedures:
172 \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:
174 \$$>$ gs -dNOSAFER monfichier.ps quit.ps
175 \item[Windows:
] Within the menue
\texttt{Options
}, the option
176 \textsf{Security of files
} must be turned to unchecked.
179 \subsubsection{The plot of the curve
}
181 \begin{LTXexample
}[width=
9cm
]
182 \begin{pspicture
}(-
5,-
3.5)(
4,
3)
183 \psset{lightsrc=
80 30 30}
184 \psset{viewpoint=
100 60 20 rtp2xyz,
186 \psframe*
[linecolor=cyan!
30](-
4.5,-
3)(
3.5,
3)
187 \psSolid[object=datfile,file=./horoptere
]
193 \subsection{Some other examples
}
196 \subsubsection{A straight line
}
198 \begin{LTXexample
}[width=
7cm
]
199 \begin{pspicture
}(-
3.5,-
2)(
3.5,
2)
200 \psset{viewpoint=
100 -
20 20 rtp2xyz,
202 \psSolid[object=grille,base=-
4 4 -
4 4]%
203 \defFunction[algebraic
]{FIV
}(t)
{t
}{t
}{0.5}
204 \defFunction[algebraic
]{FIV'
}(t)
{1}{1}{0}
205 \psSolid[object=courbe,
206 range=-
4 4, ngrid=
16 16,
213 \subsubsection{A
\Index{hypocycloid
}}
215 \begin{LTXexample
}[width=
7cm
]
216 \begin{pspicture
}(-
3.5,-
3)(
3.5,
3)
217 \psset{viewpoint=
100 20 45 rtp2xyz,
219 \psSolid[object=grille,base=-
5 5 -
5 5]%
220 \defFunction[algebraic
]{FII
}(t)
221 {4*cos(t)+cos(
4*t)/
2}
222 {4*sin(t)-sin(
4*t)/
2}
224 \defFunction[algebraic
]{FII'
}(t)
225 {-
4*sin(t)-
2*sin(
4*t)
}
226 {4*cos(t)-
2*cos(
4*t)
}
228 \psSolid[object=courbe,
229 range=
0 6.28,ngrid=
90 16,
236 \subsubsection{The spring of Gaston
}
238 \begin{LTXexample
}[width=
7cm
]
239 \begin{pspicture
}(-
3.5,-
4)(
3.5,
4.5)
240 \psset{lightsrc=
80 30 30,
241 viewpoint=
100 20 20 rtp2xyz,Decran=
50}
242 \defFunction[algebraic
]{FIII
}(t)
244 {(t^
2+
3)*cos(
15*t)
}{2*t
}
245 \defFunction[algebraic
]{FIII'
}(t)
246 {2*t*sin(
15*t)+
15*(t^
2+
3)*cos(
15*t)
}
247 {2*t*cos(
15*t)-
15*(t^
2+
3)*sin(
15*t)
}{2}
248 \psSolid[object=courbe,
249 range=-
2 2,ngrid=
360 6,
250 function=FIII,hue=
0.2 0.3,
251 linewidth=
0.1pt,r=
0.2]