Previous:Float Functions   Main Index   Next:Vector Literals

### 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:
`vaxis_rotate(` VECTOR `,` VECTOR `,` FLOAT `)` |
`vcross(` VECTOR `,` VECTOR `)` |
`vrotate(` VECTOR `,` VECTOR `)` |
`vnormalize(` VECTOR `)`
``` ```
VECTOR_BUILT-IN_IDENT:
`x` | `y` | `z` | `t` | `u` | `v`
``` ```
``` ```

Note: VECTOR_IDENTIFIERS are identifiers previously declared to have vector values.

Previous:Float Functions   Main Index   Next:Vector Literals