Sophie

Sophie

distrib > Mandriva > 2010.2 > i586 > by-pkgid > 8c84ab5fe0ecd5f81b4e4e07120af05b > files > 1023

povray-3.6.1-8mdv2010.1.i586.rpm


<!--  This file copyright Persistence of Vision Raytracer Pty. Ltd. 2003-2004  -->
<html> 
<head>
  
<!--  NOTE: In order to users to help find information about POV-Ray using  -->
 
<!--  web search engines, we ask you to *not* let them index documentation  -->
 
<!--  mirrors because effectively, when searching, users will get hundreds  -->
 
<!--  of results containing the same information! For this reason, the two  -->
 
<!--  meta tags below disable archiving and indexing of this page by all  -->
 
<!--  search engines that support these meta tags.  -->
 
 <meta content="noarchive" name="robots">
   
 <meta content="noindex" name="robots">
   
 <meta content="no-cache" http-equiv="Pragma">
   
 <meta content="0" http-equiv="expires">
   
<title>2.2.7 POV-Ray Coordinate System</title>
 <link href="povray35.css" rel="stylesheet" type="text/css"> 
</head>
 <body> 
<table class="NavBar" width="100%">
  
 <tr>
   
  <td align="left" nowrap="" valign="middle" width="32">
    <a href="s_62.html"><img alt="previous" border="0" src="prev.png"></a> 
   
  </td>
   
  <td align="left" valign="middle" width="30%">
    <a href="s_62.html">2.2.6 Using the Camera</a> 
  </td>
   
  <td align="center" valign="middle">
    <strong class="NavBar">POV-Ray 3.6 for UNIX documentation</strong><br> <strong>2.2.7 
   POV-Ray Coordinate System</strong> 
  </td>
   
  <td align="right" valign="middle" width="30%">
    <a href="s_64.html">2.2.8 Setting POV-Ray Options</a> 
  </td>
   
  <td align="right" nowrap="" valign="middle" width="32">
    <a href="s_64.html"><img alt="next" border="0" src="next.png"></a> 
   
  </td>
   
 </tr>
  
</table>
 
<h3><a name="s02_02_07">2.2.7 </a>POV-Ray Coordinate System</h3>

<p>
  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 
 &quot;<a href="s_57.html#s02_02_01_01">Understanding POV-Ray's Coordinate System</a>&quot;. 
</p>

<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 <code>&lt;1,2,3&gt;</code> means the 
 point that is one unit to the right, two units up and three units in front of the center of the universe at <code>&lt;0,0,0&gt;</code>. 
 
</p>

<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>

<p>
  The size, location, orientation, and deformation of items within the coordinate system is controlled by modifiers 
 called <em>transformations</em>. The follow sub-sections describe the transformations and their usage. 
</p>

<h4><a name="s02_02_07_01">2.2.7.1 </a>Transformations</h4>

<p>
  The supported transformations are <code>rotate</code>, <code> scale</code>, and <code>translate</code>. They are 
 used to turn, size and move an object or texture. A transformation matrix may also be used to specify complex 
 transformations directly. Groups of transformations may be merged together and stored in a transformation identifier. 
 The syntax for transformations is as follows. 
</p>

<pre>
TRANSFORMATION:
    rotate &lt;Rotate_Amt&gt; | scale &lt;Scale_Amt&gt; | 
    translate &lt;Translate_Amt&gt; | transform TRANSFORM_IDENTIFIER | 
    transform { TRANSFORMATION_BLOCK...} |
    matrix &lt;Val00, Val01, Val02,
        Val10, Val11, Val12,
        Val20, Val21, Val22,
        Val30, Val31, Val32&gt;
TRANSFORMATION_BLOCK:
    TRANSFORM_IDENTIFIER | TRANSFORMATION | inverse
TRANSFORM_DECLARATION:
    #declare IDENTIFIER = transform { TRANSFORMATION_BLOCK...} |
    #local IDENTIFIER = transform { TRANSFORMATION_BLOCK...}
</pre>

<h5><a name="s02_02_07_01_01">2.2.7.1.1 </a>Translate</h5>

<p>
  Items may be moved by adding a <code>translate</code> modifier. It consists of the keyword <code>translate</code> 
 followed by a vector expression. The three 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 its current position. For example 
</p>

<pre>
 sphere { &lt;10, 10, 10&gt;, 1
  pigment { Green }
  translate &lt;-5, 2, 1&gt;
 }
</pre>

