SoCalculator¶

InventorModule
¶ genre Fields
author MeVis Medical Solutions AG
package MeVisLab/Standard
dll SoUtils
definition utils.def see also SoClipBox
,ComposePlane
,CalculateAngle
,ComposeMatrix
,ComposeMatrix
,ComposePlane
,ComposeVector4
,DecomposeMatrix
,DecomposeVector4
keywords iv
,compute
,calculate
,plane
,synchronized
,distance
,parallel
Purpose¶
The module SoCalculator
calculates by evaluating expressions (with access to input/output fields) and writing the result to the output fields.
Details¶
The SoCalculator
has 7 input float fields named ag and 7 input vectors named vavg. It has 4 output float fields named
oaad and 4 output vectors named ovaovd.
The expression input string specifies the expression to be evaluated. An expression can consist of multiple subexpressions. Several subexpressions can be specified in one string, separated by semicolons (;) (newline characters are filtered automatically).
Each subexpression is of the form:
<lhs> = <rhs>
The <lhs> can be any one of the outputs (oaad, ovaovd) or a temporary variable. The engine provides 8 temporary floatingpoint variables (ta, tb, tc, td, te, tf, tg, and th), and 8 temporary vector variables (tA, tB, tC, tD, tE, tF, tG, and tH). You can assign a value to one component of a vector output (ovaovd) or a vector variable (tAtH) by using the [ ] operator. For example, ova[0] = <rhs>, will evaluate the right hand side and assign the value to the first component of the output vector ova.
The <rhs> supports arithmetic, logical and conditional operators. They are:
(unary) !, 
(binary) +, , *, /, %, <, > <=, >=, ==, !=, &&, 
(ternary) ? :
The ternary operator is a conditional operator. For example, a ? b : c evaluates to b if a != 0, and to c if a==0.
Valid operands for the <rhs> include the inputs, outputs, temporary variables, and their components (e.g. oA[0]). Operands can also be numeric constants (e.g. 1.0), predefined named constants, or predefined functions.
The named constants are:
MAXFLOAT
MINFLOAT
M_E
M_LOG2E
M_LOG10E
M_LN2
M_LN10
M_PI
M_SQRT2 = sqrt(2)
M_SQRT1_2 = sqrt(1/2)
Most of the predefined functions come from the math library:
cos, sin, tan,
acos, asin, atan, atan2,
cosh, sinh, tanh,
sqrt, pow, exp, log, log10,
ceil, floor, fabs, fmod.
Other functions are defined by SoCalculator. They are:
rand(f)  Random number generator
cross(v1, v2)  Vector cross product
dot(v1, v2)  Vector dot product
length(v)  Vector length
normalize(v)  Normalize vector
vec3f(f1, f2, f3)  Generate a vector from 3 floats
The subexpressions are evaluated in order, so a variable set in the <lhs> of an earlier expression may be used in the <rhs> of a later expression. Comments can be inserted with #.