**What are expressions?**

An expression describes how a set of values defines a new value. It consists of numbers, parameters, operators and functions. Operators and functions define how numbers together with parameters evaluate to a numeric result. Rules specify which symbols together form a valid expression.

**Expressions in Bongo 2 **

Expressions in Bongo support basic operations: addition [+], subtraction [-], multiplication [*] and division [/]. They are operators as they combine two values into one. Fifth supported operator is power [^]. Valid expressions constructed of numbers and operators are for example 5*4+7 and 7^2+5^2.

Supported functions are sine [sin], cosine [cos], tangent [tan], square root [sqrt], Pi [pi], floor [floor], ceiling [ceil], absolute value [abs] and natural logarithm [log]. They take in one argument and return a value. Function arguments can be any expressions surrounded by parentheses. Expressions constructed of numbers, operators and functions are for example sqrt(3^2+4^2) and tan(1)*cos(1).

Parentheses are also used to change the precedence of operators and functions. For example, multiplication normally has higher precedence than addition so 3+2*2 evaluates to 7 but with parentheses around the addition it evaluates to 10.

Animated objects’ transform parameters and properties can be used as parameters in expressions. Name of the property or transform parameter is typed inside number signs. For example the scaling along x-axis for an animated object named CoffeeCup has an expression #CoffeeCup.Scale X#.

A parameter can have multiple expressions by specifying the tick range they are valid in. The tick range is specified using [Start-Stop]. For example:

[0-50] #CoffeeCup.Scale X# [51-99] #CoffeeCup.Scale Z#

You can also use commas to separate the ticks:

[1,20,25] #CoffeeCup.Scale X# [30,35,40] #CoffeeCup.Scale Z#

The letter t has a special meaning in expressions. It is the current tick. So for example, expression 10*t+4 evaluates to 4 at tick 0 and 994 at tick 99.

Minus sign in front of a number or parameter negates the value. White spaces are allowed around numbers and parameters.

Expressions can be tweened together with keyframes using the weight values.

**Examples of expressions:**

1) 3.4 + 3 * sin( 2 * 3.14159265 * #ObjectA.Rotate X# / 360 )

2) -abs( t / 10 )

3) ( 3 + t ) / (4 + 3 * sin( t ) ) / ( ( cos( t ) + 2 ) * log( #Box.Position X# ) )

**Expressions and tweening**

Normally Bongo uses 3-dimensional tweening for position. This means that all the 3 coordinates x, y and z and tweened together. The other way to tween position is to treat all coordinates separately as numbers. Expressions do not support vector operations so controlling position with expressions is only possible when 3-dimensional tweening is disabled. This can be done in the Bongo Animation Manager by right clicking the object and unchecking “3D Tweening Enabled”.

© 2017 Created by Scott Davidson. Powered by