Skip to content

FormulaEngine Concepts Functions

Mike Lewis edited this page Mar 7, 2016 · 1 revision

FormulaEngine Concepts - Functions

Beyond the four standard arithmetic operations, FormulaEngine allows any formula to invoke a number of functions. Just like their algebraic counterparts, FormulaEngine functions take some number of inputs and produce an output value. Typically functions are added to a formula when some operation cannot be expressed succinctly in arithmetic terms. Functions also have other uses for processing data within a formula.

Function Between(x, a, b)

Returns 1.0 if x lies on the interval [a,b] and 0.0 otherwise.

Function Distance(p1, p2)

Returns the Euclidean distance between points p1 and p2 - note that only points are supported as of this writing.

Function Equal(a, b)

Returns 1.0 if a and b are identical values and 0.0 otherwise. If a and b are of different types, always returns 0.0.

Function FuzzyMatch(t1, t2)

Returns 1.0 if t1 and t2 are both tokens that refer to "suitably similar" text strings. Useful for approximately matching text entered by the user to design-time text; see FormulaMUD for example usage.

Function Less(a, b)

Returns 1.0 if a and b are scalars, and a is less than b. Returns 0.0 otherwise.

Function Limit(v, m)

Returns a vector of the same direction as v but limited to magnitude m. If v is of lesser magnitude than m, returns v unmodified.

Function Normalize(v)

Returns the normalized form of the input vector v.

Function Random(x)

Returns a uniformly distributed random number on the interval [0, x).

Function Round(x)

Returns x rounded to the nearest integer.

Function SumOf(l)

Given a list of scalars l, returns the sum of each element in the list.

Function Vec(x, y)

Converts the scalars x and y into an internal vector type with the same component values.