Go to start of banner

# Functions for defining variables

The following functions are available.

Variable timing information

You can set the timing information for each variable. This enables the function that generates your new variable to fetch the input data from input frames that are offset from the output frame. You have the following options:

• Continuous. The input variable will be taken at the same frame number as the one being calculated for the output variable.
• FirstValidFrame, LastValidFrame. The input variable is taken at either the first or the last valid frame of the trial. This is handy if, for example, you want the calculate the vector from the first valid point of a marker to the last valid point, i.e. the general direction in which the marker has moved throughout the trial. By creating a Vector between points A and B, where point A is trajectory X at the first valid frame, and point B is trajectory X at the last valid frame, you get the direction vector of the trajectory's overall movement.
• Previous, Following. The input variable is taken at either the previous or the following event type specified in the combo box alongside. This could, for example, be useful if you want to calculate the distance a marker has traveled between two foot contact events.
• First, Last. The input variable is taken at either the first or the last event type specified in the combo box alongside.

#### Arithmetic

These take two input variables of any type. Note variables of different types cannot always be combined – for example, you cannot add an angle to a length.

• Subtract: A-B
• Multiply: A*B
• Divide: A/B

#### Comparison

These functions take 2 or 4 input variables, performs a comparison and returns the relevant value.

• Max: A and B. Evaluates to the largest value of the input variables A and B.
• Min: A and B. Evaluates to the smallest value of the input variables A and B.
• If A > B then C else D. Compares A and B. If A is greater than B, then the function returns variable C, otherwise it returns D.If A = B then C else D. Compares A and B. If A is equal to B, then C is returned – otherwise D.

#### Normalize

You can use this to calculate a percentage.

• Return A in % of B. Returns A’s value as a percentage of B.

#### Distance

These are functions that measure a distance.

• Magnitude: A. Returns the magnitude (length) of the vector A.
• Distance: A to B. Returns the distance from point or segment A to point or segment B.

#### Point

These are functions that calculate the location of a 3D point.

• {A, B, C}. Defines a point directly from the three variables A, B and C, which then become the X, Y and Z component of the variable, respectively.
• {A, B, C} in Segment D’s local coordinates. Defines a point in global coordinates from the components X=A, Y=B and Z=C in segment D’s local coordinates.
• Point A offset by vector B. Starting at point A, this function defines a new point that is offset by vector B.
• Halfway between A and B. Defines the halfway-point between points A and B.
• Average of A, B and C. Defines the average point of the three input points A, B and C.
• Average of A, B, C and D. As above, except for all 4 input points.
• Distance A from point B towards point C. Starts in point B and travels the distance defined by A in the direction of Point C.
• Distance A from point B along vector C. Starts in point B and travels the distance defined by A along the Vector C.
• Joint center:Distance A from pont B, C defines normal, D defines plane. This is the “classic” Plug-in Gait method of defining a joint center (JC): a specific distance (typically half the joint width from the subject measurements plus half the marker diameter) away from point B (typically the joint marker), the JC point is placed so that the lines JC-B and JC-C are perpendicular
• Project: A onto B. A is a point which is projected onto a line or a plane, defined by B.
• Transform: A to B's local coordinates. A is a point in global space which is transformed to segment B's local coordinate system. This function returns a local point.
• Transform: A from B's coordinates back to global. The reverse of the above function, A is a local point specified in B's local coordinates which is transformed back to global. Note that no check is made to ascertain that the local point was originally defined in segment B's local coordinates.
• Conditional:If A exists then A else B. This can be used if a trajectory has gaps or for some other reason doesn’t exist in the trial.
• Conditional:If A exists then A else B in C’s coordinates back to global. This function is designed to make it easy to recalculate the position of a marker which you have stored as a position in a local coordinate system during a static trial.

#### Vector

These are 3D vector function that either define a vector or perform calculations on vectors.