<p>
  will move the sphere from the location <code>&lt;10,10,10&gt;</code> to <code>&lt;5,12,11&gt;</code>. It does not 
 move it to the absolute location <code>&lt;-5,2,1&gt;</code>. Translations are always relative to the item's location 
 before the move. Translating by zero will leave the element unchanged on that axis. For example: 
</p>

<pre>
 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
 }
</pre>

<h5><a name="s02_02_07_01_02">2.2.7.1.2 </a>Scale</h5>

<p>
  You may change the size of an object or texture pattern by adding a <code> scale</code> modifier. It consists of 
 the keyword <code>scale</code> followed by a vector expression. The three terms of the vector specify the amount of 
 scaling in each of the x, y and z directions. 
</p>

<p>
  Uneven scaling is used to <em> stretch</em> or <em>squish</em> 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>

<p>
  For example 
</p>

<pre>
 sphere { &lt;0,0,0&gt;, 1
  scale &lt;2,1,0.5&gt;
 }
</pre>

<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>

<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>

<pre>
 object {
  MyObject
  scale 5 // Evaluates as &lt;5,5,5&gt; so uniformly scale
      // by 5 in every direction.
 }
</pre>

<p>
  When one of the scaling components is zero, POV-Ray changes this component to 1 since it assumes that 0 means no 
 scaling in this direction. A warning &quot;Illegal Value: Scale X, Y or Z by 0.0. Changed to 1.0.&quot; is printed 
 then. 
</p>

<h5><a name="s02_02_07_01_03">2.2.7.1.3 </a>Rotate</h5>

<p>
  You may change the orientation of an object or texture pattern by adding a <code>rotate</code> modifier. It 
 consists of the keyword <code> rotate</code> 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>

<p class="Note">
  <strong>Note:</strong> 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. 
</p>

<pre>
 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.
</pre>

<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 <em>orbit</em> about the axis as though it was swinging around on an invisible 
 string. 
</p>

<p>
  POV-Ray uses a left-handed rotation system. Using the famous &quot;<em>Computer Graphics Aerobics</em>&quot; 
 exercise, you hold up your left hand and point your thumb in the positive direction of the axis of rotation. Your 
 fingers will curl in the positive direction of rotation. Similarly if you point your thumb in the negative direction 
 of the axis your fingers will curl in the negative direction of rotation. See &quot;Understanding POV-Ray's Coordinate 
 System&quot; for an illustration. 
</p>

<h5><a name="s02_02_07_01_04">2.2.7.1.4 </a>Matrix</h5>

<p>
  The <code>matrix</code> keyword can be used to explicitly specify the transformation matrix to be used for objects 
 or textures. Its syntax is: 
</p>

<pre>
MATRIX:
    matrix &lt;Val00, Val01, Val02,
        Val10, Val11, Val12,
        Val20, Val21, Val22,
        Val30, Val31, Val32&gt;
</pre>

<p>
  Where <em><code>Val00</code></em> through <em><code>Val32</code></em> are float expressions enclosed in angle 
 brackets and separated by commas. 
</p>

<p class="Note">
  <strong>Note:</strong> this is not a vector. It is a set of 12 float expressions. 
</p>

<p>
  These floats specify the elements of a 4 by 4 matrix with the fourth column implicitly set to <code>&lt;0,0,0,1&gt;</code>. 
 At any given point <em>P, P=&lt;px, py, pz&gt;</em>, is transformed into the point <em>Q, Q=&lt;qx, qy, qz&gt;</em> by 
</p>

<p>
  qx = Val00 * px + Val10 * py + Val20 * pz + Val30 
</p>

<p>
  qy = Val01 * px + Val11 * py + Val21 * pz + Val31 
</p>

<p>
  qz = Val02 * px + Val12 * py + Val22 * pz + Val32 
</p>

<p>
  Normally you will not use the matrix keyword because it is less descriptive than the transformation commands and 
 harder to visualize. However the matrix command allows more general transformation effects like <em> shearing</em>. 
 The following matrix causes an object to be sheared along the y-axis. 
</p>

<pre>
 object {
  MyObject
  matrix &lt; 1, 1, 0,
       0, 1, 0,
       0, 0, 1,
       0, 0, 0 &gt;
 }
</pre>

<h4><a name="s02_02_07_02">2.2.7.2 </a>Transformation Order</h4>

<p>
  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. However 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>

<p>
  Similarly scaling after translation also moves an object unexpectedly. If you scale after you translate the scale 
 will multiply the translate amount. <br>For example 
</p>

<pre>
  translate &lt;5, 6, 7&gt;
  scale 4
