File: pov3001d.htm

package info (click to toggle)
povray-manual 3.0.20-1
  • links: PTS
  • area: main
  • in suites: hamm, potato, slink
  • size: 2,724 kB
  • ctags: 1,285
  • sloc: makefile: 31
file content (253 lines) | stat: -rw-r--r-- 20,894 bytes parent folder | download
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
<html>
<body text="#000000" bgcolor="#C0C0C0" background="backgrnd.gif">
<a name="ref 1151 pri 0"><a name="ref 1089 pri 0"><center><h3><a name="section 7.2.6.2">
Section 7.2.6.2<br>Text Formatting</h3></center>
Some escape sequences are available to include non-printing control characters in your text. These sequences are similar to those used in string literals in the C programming language. The sequences are:<p>
<center><table border><tr><td valign=top>&quot;\a&quot;</td><td valign=top>Bell or alarm, 0x07</td></tr>
<tr><td valign=top>&quot;\b&quot;</td><td valign=top>Backspace, 0x08</td></tr>
<tr><td valign=top>&quot;\f&quot;</td><td valign=top>Form feed, 0x0C</td></tr>
<tr><td valign=top>&quot;\n&quot;</td><td valign=top>New line (line feed) 0x0A</td></tr>
<tr><td valign=top>&quot;\r&quot;</td><td valign=top>Carriage return 0x0D</td></tr>
<tr><td valign=top>&quot;\t&quot;</td><td valign=top>Horizontal tab 0x09</td></tr>
<tr><td valign=top>&quot;\v&quot;</td><td valign=top>Vertical tab 0x0B</td></tr>
<tr><td valign=top>&quot;\0&quot;</td><td valign=top>Null 0x00</td></tr>
<tr><td valign=top>&quot;&quot;</td><td valign=top>Backslash 0x5C</td></tr>
<tr><td valign=top>&quot;\'&quot;</td><td valign=top>Single quote 0x27</td></tr>
<tr><td valign=top>&quot;\&quot;&quot;</td><td valign=top>Double quote 0x22</td></tr>

</td></tr></table></center>

<p>
For example:<p>
<listing>
  #debug &quot;This is one line.\nBut this is another&quot;
</listing>
<p>
Depending on what platform you are using, they may not be fully supported for console output. However they will appear in any text file if you re-direct a stream to a file.<p>
Note that most of these control characters only apply in text message directives. They are not implemented for other string usage in POV-Ray such as text objects or file names.<p>
The exceptions are the<p>
any string literals you specify anywhere in the POV-Ray language.<hr>
<a name="ref 1152 pri 0"><a name="ref 1153 pri 0"><center><h3><a name="section 7.3">
Section 7.3<br>POV-Ray Coordinate System</h3></center>
Objects, lights and the camera are positioned using a typical 3D coordinate system. The usual coordinate system for POV-Ray has the positive y-axis pointing up, the positive x-axis pointing to the right and the positive z-axis pointing into the screen. The negative values of the axes point the other direction as shown in the images in section <a href="pov30003.htm#ref 98 pri 0">&quot;Understanding POV-Ray's Coordinate System&quot;</a>.<p>
Locations within that coordinate system are usually specified by a three component vector. The three values correspond to the x, y and z directions respectively. For example, the vector &lt; 1,2,3&gt; means the point that's one unit to the right, two units up and three units in front of the center of the <strong>universe</strong> at &lt;0,0,0&gt;.<p>
Vectors are not always points though. They can also refer to an amount to size, move or rotate a scene element or to modify the texture pattern applied to an object.<p>
The supported transformations are <a name="ref 216 pri 2"><strong>rotate</strong>, <a name="ref 215 pri 12"><strong>scale</strong> and <a name="ref 954 pri 13"><strong>translate</strong>. They are used to turn, size and translate an object or texture. A transformation matrix may also be used to specify complex transformations directly.<hr>
<a name="ref 1154 pri 0"><a name="ref 1155 pri 0"><center><h3><a name="section 7.3.1">
Section 7.3.1<br>Transformations</h3></center>
The supported transformations are rotate, scale and translate. They are used to turn, size and translate an object or texture.<p>
<listing>
  rotate &lt;VECTOR&gt;
  scale &lt;VECTOR&gt;
  translate &lt;VECTOR&gt;
