8
Expression Techniques 143
Parentheses are a special case. They are a grouping
or subexpression operator that is provided so you
can override the precedence order of the other
operators.
Variables
In expressions you write for
expression controllers
(page 2–315)
, variables are represented by
symbolic names. You create them to contain
constant or var i able va lues in your expressions.
Several predefined variables are also provided.
Some of these have a constant value, others c an
vary.
In expressions used for
parameter w iring (page
2–393)
and the
numerical expression evaluator
(page 1–13)
, you can use predefined variables with
constant values.
Predefined Variables w ith Constant Values
Thesearethepredefinedvariablesthathavea
constant value (var iable names are case-sensitive):
Variable
Name
Constant
Value
Use
pi
3.14159
Ratio of a circle’s
circumference to its diameter.
e
2.71828
Base of natural logarithms.
TPS
4800
Ticks per second. The tick is
the basic time u n it o f 3ds Max
animation.
Predefined Variables w ith Variable Value s
Thesearethepredefinedvariablesthathavea
variable, time-based value (var iable names are
case-sensitive).
Variable
Name
Meaning
F
Frame number. For each frame, F equals the
current frame number, counting from zero.
The range of frames can vary depending
on the number of fram es in the ac tive time
segment.
Variable
Name
Meaning
NT
Normalized time. By definition, normalized
time (NT) ranges from 0 to 1 over the act ive
time segment, regardless of how many
frames are in the segment. If you base
an expression on NT, its effect happens
exactly once over the range. You can also
multiply NT by a factor for the expression’s
effect to occur a certain number of t imes
(for example, 2*NT cau ses the expression’s
effect to oc cur twice ). Expressions based
on NT speed up or slow down if you cha nge
the l eng th of the time segment.
S
Seconds (elapsed time in seconds). Elapsed
time is measured from the first frame to the
current frame. The range of seconds can
vary depending on the total time of the
active time segment.
T
Ticks (elapsed time in ticks). There are 4800
ticks per second. Elapsed time is me asured
from the first frame to the current frame.
The range of ticks can vary depending on
thetotaltimeoftheactivetimesegment.
Rules for Varia ble N ames
• Variable names can contain as many
alphanumeric charac ters as you like. Their
length is not limited.
• Variable names cannot contain spaces.
• The variable name must b egin with a letter.
Numbers are valid within a variable name (as
in "Pos1" or "M23").
• Variable names are case-sensitive. For example,
"pos", "Pos", and "POS" designate three
different variables.
•Youcan’tcreateavariablewithanamethat
duplicates another name, including the variable
names that are predefined.
Fun ction s
Following is a list of the functions provided for
expressions. In this list, p, q, and r represent scalar
values or scalar expressions. V and W represent
vector values or vector expressions.