### Section 7.2.6.2
Text Formatting

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:

"\a" | Bell or alarm, 0x07
"\b" | Backspace, 0x08
"\f" | Form feed, 0x0C
"\n" | New line (line feed) 0x0A
"\r" | Carriage return 0x0D
"\t" | Horizontal tab 0x09
"\v" | Vertical tab 0x0B
"\0" | Null 0x00
"" | Backslash 0x5C
"\'" | Single quote 0x27
"\"" | Double quote 0x22

For example:

      #debug "This is one line.\nBut this is another"

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.

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.

The exceptions are the

any string literals you specify anywhere in the POV-Ray language.

### Section 7.3
POV-Ray Coordinate System

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 "Understanding POV-Ray's Coordinate System".

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 < 1,2,3> means the point that's one unit to the right, two units up and three units in front of the center of the universe at <0,0,0>.

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.

The supported transformations are rotate, scale and translate. They are used to turn, size and translate an object or texture. A transformation matrix may also be used to specify complex transformations directly.

### Section 7.3.1
Transformations

The supported transformations are rotate, scale and translate. They are used to turn, size and translate an object or texture.

      rotate <VECTOR>
      scale <VECTOR>
      translate <VECTOR>

### Section 7.3.1.1
Translate

An object or texture pattern may be moved by adding a translate parameter. It consists of the keyword translate 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

      sphere { <10, 10, 10>, 1
        pigment { Green }
        translate <-5, 2, 1>
      }

will move the sphere from <10,10,10> to < 5,12,11>. It does not move it to the absolute location <-5,2,1>. Translating by zero will leave the element unchanged on that axis. For example:

      sphere { <10, 10, 10>, 1
        pigment { Green }
        translate 3*x // evaluates to <3,0,0> so move 3 units
                      // in the x direction and none along y or z
      }

### Section 7.3.1.2
Scale

You may change the size of an object or texture pattern by adding a scale parameter. It consists of the keyword scale 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.

Scale is used to stretch or squish 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.

For example

      sphere { <0,0,0>, 1
        scale <2,1,0.5>
      }

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.

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:

      object {
        MyObject
        scale 5 // Evaluates as <5,5,5> so uniformly scale
                // by 5 in every direction.
      }

### Section 7.3.1.3
Rotate

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

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

      rotate <0, 30, 0>  // 30 degrees around Y axis then,
      rotate <-20, 0, 0> // -20 degrees around X axis then,
      rotate <0, 0, 10>  // 10 degrees around Z axis.

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

To work out the rotation directions you must perform the famous Computer Graphics Aerobics exercise as explained in the section "Understanding POV-Ray's Coordinate System".

### Section 7.3.1.4
Matrix Keyword

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

      matrix < m00, m01, m02,
               m10, m11, m12,
               m20, m21, m22,
               m30, m31, m32 >

Where m00 through m32 are float expressions that specify the elements of a 4*4 matrix with the fourth column implicitly set to <0,0,0,1>. A point P, P=<px, py, pz>, is transformed into Q, Q=<qx, qy, qz> by

      qx = M00 * px + M10 * py + M20 * pz + M30
      qy = M01 * px + M11 * py + M21 * pz + M31
      qz = M02 * px + M12 * py + M22 * pz + M32

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.

      object {
        MyObject
        matrix < 1, 1, 0,
                 0, 1, 0,
                 0, 0, 1,
                 0, 0, 0 >
      }

### Section 7.3.2
Transformation Order

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!

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

      translate <5, 6, 7>
      scale 4

will translate to <20,24,28> instead of < 5,6,7>. Be careful when transforming to get the order correct for your purposes.

### Section 7.3.3
Transform Identifiers

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:

      #declare IDENT = transform { TRANSFORMATION... }

Where IDENT is the identifier to be declared and TRANSFORMATION is one or more translate, rotate, scale or matrix specifications or a previously declared transform identifier. A transform identifier is invoked by the transform keyword without any brackets as shown here:

      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
      }

On extremely complex CSG objects with lots of components it may speed up parsing if you apply a declared transformation rather than the individual translate, rotate, scale or matrix specifications. The transform is attached just once to each component. Applying each individual translate, rotate, scale or matrix specifications takes long. This only affects parsing - rendering works the same either way.

### Section 7.3.4
Transforming Textures and Objects

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

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

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:

      box { <0, 0, 0>, <1, 1, 1>
        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.
      }

### Section 7.4
Camera

The camera definition describes the position, projection type and properties of the camera viewing the scene. Its syntax is:

      camera {
        [ perspective | orthographic | fisheye |
          ultra_wide_angle | omnimax | panoramic |
          cylinder FLOAT ]
        location <VECTOR>
        look_at <VECTOR>
        right <VECTOR>
        up <VECTOR>
        direction <VECTOR>
        sky <VECTOR>
        right <VECTOR>
        angle FLOAT
        blur_samples FLOAT
        aperture FLOAT
        focal_point <VECTOR>
        normal { NORMAL }
      }

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.

Regardless of the projection type all cameras use the location, look_at, right, up, direction and sky 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.

### Section 7.4.1
Type of Projection

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.

Perspective projection: 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 angle, 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.

The perspective camera.

Orthographic projection: 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.

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.

Fisheye projection: This is a spherical projection. The viewing angle is specified by the angle keyword. An angle of 180 degrees creates the "standard" fisheye while an angle of 360 degrees creates a super-fisheye ("I-see-everything-view"). 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 "Aspect Ratio".

Ultra wide angle projection: 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 angle keyword.

Omnimax projection: 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 angle keyword isn't used with this projection.

Panoramic projection: This projection is called "cylindrical equirectangular projection". 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 angle keyword is used to determine the viewing angle.

Cylindrical projection: 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:

1 | vertical cylinder, fixed viewpoint
2 | horizontal cylinder, fixed viewpoint
3 | vertical cylinder, viewpoint moves along the cylinder's axis
4 | horizontal cylinder, viewpoint moves along the cylinder's axis

If the perspective camera is used the angle keyword overrides the viewing angle specified by the direction keyword and vice versa. Each time angle is used the length of the direction vector is adjusted to fit the new viewing angle.

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.

You should note that the vista buffer can only be used with the perspective and orthographic camera.

Next Section
Table Of Contents