Mathematical Expression Scripting
Sunday, June 25, 2017 3:15 AMOverview
Mathematical Expression Scripting is a powerful feature available in the Knots editing animation view. This allows the feeding of existing animated values into a mathematical function crafted by the user.
Usage
When the calculator button is clicked, the following panel is shown:
A text expression representing the mathematical function is used as input to this operation. The mathematical expression is run on the current animated values over the Time/Frame range defined in the options above.
You will use the x variable to represent the incoming animated values. A time t variable is also available if the function is time dependent. t holds the incoming Time/Frame values of the current animation clip. For example, if the current animation clip has a Time/Frame range of 0 to 280, then t will contain integer values of 0 to 280 for each application of the mathematical expression.
In the above example, a mathematical expression of:
x + 5.0 * sin(t * 10)
will read in animated values into the x variable and then modify it with the function above. This essentially applies an additional sine wave function with a magnitude value of 5.0 and frequency of 10 onto the existing animated values. The sine wave changes over time based on the t variable.
The resulting animated curve is shown below:
As you can see, this feature allows the easy manipulation of large amounts of animated data using scripted mathematical expressions.
More Examples
Adding a fixed value to all animated keys
You can easily add a fixed value if say 10.0 to a set of animated keys in a defined Time/Frame range by using an expression like this:
x + 10.0
This can be useful if you wanted to add an additional 10 degrees of rotation to a FK bone motor for instance.
Scaling all animated keys down
You can half the value of every animated key in the defined Time/Frame range by using an expression like this:
0.5 * x
Available Math Functions
The following math functions are available:
abs, acos, asin, atanm atan2, ceil, floor, acosh, asinh, atanh, exp2, expm1, gamma, lgamma, log1p, log2, logb, rint, round, scalbn, trunc, sin, cos, sqrt, tan, max, min