====== Mathematical Operators ====== The [[visual3d:documentation:pipeline:expressions:expressions_overview|Evaluate_Expression]] command can be used to evaluate arbitrary mathematical expressions. Use the following characters for your mathematical operators. **Arithmetic Operators** * [[#Plus|Plus ]] * [[#Minus|Minus]] * [[#Multiply|Multiply]] * [[#Divide|Divide]] * [[#Power|Power]] **Boolean Operators** * [[#Logical_Or|Logical OR]] * [[#Logical_And|Logical AND]] * [[#Using_the_Adjective_NOT|The Adjective NOT]] **Comparison Operators** * [[#Equals|Equals]] * [[#Not_Equals|Not Equals]] * [[#Less_Than|Less Than]] * [[#Less_Than_Or_Equals|Less Than Or Equals]] * [[#Greater_Than|Greater Than]] * [[#Greater_Than_Or_Equals|Greater Than Or Equals]] Note: Visual3D parses the mathematical operators before it parses the signal names. If you have a signal name that contains a mathematical operator (e.g. R-Foot1), Visual3D will probably not be able to parse the equation expression properly. ===== Arithmetic Operators ===== Arithmetic operations can generally be performed using syntax that is similar to that found in a variety of programming and scripting languages. ==== Plus ==== Addition is accomplished using the + character. An alternative syntax is **add(a,b)** where a and b are expressions that evaluate to numbers. NOTE: Pipeline command parameters use the + character as a delimiter. If the user wants to use an expression containing a + in a command parameter that allows multiple signals, then Visual3D will likely interpret this plus sign incorrectly. In this case the **add(a,b)** syntax should be used. 2 + 3 = 5 add(2,3) = 5 ==== Minus ==== Subtraction is accomplished using the - character. 3 - 2 = 1 ==== Multiply ==== Multiplication is accomplished using the * character. 3 * 2 = 6 ==== Divide ==== Division is accomplished using the / character. 6 / 3 = 2 ==== Power ==== Exponentiation is accomplished using the ^ character. 2^3 = 8 ===== Boolean Operators ===== Boolean operators deal with boolean values, such as TRUE and FALSE. These are represented numerically as 1 (TRUE) and 0 (FALSE). ==== Logical OR ==== The Logical OR operator is signified by the | character. It takes two boolean values as input and returns TRUE if either of the input values is TRUE. FALSE | FALSE = FALSE FALSE | TRUE = TRUE TRUE | FALSE = TRUE TRUE | TRUE = FALSE ==== Logical AND ==== The Logical AND operator is signified by the & character. It takes two boolean values as input and returns TRUE when both input values are TRUE. FALSE | FALSE = FALSE FALSE | TRUE = FALSE TRUE | FALSE = FALSE TRUE | TRUE = FALSE ==== The Adjective NOT ==== The logical adjective NOT can be used with both the logical AND and logical OR operators. It takes one boolean value as input and negates that boolean value. NOT(FALSE) = TRUE NOT(TRUE) = FALSE ===Example=== Given a workspace containing 3 trials (*trial1.c3d, *trial2.c3d, and *trial3.c3d). * All trials are assigned a TAG labeled WALK * trial1.c3d is also assigned a TAG labeled BAD Select_Active_File /FILE_NAME=WALK /QUERY=BAD ; This command results in *trial1.c3d being active Select_Active_File /FILE_NAME=WALK /QUERY=NOT(BAD) ; This command results in *trial2.c3d and *trial3.c3d being active. ===== Comparison Operators ===== Comparison operators take two inputs of the same type and return a boolean value. ==== Equals ==== Equality is tested using either = or ==. It returns TRUE if the two inputs have the same value and FALSE if they do not. ===Example=== Consider a model metric that is defined as a string and compare it to an explicitly defined string. Set_Model_Metric ! /CALIBRATION_FILE= /METRIC_NAME=TEST /METRIC_VALUE="TTT" ; Evaluate_Expression** /EXPRESSION=MODEL::METRIC::TEST="TTT" /RESULT_NAME=SCOTT /RESULT_TYPE=METRIC ! /RESULT_FOLDER=PROCESSED ; The text strings are equal, so the resulting signal contains a 1 (indicating TRUE). ==== Not Equals ==== Non-equality is tested using either <> or ><. Its behaviour is opposite that of equality. If (a==b) is TRUE then (a<>b) is FALSE. Similarly, if (a==b) is FALSE, then (a<>b) is TRUE. ==== Less Than ==== We can test is one value is less than another using the < character. ===Example=== Given two signals TARGET::ORIGINAL::RFT1 and TARGET::ORIGINAL::LFT1, use the Boolean operator < to identify when the Z component of RFT1 is less than the Z component of LFT1. Evaluate_Expression /EXPRESSION= TARGET::ORIGINAL::RFT1::Z < TARGET::ORIGINAL::LFT1::Z /RESULT_NAME=RFT1_GREATER /RESULT_TYPE=DERIVED /RESULT_FOLDER=PROCESSED ; The output signal will be 1 when RFT1::Z is less than LFT1::Z and 0 otherwise ===Example - Foot Clearance=== Heel and toe clearance are defined by two paths. It is possible to model "foot clearance" as the lower value of the heel and toe clearance values at each frame. {{:heel_toe_clearance.jpg}} Here is a simplified test of this. First, make the Global Workspace Active. Then, create 2 toy signals and calculate a third signal containing the lower value of the two toy signals. Evaluate_Expression /EXPRESSION=LIST(1,2,3,4,5) ! /SIGNAL_TYPES= ! /SIGNAL_FOLDER=ORIGINAL ! /SIGNAL_NAMES= ! /SIGNAL_COMPONENTS= /RESULT_TYPES=DERIVED /RESULT_FOLDERS=PROCESSED /RESULT_NAME=SIGNAL1 ! /APPLY_AS_SUFFIX_TO_SIGNAL_NAME=FALSE ; Evaluate_Expression /EXPRESSION=LIST(5,4,3,2,1) ! /SIGNAL_TYPES= ! /SIGNAL_FOLDER=ORIGINAL ! /SIGNAL_NAMES= ! /SIGNAL_COMPONENTS= /RESULT_TYPES=DERIVED /RESULT_FOLDERS=PROCESSED /RESULT_NAME=SIGNAL2 ! /APPLY_AS_SUFFIX_TO_SIGNAL_NAME=FALSE ; !create a new signal that is the lower value of the two signals Evaluate_Expression /EXPRESSION=(DERIVED::PROCESSED::SIGNAL1<=DERIVED::PROCESSED::SIGNAL2)*DERIVED::PROCESSED::SIGNAL1 +(DERIVED::PROCESSED::SIGNAL2 {{:heel_toe_clearance2.jpg}} ==== Less Than Or Equals ==== This boolean operator uses one of the following syntaxes: <= or =<. The expression (a <= b) is equivalent logically to ((a < b) | (a == b)). ===Example=== Given two signals TARGET::ORIGINAL::RFT1 and TARGET::ORIGINAL::LFT1, use the Boolean operator <= or the boolean operative =< to identify when the Z component of RFT1 is less than or equal to the Z component of LFT1. Evaluate_Expression /EXPRESSION= TARGET::ORIGINAL::RFT1::Z <= TARGET::ORIGINAL::LFT1::Z /RESULT_NAME=RFT1_GREATER /RESULT_TYPE=DERIVED /RESULT_FOLDER=PROCESSED ; The output signal will be 1 (indicating TRUE) when RFT1::Z is less than or equal to LFT1::Z and 0 (indicating FALSE) otherwise. ==== Greater Than ==== We can test is one value is less than another using the > character. ===Example=== Given two signals TARGET::ORIGINAL::RFT1 and TARGET::ORIGINAL::LFT1, use the Boolean operator > to identify when the Y component of RFT1 is greater than the Y component of LFT1. Evaluate_Expression /EXPRESSION= TARGET::ORIGINAL::RFT1::Y > TARGET::ORIGINAL::LFT1::Y /RESULT_NAME=RFT1_GREATER /RESULT_TYPE=DERIVED /RESULT_FOLDER=PROCESSED ; The output signal will be 1 (indicating TRUE) when RFT1::Y is greater than LFT1::Y and 0 (indicating FALSE) otherwise. ==== Greater Than Or Equals ==== This boolean operator uses one of the following syntaxes: >= or =>. The expression (a >= b) is equivalent logically to ((a > b) | (a == b)).