University of California, Berkeley EECS Dept, CS Division |
||
Jordan Smith |
SLIDE: Scene Language for Interactive Dynamic Environments |
Prof. Carlo H. Séquin |
Home | Goals | Publications | People | Gallery | Assignments | Distributions |
expr math
expr (30 * sin(100)) + $SLF_MOUSE_X
sin, cos, tan, atan, asin, acos, atan2, exp, log
).
Pretty much any math you can do in C, you can do in TCL.
The only thing that works much differently is arrays and array
indexing, which uses lists.
This should be all you need to know to design a dynamic scene. If you want to explore all the power of TCL, you can use your own variables, functions, and even widgets, but simple mathematical expressions should be sufficient to create interesting behaviors in your SLIDE scene.
set
command:set variable value
set x 30
$y
gets the value of the
variable y
.set z $y
Square brackets force evaluation of a statement, whereas curly
braces pass the statement along unevaluated as a list, so
set y [expr 10 * 100]
gives the variable y
the value 1000, whereas
set y {expr 10 * 100}
gives the variable y
the list value {expr, 10, *, 100}.
set v {1 2 3}
list
statement:set v [list 1 2 [expr sin(30)]]
lindex
(short for listindex), so with v
defined as above:lindex $v 0
lindex $v 1
lindex $v 2
sin(30)
or 0.5.
wish
and
type in TCL expressions at the command prompt.
You may want to start out by defining those SLIDE variables that you
will expect to find with some arbitrary value:
set SLF_TIME 1
set SLF_MOUSE_X 100
set SLF_MOUSE_Y 300
You can check the value of any variable with the command,
puts
(short for putstring).puts $y
source
command: source my_commands.tcl
This page was originally built by Jordan Smith.
Last modified: Saturday, 06-Feb-1999 23:50:03 PST