This is a child page. You can use Parent in the quick nav bar at the top or the bottom of the page to navigate directly back to the parent of this page. Some child pages are more than one level deep, and in that case will require more than one Parent click to reach the outermost document level.

#### 16.90.6.9 - Mathematical Expressions and Keys

Animating a ray trace requires some basic mathematical background. This animation will be simple in its movements so as not to be overly complicated. The image below was used in the image map on the rectangle. This image gave the rectangle a "felt table" look.

Note that all keys are set for 30 frames. Library: Initialize random number:  <seed 10 Keys let you set "trends" for any effect in the ray trace operator. The Keys operator works as follows: Keys "keyname" frame1 value frame2 value... etc. This is saying "From frame 1 to frame 15, I want the value of 'cuemovex' to go from -12 to -2. Then, from frame 15 to 30, I want the value of 'cuemovex' to go from -2 to -5." This value is going to be used in the x-position of the cueball. That means that the cueball is going to move left, and bounce back rightward abruptly: "From frame 1 to 15, 'cuemovez' will remain 0. From frame 15 to 30, the value of 'cuemovez' will go from 0 to 3." This value will be used in the z-position of the cueball, that means that it's also going to move farther away from the camera: This is going to be used in the rotation of the cueball. It will rotate just a bit about x when the abrupt bounce happens: This is going to be used as the x-position of the fourball, so it stays in place until frame 15, then shoots forward on x: Four ball: Follow the "four" keys  <radius 3 Follow four rotation keys Cue Ball: Follow cue keys  <radius 3 Rotate per cue keys Felt: The felt surface is going to be a arbitrarily large rectangle, to simulate a pool table surface, it will also be imagemapped with a tiled image of real felt. Rectangles have to be bound within a structure: These are the vertices of the rectangle. Tile 10000 x 10000 area Optimize: Light: Camera:

This is the end product of the script

Some notes and tips for adding mathematical expressions to your ray traces:

Always remember that you must prefix an expression with '!' (an exclamation point). No whitespace is allowed inside the expression either, whitespace is the signal to the evaluator that the expression is complete.

Tip:

A simple boilerplate way to make circles is to add the following expressions:

Now it treats the frame number as a fractional part of one whole rotation. Now you just determine the radius you want, and you have a circle.

You can also set a variable for the radius so it lives in one easy to find place by adding a key:

Now "radius" will remain constant, and can be changed for all instances with little effort.

You can also model an oval by giving unequal radii for the sin and cos function.

Spinning the camera would be:

This will move in a circle in/out and left/right, not up/down

Here is a list of valid expressions for the ray tracer's SceneScript.

One more example.