This is an old revision of the document!
Table of Contents
Logic Circuits
Math
linear
Linear scale and constant offset.
return Input() * Scaling + Offset;
<[linear][DoubleA][] <[string8][Input][A.Output]> <[float64][Scaling][1.0]> <[string8][Offset][0.0]> >
mixlinear
Sum of two values, scaled with a factor. Weights can be negative, to subtract the inputs.
return Input0() * Weight0 + Input1() * Weight1 + Offset;
<[mixlinear][ABMix][] <[string8][Input0][A.Output]> <[string8][Input1][B.Output]> <[float64][Weight0][1.0]> <[float64][Weight1][1.0]> >
maximum
Returns the highest value in the list.
<[maximum][MaximumOfValue0Value1][] <[string8][Inputs][ Value0.Output Value1.Output ]> >
minimum
Returns the lowest value in the list.
<[minimum][MinimumOfValue0Value1][] <[string8][Inputs][ Value0.Output Value1.Output ]> >
absolute
Returns the absolute value of the input, without the sign. Inputs below 0.0 are turned positive.
<[absolute][Absolute][] <[string8][Input][Input.Output]> >
clamp
When the value is within a certain range the value itself is returned. When it leaves the range the output stays bounded to the range.
<[clamp][Clamped][] <[string8][Input][Value.Output]> <[tmvector2d][Range][ -1.0 1.0 ]> >
sum
Total sum of all inputs.
<[sum][APlusB][] <[string8][Inputs][ A.Output B.Output ]> >
product
Multiplies all inputs. Works great to turn off a function under certain conditions, e.g. disable the nose wheel steering.
<[product][ATimesB][] <[string8][Inputs][ A.Output B.Output ]> >
inverse
Divides 1.0 with the input. When Input is close to zero the inverse returns 0.0. Normally this function is never needed in the physics computations. If you want to convert units, this can be done in the graphics_input with the Scaling.
<[inverse][OneOverA][] <[string8][Input][A.Output]> >
linear_interpolation
Linear interpolations or mappings work by finding an intermediate value from nearby points. The points in the map define discrete points where the output value is know. The map is a list of 2d-vectors. The first component is the input, the second is the output mapped to that input.
The linear_interpolation stops at the last value and does not extrapolate.
<[linear_interpolation][LinearMapping][] <[string8][Input][Control.Output]> <[tmvector2d][Map][ (0.0 0.0) (1.0 1.0) ]> >
Any value to binary
logic_greater
Comparison of the two inputs.
if ( Input0() > Input1() ) return 1.0; else return 0.0;
<[logic_greater][Input0GreaterInput1][] <[string8][Input0][Input0.Output]> <[string8][Input1][Input1.Output]> >
logic_range
Determines if an input is within a given range.
if ( Input0() > Range.min && Input0() < Range.max ) return 1.0; else return 0.0;
<[logic_range][ValueInRange][] <[float64][Input][Value.Output]> <[float64][Range][ 0.0 1.0 ]> >
Binary operations
logic_invert
Negates the input.
if ( Input0() < 0.5 ) return 1.0; else return 0.0;
<[logic_invert][NotA][] <[string8][Input][A.Output]> >
logic_equal
Returns true (1.0) when the two inputs are equal (difference very small).
<[logic_equal][AEqualsB][] <[string8][Input0][A.Output]> <[string8][Input1][B.Output]> >
logic_set
Returns true (1.0) when the input is equal to any of the values in the set.
<[logic_set][LeftMagnetoLeft][] <[string8][Input][MagnetosLeft.Output]> <[string8][Set][2 3 4]> >
logic_and
When all input are true (above 0.5) the logic_and returns 1.0;
<[logic_and][ABAndC][] <[string8][Inputs][ A.Output B.Output C.Output ]> >
logic_or
When any input is true (greater 0.5) the logic_or returns true
<[logic_or][ABOrC][] <[string8][Inputs][ A.Output B.Output C.Output ]> >
logic_xor
The XOR gate returns 1.0 when the inputs are different (either a true or b true but not both).
if( ( Input0() > 0.5 ) != ( Input1() > 0.5 ) ) return 1.0; else return 0.0;
<[logic_xor][ExactlyOneGeneratorOff][] <[string8][Input0][LeftGeneratorOff.Output]> <[string8][Input1][RightGeneratorOff.Output]> >
logic_combination
Some combinations are tricky to evaluate with the elements introduced so far. When complex logic is needed for deciding an outcome, e.g. of a multi-failure mode, the logic_combination can be used to save loads of tmd objects.
<[logic_combination][ErrorCases][] <[string8][Inputs][ A.Output B.Output C.Output ]> >
Available combinations are requested with the output functions:
Output | Description |
---|---|
OutputNone | NOR - 1.0 if all inputs are below 0.5 |
OutputAny | OR - 1.0 if any input above 0.5 |
OutputAll | AND - 1.0 if all inputs above 0.5 |
OutputCount | Number of inputs above 0.5 |
OutputSingle | Exactly one input above 0.5 |
OutputDual | Exactly two inputs above 0.5 |
OutputTriple | Exactly three inputs above 0.5 |
OutputExclusively0 | Only the first input above 0.5 |
OutputExclusively1 | Only the second input above 0.5 |
OutputExclusively2 | Only the third input above 0.5 |
OutputExclusively3 | Only the fourth input above 0.5 |
OutputExclusively4 | Only the fifth input above 0.5 |
OutputExclusively5 | Only the sixth input above 0.5 |
OutputExclusively6 | Only the seventh input above 0.5 |
OutputExclusively7 | Only the eighth input above 0.5 |