Small Instantiation Language: Expressions

SILLY supports numeric, vector and shape expressions, and they are always evaluated at compile time, when the scene tree is constructed.

Operators

The typical set of symbolic operators acting on numeric, vector and shape operands, is supported.

Operator +

Operator + implements the sum of numbers and vectors, and can be used as an alternative syntax for shape union.

Operation Yields Meaning
number + number   number   Numeric addition.  
vector + vector vector Vector sum.
shape + shape shape Shape union.

This operator can also be used as a unary operator when the operand is a number or vector.

Operator -

Operator - implements the substraction of numbers and vectors, and can be used as an alternative syntax for shape difference.

Operation Yields Meaning
number - number   number   Numeric substraction.  
vector - vector vector Vector substraction.
shape - shape shape Shape difference.

This operator can also be used as a unary operator when the operand is a number or vector.

Operator *

Operator - implements the product of numbers and vectors, and can be used as an alternative syntax for shape intersection.

Operation Yields Meaning
number * number number Numeric multiplication.
vector * vector number Vector inner product.
number * vector vector Vector scalar product.
vector * number vector Vector scalar product.
shape * shape shape Shape intersection.

Operator /

Operator - implements the divison of numbers and vectors by numbers.

Operation Yields Meaning
number / number number Numeric division.
vector / number vector Vector scalar division.

Function calls

SILLY supports several predefined scalar functions that always act on numeric operands.

 Function  Meaning
 Abs  Absolute value
 Cos  Cosine
 Sin  Sine
 Tan  Tangent
 Sqrt  Squared root

Transformation operators

A very important feature of ray tracers is the ability to apply Euclidean transformations to basic and complex shapes. This transformations are implemented by the XSight RT Engine as special shape classes. For instance, if you want to rotate a red box around the Y axis, you could use one of the constructors from the Rotate class:

rotate(0, 45, 0,
    box([1-,-1,-1], [+1,+1,+1], plastic(red)))

As you can see, the shape to be rotated is passed as a parameter. However, this notation is not the most convenient one. Nesting constructor calls add more parenthesis and complexity to a scene. For this reason, we have designed three special operators corresponding to the three basic Euclidian transformations:

 Operator  Equivalent class
 move  Translate
 spin  Rotate
 size  Scale

These are binary operators, that accepts a shape as their first operand and a vector in their second operand. The size operator also allows a numeric value in its second operand, for an isotropic scale change. The rotated red box example can now be written this way:

box([1-,-1,-1], [+1,+1,+1], plastic(red))
    spin 45^Y

Another advantage of the transformation operators has to do with cascading transformations:

translate(10, 0, 0,
    rotate(0, 45, 0,
        box([1-,-1,-1], [+1,+1,+1], plastic(red)))

The above expression must be read as "translate ten units a rotated by 45 degrees box", which is unnatural. Compare now with the alternative:

box([1-,-1,-1], [+1,+1,+1], plastic(red))
    spin 45^Y
    move 10^X

Now you can read: "take a red box, rotate 45 degrees around the Y axis, and then move it 10 units to the right".

See also

Home | XSight Ray Tracer overview | Small Instantiation Language | Using XSight's Ray Editor | Basic syntax | Data types | Animation support | Macros | Scenes