Initialisation du projet pst-solides3d.git (SVN revision 142)
[pst-solides3d.git] / doc-en / par-eclairageponctuel-en.tex
1 \newpage
2 \section{Lighting by a point light source}
3
4 Two parameters, the first one positions the \Index{light source}, the second one sets the \Index{light intensity}:
5 \begin{compactitem}
6 \item \Lkeyword{lightsrc}=20 30 50 in Cartesian coordinates, or
7 \texttt{\Lkeyword{lightsrc}=\Lkeyval{viewpoint}} to put the light source at the view point.
8 \item \texttt{\Lkeyword{lightintensity}=2} (default value).
9 \end{compactitem}
10 \begin{center}
11 \newcommand\LIGHTSRC[3]{%
12 \pstVerb{
13 /xLIGHTSRC #1 def
14 /yLIGHTSRC #2 def
15 /zLIGHTSRC #3 def
16 /RADIUS 4 def
17 /THETA yLIGHTSRC xLIGHTSRC atan def
18 /DISTANCE xLIGHTSRC dup mul yLIGHTSRC dup mul add zLIGHTSRC dup mul add sqrt def
19 /PHI zLIGHTSRC DISTANCE div arcsin def
20 /ALPHA RADIUS DISTANCE div arccos def
21 /OH ALPHA cos RADIUS mul def
22 /radius_cone ALPHA sin RADIUS mul def
23 /Hauteur_cone DISTANCE OH sub def
24 /X_C xLIGHTSRC OH mul DISTANCE div def
25 /Y_C yLIGHTSRC OH mul DISTANCE div def
26 /Z_C zLIGHTSRC OH mul DISTANCE div def
27 /rotX_axe_cone PHI 90 sub def
28 /rotZ_axe_cone THETA 90 sub def
29 }
30 \psset{Decran=50,viewpoint=50 10 15}
31 \psSolid[object=sphere,r=RADIUS,fillcolor=blue,ngrid=18 36,
32 lightsrc=xLIGHTSRC yLIGHTSRC zLIGHTSRC](0,0,0)
33 \psPoint(xLIGHTSRC,yLIGHTSRC,zLIGHTSRC){LS}
34 \psset{lightsrc=}
35 \psSolid[object=cone,r=radius_cone,h=Hauteur_cone,fillcolor=yellow!50,
36 ngrid=1 36,RotX=rotX_axe_cone,RotZ=rotZ_axe_cone,opacity=0.5,
37 linecolor=yellow](X_C,Y_C,Z_C)
38 \psdot(LS)}
39
40 \begin{pspicture}(-2,-2.5)(5,5)
41 \psset{unit=0.5}
42 \LIGHTSRC{0}{8}{8}
43 \uput[45](LS){Light Source}
44 \axesIIID(4,4,4)(6,6,6)
45 \end{pspicture}
46 \begin{pspicture}(-4,-2.5)(5,2.5)
47 \psset{unit=0.5}
48 \LIGHTSRC{2}{-5}{0}
49 \uput[l](LS){Light Source}
50 \axesIIID(4,4,4)(6,6,6)
51 \end{pspicture}
52
53 \begin{pspicture}(-1,-2.5)(9,2.5)
54 \psset{unit=0.5}
55 \LIGHTSRC{0}{20}{0}
56 \uput[r](LS){Light Source}
57 \axesIIID(4,4,4)(6,6,6)
58 \end{pspicture}
59 \end{center}
60
61 As you can see, the intersecting \Index{plane} (section of the sphere with the cone of
62 \Index{light}) divides the object into two half spaces: the first half space
63 (the one on the side of the \Index{light source}) is illuminated and the other half space is the shadow region referring to this light source position.
64
65 Now it is clear, that if the view point is setup with the same coordiates as the light source, the object is illuminated uniquely.
66
67 \encadre{In order to get some shadow regions to appear in the graphic---which emphasises the 3D character---we would suggest choosing the light source and the view point differently.}
68
69 \newpage
70 Here follow a few examples:
71
72 \begin{pspicture}(-3,-2)(3,3)
73 \psset{unit=0.3}
74 \psset{Decran=1e3,
75 viewpoint=500 0 1000,
76 lightsrc=10 20 30,mode=3}
77 \psSolid[object=sphere,r=5,fillcolor=blue](0,0,8)
78 \rput(0,-3.5){\texttt{lightsrc=10 20 30}}
79 \end{pspicture}
80 \begin{pspicture}(-3,-2)(3,3)
81 \psset{unit=0.3}
82 \psset{Decran=1e3,
83 viewpoint=500 0 1000,
84 lightsrc=-10 -20 30,mode=3}
85 \psSolid[object=sphere,r=5,fillcolor=blue](0,0,8)
86 \rput(0,-3.5){\texttt{lightsrc=-10 -20 30}}
87 \end{pspicture}
88 \begin{pspicture}(-3,-2)(3,3)
89 \psset{unit=0.3}
90 \psset{Decran=1e3,
91 viewpoint=500 0 1000,
92 lightsrc=30 -20 30,mode=3}
93 \psSolid[object=sphere,r=5,fillcolor=blue](0,0,8)
94 \rput(0,-3.5){\texttt{lightsrc=30 -20 30}}
95 \end{pspicture}
96
97 When the option \verb+[lightsrc=value1 value2 value3]+
98 is not specified, the object is uniformly illuminated.
99
100 \begin{center}
101 \begin{pspicture}(-6,-2)(6,2)
102 %\psframe(-6,-4)(6,4)
103 \psset{viewpoint=50 50 30 rtp2xyz,Decran=40,unit=0.6}
104 \psSolid[object=datfile,file=./tore1836,deactivatecolor]
105 %\psSolid[r1=3.5,r0=1,object=tore,ngrid=18 36,fillcolor={[rgb]{.372 .62 .628}}]%
106 \axesIIID(0,4.5,0)(6,6,4)
107 \end{pspicture}
108 \end{center}
109
110
111
112 Here are some examples, where we always keep the same object, the same view point, the same light
113 source coordinates and just vary the \Lkeyword{lightintensity} value:
114
115 \begin{pspicture}(-3,-2)(3,3)
116 \psset{unit=0.3}
117 \psset{Decran=1e3,
118 viewpoint=500 0 1000,
119 lightsrc=-10 -20 30,mode=4,lightintensity=1}
120 \psSolid[object=sphere,r=5,fillcolor=green](0,0,8)
121 \rput(0,-3.5){\texttt{lightintensity=2}}
122 \end{pspicture}
123 \begin{pspicture}(-3,-2)(3,3)
124 \psset{unit=0.3}
125 \psset{Decran=1e3,
126 viewpoint=500 0 1000,
127 lightsrc=-10 -20 30,mode=4,lightintensity=3}
128 \psSolid[object=sphere,r=5,fillcolor=green](0,0,8)
129 \rput(0,-3.5){\texttt{lightintensity=3}}
130 \end{pspicture}
131 \begin{pspicture}(-3,-2)(3,3)
132 \psset{unit=0.3}
133 \psset{Decran=1e3,
134 viewpoint=500 0 1000,
135 lightsrc=-10 -20 30,mode=4,lightintensity=8}
136 \psSolid[object=sphere,r=5,fillcolor=green](0,0,8)
137 \rput(0,-3.5){\texttt{lightintensity=8}}
138 \end{pspicture}
139
140 Here we can see, that by increasing the \Lkeyword{lightintensity} value, the shading nuances of the solid are decreasing.
141
142
143
144 \endinput

Licence Creative Commons Les fichiers de Syracuse sont mis à disposition (sauf mention contraire) selon les termes de la
Licence Creative Commons Attribution - Pas d’Utilisation Commerciale - Partage dans les Mêmes Conditions 4.0 International.