</listing>
<hr>
<a name="ref 1156 pri 0"><a name="ref 954 pri 0"><center><h3><a name="section 7.3.1.1">
Section 7.3.1.1<br>Translate</h3></center>
An object or texture pattern may be moved by adding a <strong>translate</strong> parameter. It consists of the keyword <a name="ref 954 pri 2"><strong>translate</strong> followed by a vector expression. The terms of the vector specify the number of units to move in each of the x, y and z directions. Translate moves the element relative to it's current position. For example<p>
<listing>
  sphere { &lt;10, 10, 10&gt;, 1
    pigment { Green }
    translate &lt;-5, 2, 1&gt;
  }
</listing>
<p>
will move the sphere from &lt;10,10,10&gt; to &lt; 5,12,11&gt;. It does not move it to the absolute location &lt;-5,2,1&gt;. Translating by zero will leave the element unchanged on that axis. For example:<p>
<listing>
  sphere { &lt;10, 10, 10&gt;, 1
    pigment { Green }
    translate 3*x // evaluates to &lt;3,0,0&gt; so move 3 units
                  // in the x direction and none along y or z
  }
</listing>
<hr>
<a name="ref 1157 pri 0"><a name="ref 215 pri 0"><center><h3><a name="section 7.3.1.2">
Section 7.3.1.2<br>Scale</h3></center>
You may change the size of an object or texture pattern by adding a <strong>scale</strong> parameter. It consists of the keyword <a name="ref 215 pri 11"><strong>scale</strong> followed by a vector expression. The 3 terms of the vector specify the amount of scaling in each of the x, y and z directions.<p>
Scale is used to <strong>stretch</strong> or <strong>squish</strong> an element. Values larger than one stretch the element on that axis while values smaller than one are used to squish it. Scale is relative to the current element size. If the element has been previously re-sized using scale then scale will size relative to the new size. Multiple scale values may used.<p>
For example<p>
<listing>
  sphere { &lt;0,0,0&gt;, 1
    scale &lt;2,1,0.5&gt;
  }
</listing>
<p>
will stretch and smash the sphere into an ellipsoid shape that is twice the original size along the x-direction, remains the same size in the y-direction and is half the original size in the z-direction.<p>
If a lone float expression is specified it is promoted to a three component vector whose terms are all the same. Thus the item is uniformly scaled by the same amount in all directions. For example:<p>
<listing>
  object {
    MyObject
    scale 5 // Evaluates as &lt;5,5,5&gt; so uniformly scale
            // by 5 in every direction.
  }
</listing>
<hr>
<a name="ref 1158 pri 0"><a name="ref 216 pri 0"><center><h3><a name="section 7.3.1.3">
Section 7.3.1.3<br>Rotate</h3></center>
You may change the orientation of an object or texture pattern by adding a <strong>rotate</strong> parameter. It consists of the keyword <a name="ref 216 pri 3"><strong>rotate</strong> followed by a vector expression. The three terms of the vector specify the number of degrees to rotate about each of the x-, y- and z-axes.<p>
Note that the order of the rotations does matter. Rotations occur about the x-axis first, then the y-axis, then the z-axis. If you are not sure if this is what you want then you should only rotate on one axis at a time using multiple rotation statements to get a correct rotation. As in<p>
<listing>
  rotate &lt;0, 30, 0&gt;  // 30 degrees around Y axis then,
  rotate &lt;-20, 0, 0&gt; // -20 degrees around X axis then,
  rotate &lt;0, 0, 10&gt;  // 10 degrees around Z axis.
</listing>
<p>
Rotation is always performed relative to the axis. Thus if an object is some distance from the axis of rotation it will not only rotate but it will <strong>orbit</strong> about the axis as though it was swinging around on an invisible string.<p>
To work out the rotation directions you must perform the famous <strong>Computer Graphics Aerobics</strong> exercise as explained in the section <a href="pov30003.htm#ref 98 pri 0">&quot;Understanding POV-Ray's Coordinate System&quot;</a>.<hr>
<a name="ref 1159 pri 0"><a name="ref 1160 pri 0"><center><h3><a name="section 7.3.1.4">
Section 7.3.1.4<br>Matrix Keyword</h3></center>
The <a name="ref 904 pri 0"><strong>matrix</strong> keyword can be used to explicitly specify the transformation matrix to be used for objects or textures. Its syntax is:<p>
<listing>
  matrix &lt; m00, m01, m02,
           m10, m11, m12,
           m20, m21, m22,
           m30, m31, m32 &gt;
