8
144 Chapter 4: Object Properties
To use a function in an expression, enter the name
of the function and appropri ate arguments to it.
Trigonometric Functions
The sine, cosine, and tangent functions take an
angle in degrees and return a floating-point value.
Thearcfunctionstakeafloating-pointvalueand
return a value in degrees.
Funct ion M ea ni ng
sin(p)
sine
cos(p)
cosine
tan(p)
tangent
asin(p)
arc sine
acos(p)
arc cosine
atan(p)
arc tangent
Hyperbolic Functions
H yperbolic functions take a floating-point value
and return a floating-point value.
Funct ion M ea ni ng
sinh(p) hyperbolic sine
cosh(p) hyperbolic cosine
tanh(p) hyperbolic tangent
Conversion B etween Radians and Deg rees
Funct ion M ea ni ng
radToDeg(p) takes p in radians and
returns the sa me a ngle in
degrees
degToRad(p) takes p in degrees and
returns the sa me a ngle in
radians
Rounding Functions
Fu nction Meaning
ceil(p) smallest integer greater
than or equal to p
floor(p) largest integer less than or
equal to p
Standard Calculations
Fu nction Meaning
ln(p) natural (base e) logarithm
log(p) common (base 10)
logarithm
exp(p) exponential function
exp(p)=e^p
pow(p,q) p to the power of q (p^q)
sqrt(p)
square root
abs(p) absolute value
min(p,q)
minimum returns p or q,
depending o n which is
smaller
max(p,q)
maximum returns p or q,
depending o n which is
greater
mod(p,q) remainder of p divided by q
Conditional Functions
Fu nction Meaning
if(p,q,r) works like the common
spreadsheet "if" (If p is
nonzero t hen "if" returns q,
other w ise "if" returns r.)
vif(c,V1,V2) "Vector If " (Value is V1 if c is
true, else V2.)
Vec tor Handling Func tions
Fu nction Meaning
length(V) length of V
comp(V,i) i’th component (I=0,1,2):
comp([5,6,7],1)=6
unit(V) returns a unit vector in the
same direction as V