• From A to B. The vector from point A to point B.
• Dot product: A * B. The dot (scalar) product of vectors A and B.
• Cross product: A x B. The cross product vector of input vectors A and B.
• Rotate: A to B's local coordinates. Rotates the input vector A using segment B's rotation matrix.
• Rotate: A in B's local coordinates back to global. The reverse of the above function - rotates the input vector A using the inverse of segment B's rotation matrix.
• Project: A onto B. Projects the vector A onto vector B.

#### Line

These functions define a line in 3D space.

• From A to B. Defines a line that passes through the points A and B.
• From A in direction B. Defines a line that passes through the point A and has the direction of vector B.

#### Plane

Defines a plane in 3D space.

• Contains A, B and C. Defines a plane that contains the points A, B and C.
• Contains A, normal vector B. The plane passes through point A, and has normal vector B.

#### Segment

Defines a segment which has a position and orientation in 3D space. There are many ways of defining a segment. The one to choose depends on how you want the internal axis system of the segment to be oriented.

• Origin A, X-Axis=A?B, Z-Axis=(A?B)x(A?C). Defines the segment using the three points A, B and C. The origin is at point A, whereas the major axis (X in this case) is defined by the vector from point A to point B. Then, the secondary axis is defined using the cross product of the major axis and the vector from A to C. The final axis is then formed from the cross product of the major and secondary axes, to form a right-handed coordinate system. This method of defining a segment is available for all axis configurations: XY, XZ, YX, YZ, ZX and ZY.
• Origin A, X-Axis=B, Z-Axis=B x C. This uses the point A and the vectors B and C to define the segment. B becomes the major axis, and the cross product of B and C becomes the secondary axis. This method is also available for all axis configurations.
• Define Origin A, X-Axis=lab axis closest to B, Z-Axis up. This is intended to make it easy to calculate a reference system that is aligned to the lab coordinate system.
• Define from 3-marker cluster A, B and C. The segment’s origin is the mid-point between the input points A, B and C. The segment’s axes are aligned with the marker positions. This is intended to be used for a technical coordinate system defined by a marker cluster consisting of 3 markers.
• Define from 3-marker cluster A, B, C and D. Equivalent to above, except based on a 4 marker cluster rather than 3.
• Offset segment A using segment B. This defines a segment that uses a source segment A and offsets this using segment’s B orientation and position. This is typically used when a static offset transformation has been calculated between a technical and an anatomical coordinate system during a static trial, and stored as a segment. During the dynamic trial, you can then offset the technical coordinate system A using the static offset B, which will recreate the anatomical coordinate system you started out with.

#### Angle

Defines an angle, which can be either 1D or 3D. All 3D angles are Euler angles.

• Angle: Between A and B. Defines a 1D angle between A and B. Both A and B can be a vector, a line, a plane or a segment. The angle returned is the absolute angle between two directional vectors, measured in the plane that contains both. The direction vector for a plane is its normal vector, and for a segment its major axis.
• Angle: Between A and B around C. Returns the angle between A and B, which as above can be a vector, a line, a plane or a segment, but this time calculated around the vector C (or segment, in which case it’s the segment’s major axis).
• Euler angle: <TOKEN> between A and B. Defines an Euler angle between segment A and B, using the <TOKEN> as the Euler extraction order. The available tokens are XYZ, XZY, YXZ, YZX, ZXY and ZYX.

#### Velocity

Calculates the speed, or the velocity, of an input variable.

• Velocity: A. Returns the velocity of point A or segment A's origin by differentiating the input variable using a 3-point numerical differentiator.
• Angular velocity: A. As above, but returns the angular velocity of vector A, Euler angle A or segment A's major axis.
• Velocity (5-point): A. As above, except that a 5-point numerical differentiator is used instead of a 3-point one.
• Angular velocity (5-point):A.

#### Acceleration

Calculates the acceleration of an input variable.

• Acceleration: A. Returns the acceleration of point A or segment A's origin, calculated by double-differentiating the input variable using a 3-point numerical differentiator.
• Angular acceleration: A. Returns the angular acceleration of vector A, Euler angle A or segment A's major axis.