</listing>
<p>
Where <a name="ref 1161 pri 0"><strong>m00</strong> through <a name="ref 1162 pri 0"><strong>m32</strong> are float expressions that specify the elements of a 4*4 matrix with the fourth column implicitly set to &lt;0,0,0,1&gt;. A point P, P=&lt;px, py, pz&gt;, is transformed into Q, Q=&lt;qx, qy, qz&gt; by<p>
<pre>
  qx = M00 * px + M10 * py + M20 * pz + M30
  qy = M01 * px + M11 * py + M21 * pz + M31
  qz = M02 * px + M12 * py + M22 * pz + M32
</pre>
<p>
Normally you won't use the matrix keyword because it's less descriptive than the transformation commands and harder to visualize. There is an intersecting aspect of the matrix command though. It allows more general transformation like shearing. The following matrix causes an object to be sheared along the y-axis.<p>
<listing>
  object {
    MyObject
    matrix &lt; 1, 1, 0,
             0, 1, 0,
             0, 0, 1,
             0, 0, 0 &gt;
  }
</listing>
<hr>
<a name="ref 1163 pri 0"><a name="ref 1164 pri 0"><center><h3><a name="section 7.3.2">
Section 7.3.2<br>Transformation Order</h3></center>
Because rotations are always relative to the axis and scaling is relative to the origin, you will generally want to create an object at the origin and scale and rotate it first. Then you may translate it into its proper position. It is a common mistake to carefully position an object and then to decide to rotate it because a rotation of an object causes it to orbit about the axis, the position of the object may change so much that it orbits out of the field of view of the camera!<p>
Similarly scaling after translation also moves an object unexpectedly. If you scale after you translate the scale will multiply the translate amount. For example<p>
<listing>
  translate &lt;5, 6, 7&gt;
  scale 4
</listing>
<p>
will translate to &lt;20,24,28&gt; instead of &lt; 5,6,7&gt;. Be careful when transforming to get the order correct for your purposes.<hr>
<a name="ref 1165 pri 0"><a name="ref 1166 pri 0"><center><h3><a name="section 7.3.3">
Section 7.3.3<br>Transform Identifiers</h3></center>
At times it is useful to combine together several transformations and apply them in multiple places. A <a name="ref 951 pri 0"><strong>transform</strong> identifier may be used for this purpose. Transform identifiers are declared as follows:<p>
<listing>
  #declare IDENT = transform { TRANSFORMATION... }
</listing>
<p>
Where IDENT is the identifier to be declared and TRANSFORMATION is one or more <a name="ref 954 pri 3"><strong>translate</strong>, <a name="ref 216 pri 7"><strong>rotate</strong>, <a name="ref 215 pri 19"><strong>scale</strong> or <a name="ref 904 pri 20"><strong>matrix</strong> specifications or a previously declared transform identifier. A transform identifier is invoked by the <a name="ref 951 pri 21"><strong>transform</strong> keyword without any brackets as shown here:<p>
<listing>
  object {
    MyObject           // Get a copy of MyObject
    transform MyTrans  // Apply the transformation
    translate -x*5     // Then move it 5 units left
  }
  object {
    MyObject           // Get another copy of MyObject
    transform MyTrans  // Apply the same transformation
    translate -x*5     // Then move this one 5 units right
  }