</pre>

<p>
  will translate to <code>&lt;20,24,28&gt;</code> instead of <code> &lt;5,6,7&gt;</code>. Be careful when 
 transforming to get the order correct for your purposes. 
</p>

<h4><a name="s02_02_07_03">2.2.7.3 </a>Inverse Transform</h4>

<pre>
  transform { scale &lt;20,24,28&gt; translate y*3  inverse }
</pre>

<p>
  An inverse transform does the opposite of what the transform would normally do, and can be used to &quot;undo&quot; 
 transforms without messing around with huge numbers of transformations. To do the same without this <code>inverse</code>, 
 you would have to duplicate each transform, change them to do the opposite of what they would normally do (for example <code>translate 
 -y*3</code> instead of <code>translate y*3</code>)and reverse their order. 
</p>

<h4><a name="s02_02_07_04">2.2.7.4 </a>Transform Identifiers</h4>

<p>
  At times it is useful to combine together several transformations and apply them in multiple places. A transform 
 identifier may be used for this purpose. Transform identifiers are declared as follows: 
</p>

<pre>
TRANSFORM_DECLARATION:
  #declare IDENTIFIER = transform{ TRANSFORMATION... } |
  #local IDENTIFIER = transform{ TRANSFORMATION... }
</pre>

<p>
  Where <em>IDENTIFIER</em> is the name of the identifier up to 40 characters long and <em>TRANSFORMATION</em> is any 
 valid transformation modifier. See &quot;<a href="s_98.html#s03_02_02_02_02">#declare vs. #local</a>&quot; for 
 information on identifier scope. Here is an example... 
</p>

<pre>
  #declare MyTrans =
    transform {
      rotate THISWAY
      scale SOMUCH
      rotate -THISWAY
      scale BIGGER
      translate OVERTHERE
      rotate WAYAROUND
    }
</pre>

<p>
  A transform identifier is invoked by the <code>transform</code> keyword with or without brackets as shown here: 
</p>

<pre>
  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
  }
</pre>

<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 <code>translate</code>, <code>rotate</code>, <code>scale</code>, or <code> 
 matrix</code> modifiers. The <code>transform</code> is attached just once to each component. Applying each individual <code>translate</code>, 
 <code> rotate</code>, <code>scale</code>, or <code>matrix</code> modifiers takes longer. This only affects parsing - 
 rendering works the same either way. 
</p>

<h4><a name="s02_02_07_05">2.2.7.5 </a>Transforming Textures and Objects</h4>

<p>
  When an object is transformed all textures attached to the object <em>at that time</em> are transformed as well. 
 This means that if you have a <code> translate</code>, <code>rotate</code>, <code>scale</code>, or <code> matrix</code> 
 modifier in an object <em>before</em> a texture, then the texture will not be transformed. If the transformation is <em>after</em> 
 the texture then the texture will be transformed with the object. If the transformation is <em>inside</em> the <code>texture</code> 
 statement then <em>only the texture</em> is affected. The shape remains the same. For example: 
</p>

<pre>
 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
  }
 }
</pre>

<p>
  Transformations may also be independently applied to pigment patterns and surface normal patterns. 
</p>

<p class="Note">
  <strong>Note:</strong> scaling a normal pattern not only affects the width and spacing. It does also 
 affect the apparent height or depth of the bumps, for how to avoid this see <a href="s_116.html#s03_05_02_04">Scaling 
 normals</a>. 
</p>

<p>
  For example: 
</p>

<pre>
 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
              // and also the height. Has no effect on
              // color pattern.
   }
   rotate y*45 // This affects the entire texture but
  }            // not the object.
 }
</pre>
 <br> 
<table class="NavBar" width="100%">
  
 <tr>
   
  <td align="left" nowrap="" valign="middle" width="32">
    <a href="s_62.html"><img alt="previous" border="0" src="prev.png"></a> 
   
  </td>
   
  <td align="left" valign="middle" width="30%">
    <a href="s_62.html">2.2.6 Using the Camera</a> 
  </td>
   
  <td align="center" valign="middle">
    <strong>2.2.7 POV-Ray Coordinate System</strong> 
  </td>
   
  <td align="right" valign="middle" width="30%">
    <a href="s_64.html">2.2.8 Setting POV-Ray Options</a> 
  </td>
   
  <td align="right" nowrap="" valign="middle" width="32">
    <a href="s_64.html"><img alt="next" border="0" src="next.png"></a> 
   
  </td>
   
 </tr>
  
</table>
 </body> </html>