Debian Codegraph @

doc/man/man3/ivm/engines/SoCalculator.ivm

raw
1 NAME SoCalculator "" "" { a general-purpose calculator }
2
3 DESC {
4 This engine is a general-purpose calculator.
5 The calculator operates on floating-point values and 3D
6 floating-point vectors.
7 The engine takes up to eight inputs of each type
8 (\+\cSoMFFloat\. and \cSoMFVec3f\.\.\-\cSoMFloat\. and \cSoMV3f\.\.),
9 and produces up to four outputs of each type.
10 \p
11 Each input field (\va\.-\vh\., \vA\.-\vH\.) can have multiple values,
12 allowing the engine to
13 evaluate the expression with different values in parallel.
14 Some inputs may have more values than others. In such cases,
15 the last value of the shorter inputs will be repeated as necessary.
16 \p
17 The \vexpression\. input string specifies the expression to be evaluated.
18 An expression can consist of multiple subexpressions.
19 Several subexpressions can be specified in one string,
20 separated by semicolons (;).
21 Alternatively, the subexpressions can be stored in separate strings
22 in the multiple-valued input field.
23 \p
24 Each subexpression is of the form:
25 \b
26 <lhs> = <rhs>
27 \.
28 The \k<lhs>\. can be any one of the outputs or a temporary variable.
29 The engine provides 8 temporary floating-point variables
30 (ta, tb, tc, td, te, tf, tg, and th),
31 and 8 temporary vector variables (tA, tB, tC, tD, tE, tF, tG, and tH).
32 You can assign a value to one component of a vector output (\vA\.-\vH\.)
33 or a vector variable (\vtA\.-\vtH\.) by using the [\|] operator.
34 For example, oA[0] = <rhs>, will evaluate the right hand side and assign
35 the value to the first component of the output vector \voA\..
36 \p
37 The \k<rhs>\. supports arithmetic, logical and conditional operators.
38 They are:
39 \b
40 (unary) !, -
41 (binary) +, -, *, /, %, <, > <=, >=, ==, !=, &&, ||
42 (ternary) ? :
43 \.
44 The ternary operator is a conditional operator. For example,
45 \ka ? b : c\. evaluates to b if a != 0, and to c if a==0.
46 \p
47 Valid operands for the \k<rhs>\. include the inputs, outputs, temporary
48 variables, and their components (e.g. oA[0]).
49 Operands can also be numeric constants (e.g. 1.0),
50 pre-defined named constants, or pre-defined functions.
51 \p
52 The named constants are:
53 \b
54 MAXFLOAT
55 MINFLOAT
56 M_E
57 M_LOG2E
58 M_LOG10E
59 M_LN2
60 M_LN10
61 M_PI
62 M_SQRT2 = sqrt(2)
63 M_SQRT1_2 = sqrt(1/2)
64 \.
65 Most of the pre-defined functions come from the math library:
66 \b
67 cos, sin, tan,
68 acos, asin, atan, atan2,
69 cosh, sinh, tanh,
70 sqrt, pow, exp, log, log10,
71 ceil, floor, fabs, fmod.
72 \.
73 Other functions are defined by \cSoCalculator\.. They are:
74 \b
75 rand(f) - Random number generator
76 cross(v1, v2) - Vector cross product
77 dot(v1, v2) - Vector dot product
78 length(v) - Vector length
79 normalize(v) - Normalize vector
80 vec3f(f1, f2, f3) - Generate a vector from 3 floats
81 \.
82 The subexpressions are evaluated in order, so a variable
83 set in the <lhs> of an earlier expression may be used in the
84 <rhs> of a later expression.
85 \p
86 Note, when the input has multiple values, all the
87 subexpressions specified in the \vexpression\. are applied
88 to all the multiple input values.
89 This is unlike the \cSoBoolOperation\. engine, where each
90 operation is applied only to the corresponding entries
91 of the input data.
92 Note also, that even though the inputs and outputs can have multiple
93 values the [\|] operator is only for indexing into the values of a
94 single vector.
95 It does not index into the multiple values of a field.
96 For example, if the floating-point input field \va\. has two values:
97 1.0, and 2.0, then the expression
98 \b
99 "oA[0]=a; oA[1]=a; oA[2]=0.0"
100 \.
101 will produce two output vectors in \voA\.: (1.0, 1.0, 0.0) and
102 (2.0, 2.0, 0.0).
103 \p
104 Examples of expressions:
105 \b
106 "ta = oA[0]*floor(a)"
107 "tb = (a+b)*sin(M_PI)"
108 "oA = vec3f(ta, tb, ta+tb)"
109 "oB = normalize(oA)"
110 "ta = a; tb = sin(ta); oA = vec3f(ta, tb, 0)"\.
111 }
112
113 INCLUDE engines/SoCalculator.h
114
115 INPUT a { }
116 INPUT b { }
117 INPUT c { }
118 INPUT d { }
119 INPUT e { }
120 INPUT f { }
121 INPUT g { }
122 INPUT h { Inputs a-h are the floating-point values. }
123 INPUT A { }
124 INPUT B { }
125 INPUT C { }
126 INPUT D { }
127 INPUT E { }
128 INPUT F { }
129 INPUT G { }
130 INPUT H { Inputs A-H are the vectors. }
131 INPUT expression { The expression to be evaluated. }
132
133 OUTPUT oa { }
134 OUTPUT ob { }
135 OUTPUT oc { }
136 OUTPUT od { Outputs oa-od are the floating-point values. }
137 OUTPUT oA { }
138 OUTPUT oB { }
139 OUTPUT oC { }
140 OUTPUT oD { Outputs oA-oD are the vectors. }
141
142 METHOD Create SoCalculator() { Constructor }
143
144 ALSO { SoEngineOutput, SoBoolOperation }