summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/generic/pst-solides3d/doc-en/par-new_en_corr.tex
blob: a5e0a679c5eba1a10c566efca5fae48adf639d1f (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
\section{Construction from scratch}

The object \verb+new+ constructs a solid.  Two parameters are used: \verb+sommets+
which indicates the list of coordinates of the different vertices, and \verb+faces+ which
gives the list of faces of the solid; a face is characterized by a list of the indices of its vertices, listed
in counterclockwise order
when the face is viewed from the exterior of the solid.

\clearpage

\subsection{Example 1: a house}
\begin{LTXexample}[width=6.5cm]
\psset{unit=0.5}
\psset{lightsrc=10 -20 50,viewpoint=50 -20 30 rtp2xyz,Decran=50}
\begin{pspicture*}(-7,-4)(7,7)
\psSolid[object=new,
  sommets= 
    2  4  3   -2  4  3  -2 -4  3   2 -4  3   
    2  4  0   -2  4  0  -2 -4  0   2 -4  0
   0  4  5   0 -4  5,
  faces={
  [0 1 2 3] [7 6 5 4] [0 3 7 4]    
  [3 9 2]   [1 8 0]   [8 9 3 0]
  [9 8 1 2] [6 7 3 2] [2 1 5 6]},
  num=all,show=all,action=draw]
\end{pspicture*}
\end{LTXexample}

Note that the solid \verb+new+ uses the same options as the other solids.
For example, we give the same solid as above below, using the parameters
\verb+hollow+, \verb+incolor+, \verb+fillcolor+, and \verb+rm+.

%% example 2
\begin{LTXexample}[width=6.5cm]
\psset{unit=0.5}
\psset{lightsrc=10 -20 50,viewpoint=50 -20 30 rtp2xyz,Decran=50}
\begin{pspicture*}(-7,-3.5)(7,7.5)
\psSolid[object=new,fillcolor=red!50,incolor=yellow,
  action=draw**,hollow,rm=2,
  sommets=
   2  4  3  -2  4  3  -2 -4  3   2 -4  3   
   2  4  0  -2  4  0  -2 -4  0   2 -4  0   
   0  4  5   0 -4  5,
  faces={   [0 1 2 3][7 6 5 4][0 3 7 4]
   [3 9 2]  [1 8 0]  [8 9 3 0][9 8 1 2]
   [6 7 3 2][2 1 5 6]},   
  num=all,show=all]
\end{pspicture*}
\end{LTXexample}

\subsection{Example 2: a hyperboloid with a fixed radius}

%\psset{lightsrc=10 20 30,SphericalCoor=true,viewpoint=50 20 30}
%\psset{SphericalCoor=true,viewpoint=50 20 30}


As always, the options of the macro \bs{psSolid} can handle Postscript code, even \textit{jps code}

Unlike an example in pure PostScript, where we use the parameters
$a$, $b$ et $h$ which are transmitted by the options of PSTricks.
In this way one obtains a variable solid constructed from scratch.

Remark: the code being used comes from a jps source used in practice, as in:

\noindent\url{http://melusine.eu.org/lab/bjps/solide/tour.jps}
\begin{LTXexample}[width=6.5cm]
\psset{unit=0.75}
\psset{lightsrc=10 -20 50,viewpoint=50 -20 30 rtp2xyz,Decran=50}
\begin{pspicture*}(-5,-5)(3,5)
\psSolid[object=new,fillcolor=red!50,incolor=yellow,
  hollow, a=10, %% nb d'etages
  b=20, %% diviseur de 360, nb de meridiens
  h=8,  %% hauteur
  action=draw**,sommets=
   /z0 h neg 2 div def
   a -1 0 {
    /k exch def
    0 1 b 1 sub {
     /i exch def
     /r z0 h a div k mul add dup mul 4 div 1 add sqrt def
     360 b idiv i mul cos r mul 360 b idiv i mul sin r mul
     z0 h a div k mul add
    } for
   } for,
   faces={
    0 1 a 1 sub {
    /k exch def
    k b mul 1 add 1 k 1 add b mul 1 sub {
    /i exch def
    [i i 1 sub b i add 1 sub b i add]
   } for
   [k b mul k 1 add b mul 1 sub k 2 add b mul 1 sub k 1 add b mul]
  } for
}]
\end{pspicture*}
\end{LTXexample}



\subsection{Example 3: importing external files}


From a file describing a solid in a particular format (other than \texttt{.obj} or \texttt{.off}),
we can create a \texttt{.dat} file containing the coordinates of the vertices,
and another \texttt{.dat} file containing the tables of indices of the vertices on each face.
These files can then be entered as parameters \verb+sommets+ and \verb+faces+
when using the Postscript instruction \verb+run+.


In the example below, the files \verb+sommets_nefer.dat+
and \verb+faces_nefer.dat+ have been placed in the directory of the compiler.

\begin{LTXexample}[width=5.5cm]
\psset{unit=0.4}
\definecolor{AntiqueWhite}{rgb}{0.98,0.92,0.84}
\begin{pspicture}(-7,-9)(7,7)
\psset{lightsrc=30 -40 10}
\psset{viewpoint=50 -50 20 rtp2xyz,Decran=50}
\psset{RotX=90,sommets= (sommets_nefer.dat) run}
\psSolid[object=new,fillcolor=AntiqueWhite,linewidth=0.5\pslinewidth,
    faces={(faces_nefer.dat) run}]%
\psSolid[object=new,fillcolor=red,linewidth=0.5\pslinewidth,
    faces={(faces_nefer_levres.dat) run}]%
\psSolid[object=new,fillcolor=black,
    faces={(faces_nefer_sourcils.dat) run}]%
\end{pspicture}
\hfill
\begin{pspicture}(-7,-9)(7,7)
\psset{lightsrc=-10 -40 -5,lightintensity=.5}
\psset{viewpoint=50 -80 10 rtp2xyz,Decran=50}
\psset{RotX=90,RotZ=30,sommets= (sommets_nefer.dat) run}
\psSolid[object=new,fillcolor=AntiqueWhite,linewidth=0.5\pslinewidth,
  grid,faces={(faces_nefer.dat) run}]
\psSolid[object=new,fillcolor=red,linewidth=0.5\pslinewidth,grid,
    faces={(faces_nefer_levres.dat) run}]
\psSolid[object=new,fillcolor=black,
    faces={(faces_nefer_sourcils.dat) run}]
\end{pspicture}
\end{LTXexample}


\endinput