The RenderMan Interface - Paul Bourke
The RenderMan Interface - Paul Bourke
The RenderMan Interface - Paul Bourke
- No tags were found...
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Section 13<br />
LANGUAGE CONSTRUCTS<br />
13.1 Expressions<br />
Expressions are built from arithmetic operators, function calls, and variables. <strong>The</strong> language<br />
supports the common arithmetic operators (+, -, *, and /) plus the vector operators ˆ (cross<br />
product) and . (dot product), and the C conditional expression (binary relation expr1 :<br />
expr2).<br />
When operating on points, vectors, normals, or colors, an arithmetic operation is performed<br />
in parallel on each component. If a binary operator involves a float and a multicomponent<br />
type (such as a point, vector, normal, matrix, or color), the float is promoted to<br />
the appropriate type by duplicating its value into each component. It is illegal to perform<br />
a binary operation between a point and a color. Cross products only apply to vectors; dot<br />
products apply to both vectors and colors. Two points, two colors, or two strings can be<br />
compared using == and !=. Points cannot be compared to colors.<br />
<strong>The</strong> usual common-sense mathematical rules apply to point/vector/normal arithmetic.<br />
For example, a vector added to a point yields a point, a vector added to a vector yields a<br />
vector, and a point subtracted from a point yields a vector. Mixing the types of vectors,<br />
normals, and points (for example, taking a cross product of two points, rather than two<br />
vectors) is allowed, but is discouraged. A particular implementation may choose to issue<br />
a compiler warning in such cases. Note that vectors and normals may be used nearly<br />
interchangably in arithmetic expressions, but care should be taken to distinguish between<br />
them when performing coordinate system transformations.<br />
Matrix variables can be tested for equality and inequality with the == and != boolean operators.<br />
<strong>The</strong> * operator between matrices denotes matrix multiplication, while m1 / m2<br />
denotes multiplying m1 by the inverse of matrix m2. Thus, a matrix can be inverted by<br />
writing 1/m.<br />
13.2 Standard Control Flow Constructs<br />
<strong>The</strong> basic explicit control flow constructs are:<br />
• block-structured statement grouping,<br />
125