Show in Contents
Add to Favorites
Home: Flame
Slip Functions
Function Reference
Random Number Functions
Simple Mathematical Functions
The following functions
are useful for performing various simple mathematical calculations.
abs
Returns
the absolute value of a given number. The absolute value is the
positive value of any number.
Syntax: |
abs(Number) |
Arguments: |
- Number is the number of which you want
the absolute value.
|
Examples: |
- abs(3) returns 3.
- abs(-3) returns 3.
|
sign
Returns
the sign of a given number. The sign function returns 1 if the number
is above or equal to zero, and returns -1 if less than zero.
Syntax: |
sign(Number) |
Arguments: |
- Number is the number of which you want
the sign.
|
Examples: |
- sign(5) returns 1.
- sign(0) returns 1.
- sign(-0.001) returns -1.
|
pow
Returns
a number raised to the power of an exponent.
Syntax: |
pow(Number,Power) |
Arguments: |
- Number is the base number to be raised.
- Power is the exponent to which the base
number is raised.
|
Examples: |
- pow(3, 2) returns 9.
- pow(4, 3) returns 64.
- pow(5, 0) returns 1.
- pow(-2.5, 4) returns 39.0625.
|
sqrt
Returns
the square root of a given number.
Syntax: |
sqrt(Number) |
Arguments: |
- Number is the non-negative number of
which you want the square root.
|
Examples: |
- sqrt(25) returns 5.
- sqrt(abs(-25)) returns 5.
- sqrt(0) returns 0.
|
max
Returns
the larger of two given numbers.
Syntax: |
max(Number1, Number2) |
Arguments: |
- Number1 and Number2 are numbers of which
you want to find the maximum value.
|
Examples: |
- max(5.9, 8.1) returns 8.1.
- max(-14, -32) returns -14.
- max(axis1.position.x, axis2.position.x)
returns the larger of axis1.position.x or axis2.position.x.
|
min
Returns
the smaller of two given numbers.
Syntax: |
min(Number1, Number2) |
Arguments: |
- Number1 and Number2 are numbers of which
you want to find the minimum value.
|
Examples: |
- min(5.9, 8.1) returns 5.9.
- min(-14, -32) returns -32.
- min(axis1.position.x, axis2.position.x)
returns the smaller of axis1.position.x or axis2.position.x.
|
mod
Returns
the integer remainder from dividing one number by another. This
function is useful for repeating an animation every given number
of frames.
Syntax: |
mod(Number, Divisor) |
Arguments: |
- Number is the number to divide.
- Divisor is the number by which you want
to divide Number.
|
Examples: |
- mod(8, 3) returns 2 because 8 divided
by 3 is 2 with 2 as the remainder.
- mod(-8, 3) returns -2.
- mod(8, -3) returns 2.
- mod(-8, -3) returns -2.
- mod(7.5, 2.25) returns 0.75.
- mod(frame, 20) * 5 yields the following curve:
|