Documentation Talk:Reference Section 2.1

From POV-Wiki
Revision as of 12:06, 20 May 2010 by Clipka (talk | contribs) (Vector Expressions: fix indentation of "NUMERIC_FACTOR:" in syntax)
Jump to navigation Jump to search

Vector Expressions

POV-Ray often requires you to specify a vector. A vector is a set of related float values. Vectors may be specified using literals, identifiers or functions which return vector values. You may also create very complex vector expressions from combinations of any of these using various familiar operators.

POV-Ray vectors may have from two to five components but the vast majority of vectors have three components. Unless specified otherwise, you should assume that the word "vector" means a three component vector. POV-Ray operates in a 3D x, y, z coordinate system and you will use three component vectors to specify x, y and z values. In some places POV-Ray needs only two coordinates. These are often specified by a 2D vector called an UV vector. Fractal objects use 4D vectors. Color expressions use 5D vectors but allow you to specify 3, 4 or 5 components and use default values for the unspecified components. Unless otherwise noted, all 2, 4 or 5 component vectors work just like 3D vectors but they have a different number of components.

The syntax for combining vector literals into vector expressions is almost identical to the rules for float expressions. In the syntax for vector expressions below, some of the syntax items are defined in the section for float expressions. See "Float Expressions" for those definitions. Detailed explanations of vector-specific issues are given in the following sub-sections.

VECTOR:
  NUMERIC_TERM [SIGN NUMERIC_TERM]
  NUMERIC_TERM:
  NUMERIC_FACTOR [MULT NUMERIC_FACTOR]
NUMERIC_FACTOR:
  VECTOR_LITERAL        | 
  VECTOR_IDENTIFIER     | 
  SIGN NUMERIC_FACTOR   | 
  VECTOR_FUNCTION       |
  VECTOR_BUILT-IN_IDENT | 
  ( FULL_EXPRESSION )   | 
  ! NUMERIC_FACTOR      | 
  FLOAT
VECTOR_LITERAL:
  < FLOAT , FLOAT , FLOAT >
VECTOR_FUNCTION:
  min_extent ( OBJECT_IDENTIFIER )         |
  max_extent ( OBJECT_IDENTIFIER )         |
  trace(OBJECT_IDENTIFIER, VECTOR, VECTOR, [VECTOR_IDENTIFIER] )|
  vaxis_rotate( VECTOR , VECTOR , FLOAT )  |
  vcross( VECTOR , VECTOR )                |
  vrotate( VECTOR , VECTOR )               | 
  vnormalize( VECTOR )                     |
  vturbulence(FLOAT, FLOAT, FLOAT, VECTOR)
VECTOR_BUILT-IN_IDENT:
  x | y | z | t | u | v

...

Specifying Colors

COLOR:
  COLOR_BODY             |
  color COLOR_BODY       | (this means the keyword color or
  colour COLOR_BODY         colour may optionally precede
                            any color specification)
COLOR_BODY:
  COLOR_VECTOR           |
  COLOR_KEYWORD_GROUP    |
  COLOR_IDENTIFIER
COLOR_VECTOR:
  rgb <3_Term_Vector>  |
  rgbf <4_Term_Vector> |
  rgbt <4_Term_Vector> |
  [ rgbft ] <5_Term_Vector>
COLOR_KEYWORD_GROUP:
  [ COLOR_KEYWORD_ITEM ]...
  COLOR_KEYWORD_ITEM:
  COLOR_IDENTIFIER       |
  red Red_Amount         |
  blue Blue_Amount       |
  green Green_Amount     |
  filter Filter_Amount   |
  transmit Transmit_Amount