</listing>
<p>
On extremely complex CSG objects with lots of components it may speed up parsing if you apply a declared transformation rather than the individual <a name="ref 954 pri 25"><strong>translate</strong>, <a name="ref 216 pri 30"><strong>rotate</strong>, <a name="ref 215 pri 43"><strong>scale</strong> or <a name="ref 904 pri 45"><strong>matrix</strong> specifications. The <a name="ref 951 pri 47"><strong>transform</strong> is attached just once to each component. Applying each individual <a name="ref 954 pri 52"><strong>translate</strong>, <a name="ref 216 pri 58"><strong>rotate</strong>, <a name="ref 215 pri 72"><strong>scale</strong> or <a name="ref 904 pri 75"><strong>matrix</strong> specifications takes long. This only affects parsing - rendering works the same either way.<hr>
<a name="ref 1167 pri 0"><a name="ref 1168 pri 0"><center><h3><a name="section 7.3.4">
Section 7.3.4<br>Transforming Textures and Objects</h3></center>
When an object is transformed all textures attached to the object <b>at that time</b> are transformed as well. This means that if you have a <a name="ref 954 pri 6"><strong>translate</strong>, <a name="ref 216 pri 13"><strong>rotate</strong>, <a name="ref 215 pri 28"><strong>scale</strong> or <a name="ref 904 pri 32"><strong>matrix</strong> in an object <b>before</b> a texture the texture will not be transformed. If the transformation is <b>after</b> the texture then the texture will be transformed with the object. If the transformation is <b>inside</b> the <strong>texture</strong> statement then <b>only the texture</b> is affected. The shape remains the same. For example:<p>
<listing>
  sphere { 0, 1
    texture { Jade }  // texture identifier from TEXTURES.INC
    scale 3           // this scale affects both the
                      // shape and texture
  }

  sphere { 0, 1
    scale 3           // this scale affects the shape only
    texture { Jade }
  }

  sphere { 0, 1
    texture {
      Jade
      scale 3         // this scale affects the texture only
    }
  }
</listing>
<p>
Transformations may also be independently applied to pigment patterns and surface normal patterns. Note that scaling a normal pattern affects only the width and spacing. It does not affect the apparent height or depth of the bumps. For example:<p>
<listing>
  box { &lt;0, 0, 0&gt;, &lt;1, 1, 1&gt;
    texture {
      pigment {
        checker Red, White
        scale 0.25 // This affects only the color pattern
      }
      normal {
        bumps 0.3  // This specifies apparent height of bumps
        scale 0.2  // Scales diameter and space between bumps
                   // but not the height. Has no effect on
                   // color pattern.
      }
      rotate y*45  // This affects the entire texture but
    }              // not the object.
  }
</listing>
<hr>
<a name="ref 1169 pri 0"><a name="ref 107 pri 0"><center><h3><a name="section 7.4">
Section 7.4<br>Camera</h3></center>
The camera definition describes the position, projection type and properties of the camera viewing the scene. Its syntax is:<p>
<listing>
  camera {
    [ perspective | orthographic | fisheye |
      ultra_wide_angle | omnimax | panoramic |
      cylinder FLOAT ]
    location &lt;VECTOR&gt;
    look_at &lt;VECTOR&gt;
    right &lt;VECTOR&gt;
    up &lt;VECTOR&gt;
    direction &lt;VECTOR&gt;
    sky &lt;VECTOR&gt;
    right &lt;VECTOR&gt;
    angle FLOAT
    blur_samples FLOAT
    aperture FLOAT
    focal_point &lt;VECTOR&gt;
    normal { NORMAL }
  }
