# Expressions

Jump to navigation
Jump to search

Language: |
English
• français • italiano • português • español |
---|

Many (but not all) edit boxes and pipeline command parameters allow the use of expressions instead of numerical values. Visual3D uses a common expression parser, so the following syntax is common across all command parameters that allow expressions.

## Evaluate_Expression Command

The Evaluate_Expression command allows the users to include expressions for defining the processing of the signals.

- Evaluate_Expression
- /Expression=
- !/Signal_Type=
- !/Signal_Folder=
- !/Signal_Name=
- /Result_Type=
- /Result_Folder=
- /Result_Name=
- !/Apply_as_suffix_to_signal_name=FALSE
**;**

### Expression_Items

- Data Tree Signals
- Expressions_in_Model_Builder_Mode
- Pipeline_Parameters
- Tags
- C3D_Parameters
- Model Metrics
- String Data

### Visual3D Reserved Characters

There are five characters that cause the equation parser considerable trouble. We have introduced reserved pipeline commands that can be used in the place of these characters.

### Visual3D Reserved Names

Reserved_Names CURRENT_SIGNAL short hand for signal names NAN Not a Number isNAN Is Not a Number?

### Numbers

Mathematical Constants pi() 3.14159265358979323846 gravity_vector() gravity vector in the laboratory coordinate system. For a z-up coordinate system returns (0,0,-9.81) rand() Generate a random number

### Mathematical Operators

**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.**

**Also Note the potential conflict between some of the operators and the reserved characters. If the string is obviously an expression, there is no conflict.**

Mathematical Operators + Plus or Add - Minus or Subtract * Multiply / Divide ^ Power -> for example, x^2 = x to the power 2 | logical OR -> the adjective NOT is allowed & logical AND -> the adjective NOT is allowed == OR = Equals <> OR >< Not Equals < Less Than <= OR =< Less Than or Equals To > Greater Than >= OR => Greater Than or Equals To NOT() NOT()

#### The ugly truth of the logical and

- & is used by Visual3D for concatenating strings
- it works quite well, but there is one circumstance where this choice of delimiter is a nuisance.
- and that is when you want & to actually be a logical and and the parser throws it away
- in this case you can use the reserved string AMP

- it was only really ugly before version 2024_04 because it didn't work before then

- Example given a file that has TAGS labelled TEST1 and TEST2
- To select files containing the tags TEST1 and TEST2
- Select_Active_File
- /FILE_NAME=ALL_FILES
- /QUERY=TEST1 & TEST2
- ! /SUBJECT_TAGS=NO_SUBJECT
**;**

- ! But what if you want to generalize and use another pipeline parameter for TEST2
- Set_Pipeline_Parameter
- /PARAMETER_NAME=SCOTT2
- /PARAMETER_VALUE=TEST1 &::AMP &::SCOTT
**;**

- Select_Active_File
- /FILE_NAME=ALL_FILES
- /QUERY=TEST1 &::AMP &::SCOTT
- ! /SUBJECT_TAGS=NO_SUBJECT
**;**

### Brackets

## Functions

- Visual3D has pre-defined functions imbedded in the pipeline to help you out.
- These functions are commonly used or have been added based on customer use.

** Metric Functions**

** Signal Functions**

### String Data

**Least Squares Fitting of Data**

** Intersection Functions**

**Assigned Force Functions**

**Trigonometric Functions**

** Array and Matrix Functions**

### Common Math Expressions

**int(a**) - truncate each component to the nearest integer

**round(a)**- round each component to the nearest integer

**fmod(y,x)**- Returns the floating-point remainder of y/x

- => y and x must be one dimensional signals; returns a one dimensional signal

**abs(a)**- absolute value

**sign(a)**= sign of the signal ((a<0)=-1, (a>0)=1, (a==0) = 0

**sqrt(a)**- square root

**exp(a)**- exponent

**log(a)**- natural log

**log10(a)**- log base 10

**length(x)**-- creates the length (magnitude) of a vector

**distance(a,b)**-- distance between two signals.- Example

- Evaluate_Expression
- /Expression= distance(LANDMARK::ORIGINAL::RIGHT_HIP , TARGET::ORIGINAL::LHIP)
- /Result_Name=PROX_THIGH_RADIUS
- ! /Result_Type=DERIVED
- ! /Result_Folder=PROCESSED
**;**

**dot (a, b)**-- creates the dot product of a and b

**cross (a, b)**-- creates the cross product of a and b

**NOTE: Often you will want to do dot (a, b)/ length (b), or cross (a, b) / length (b)**

## Expression Examples

Examples of using Evaluate_Expressions can be found here: **Expressions Examples**