</listing>
<p>
Depending on the projection type some of the parameters are required, some are optional and some aren't used. If no projection type is given the perspective camera will be used (pinhole camera). If no camera is specified a default camera is used.<p>
Regardless of the projection type all cameras use the <a name="ref 881 pri 1"><strong>location</strong>, <a name="ref 888 pri 2"><strong>look_at</strong>, <a name="ref 99 pri 4"><strong>right</strong>, <a name="ref 564 pri 6"><strong>up</strong>, <a name="ref 557 pri 8"><strong>direction</strong> and <a name="ref 862 pri 9"><strong>sky</strong> keywords to determine the location and orientation of the camera. Their meaning differs with the projection type used. A more detailed explanation of the camera placement follows later.<hr>
<a name="ref 1170 pri 0"><a name="ref 1171 pri 0"><center><h3><a name="section 7.4.1">
Section 7.4.1<br>Type of Projection</h3></center>
The following list explains the different projection types that can be used with the camera. The most common types are the perspective and orthographic projections.<p>
<a name="ref 975 pri 0"><strong>Perspective projection:</strong> This projection represents the classic pinhole camera. The (horizontal) viewing angle is either determined by the ratio between the length of the direction vector and the length of the right vector or by the optional keyword <strong>angle,</strong> which is the preferred way. The viewing angle has to be larger than 0 degrees and smaller than 180 degrees. See the figure below for the geometry of the perspective camera.<p>
<center><img src="pov3003b.gif" border=0 width=320 height=240><br><cite>The perspective camera.</cite></center><br> <p>
<a name="ref 964 pri 0"><strong>Orthographic projection:</strong> This projection uses parallel camera rays to create an image of the scene. The size of the image is determined by the lengths of the right and up vectors.<p>
If you add the orthographic keyword after all other parameters of a perspective camera you'll get an orthographic view with the same image area, i.e. the size of the image is the same. In this case you needn't specify the lengths of the right and up vector because they'll be calculated automatically. You should be aware though that the visible parts of the scene change when switching from perspective to orthographic view. As long as all objects of interest are near the look_at location they'll be still visible if the orthographic camera is used. Objects farther away may get out of view while nearer objects will stay in view.<p>
<a name="ref 1030 pri 0"><strong>Fisheye projection:</strong> This is a spherical projection. The viewing angle is specified by the <strong>angle</strong> keyword. An angle of 180 degrees creates the &quot;standard&quot; fisheye while an angle of 360 degrees creates a super-fisheye (&quot;I-see-everything-view&quot;). If you use this projection you should get a circular image. If this isn't the case, i.e. you get an elliptical image, you should read <a href="pov3001e.htm#ref 1172 pri 0">&quot;Aspect Ratio&quot;</a>.<p>
<a name="ref 976 pri 0"><strong>Ultra wide angle projection:</strong> This projection is somewhat similar to the fisheye but it projects the image onto a rectangle instead of a circle. The viewing angle can be specified using the <strong>angle</strong> keyword.<p>
<a name="ref 953 pri 0"><strong>Omnimax projection:</strong> The omnimax projection is a 180 degrees fisheye that has a reduced viewing angle in the vertical direction. In reality this projection is used to make movies that can be viewed in the dome-like Omnimax theaters. The image will look somewhat elliptical. The <strong>angle</strong> keyword isn't used with this projection.<p>
<a name="ref 966 pri 0"><strong>Panoramic projection:</strong> This projection is called &quot;cylindrical equirectangular projection&quot;. It overcomes the degeneration problem of the perspective projection if the viewing angle approaches 180 degrees. It uses a type of cylindrical projection to be able to use viewing angles larger than 180 degrees with a tolerable lateral-stretching distortion. The <strong>angle</strong> keyword is used to determine the viewing angle.<p>
<a name="ref 1173 pri 0"><strong>Cylindrical projection:</strong> Using this projection the scene is projected onto a cylinder. There are four different types of cylindrical projections depending on the orientation of the cylinder and the position of the viewpoint. The viewing angle and the length of the up or right vector determine the dimensions of the camera and the visible image. The camera to use is specified by a number. The types are:<p>
<center><table border><tr><td valign=top>1</td><td valign=top>vertical cylinder, fixed viewpoint</td></tr>
<tr><td valign=top>2</td><td valign=top>horizontal cylinder, fixed viewpoint</td></tr>
<tr><td valign=top>3</td><td valign=top>vertical cylinder, viewpoint moves along the cylinder's axis</td></tr>
<tr><td valign=top>4</td><td valign=top>horizontal cylinder, viewpoint moves along the cylinder's axis</td></tr>

</td></tr></table></center>

<p>
If the perspective camera is used the <a name="ref 555 pri 0"><strong>angle</strong> keyword overrides the viewing angle specified by the <a name="ref 557 pri 3"><strong>direction</strong> keyword and vice versa. Each time <a name="ref 555 pri 6"><strong>angle</strong> is used the length of the direction vector is adjusted to fit the new viewing angle.<p>
There is no limitation to the viewing angle except for the perspective projection. If you choose viewing angles larger than 360 degrees you'll see repeated images of the scene (the way the repetition takes place depends on the camera). This might be useful for special effects.<p>
You should note that the vista buffer can only be used with the perspective and orthographic camera.<hr>

<center>
<a href="pov3001e.htm">Next Section</a><br>
<a href="povray.htm#Table of Contents">Table Of Contents</a><br>
</center>
</body>
</html>