### Inhaltsverzeichnis

# Functions

## General

### +

A binlary operator which calculates the sum of two variables. The following combinations of argument types are allowed:

argument 1 | argument 2 | result |
---|---|---|

integer | integer | integer |

double | double | double |

integer | double | double |

double | integer | double |

integer | complex | complex |

double | complex | complex |

complex | complex | complex |

complex | integer | complex |

complex | double | complex |

3d vector | 3d vector | 3d vector |

3d matrix | 3d matrix | 3d matrix |

**Example**

A + B

### -

This unary operator changes the sign of the given argument. For matrix argument the matrix inverse is determined.

Types:

Argument | Result |
---|---|

integer | integer |

double | double |

complex | complex |

3d vector | 3d vector |

3d matrix | 3d matrix |

#### Examples

-A

### *

### /

### abs()

This named function calculates the absolute value of the variable give as argument.

Types:

Argument | Result |
---|---|

integer | integer |

double | double |

complex | complex |

#### Examples

abs(A) abs(-3)

### log()

### ln()

### mod()

### sqr()

### sqrt()

### re()

### im()

### pow()

### rand()

## Trigometric

### sin()

### cos()

### sinh()

### cosh()

### tan()

### tanh()

### acos()

This named function determines the acrcos tangens of the given argument.

Argument | Result |
---|---|

integer | double |

double | double |

complex | double |

#### Examples

acos(a)

### asin()

This named function determines the arcos sinus of the given argument.

Types:

Argument | Result |
---|---|

integer | double |

double | double |

complex | double |

#### Examples

asin(A)

### atan()

This named function determines the arcos tangens of the given argument.

Types:

Argument | Result |
---|---|

integer | double |

double | double |

complex | double |

#### Examples

atan(A)

### atan2()

### atan2'()

### atan2''()

### asinh()

This named function determines the arcos sinus hyperbolicus of the given argument.

Types:

Argument | Result |
---|---|

integer | double |

double | double |

complex | double |

#### Examples

asinh(A)

### acosh()

This named function determines the acrcos tangens hyperbolicos of the given argument.

Types:

Argument | Result |
---|---|

integer | double |

double | double |

complex | complex |

#### Examples

acosh(a)

### asin'

This named function determines the first derivative of the arcos sinus of the given argument: 1d/(sqrt(1d-x*x))

Types:

Argument | result |
---|---|

integer | double |

double | double |

complex | double |

#### Examples

asin'(A)

### asin''

This named function determines the second derivative of the arcos sinus of the given argument: x/pow(1-x*x, 1.5).

Types:

Argument | result |
---|---|

integer | double |

double | double |

complex | double |

#### Examples

asin''(A)

## 3d

### dot()

Determination of the dot product of two given 3d vectors.

Types:

Argument 1 | Argument 2 | Result |
---|---|---|

3d vector | 3d vector |

#### Examples

dot(A,B)

### length()

Determination of the length of a given 3d vector.

Types:

Argument | Result |
---|---|

3d vector | double |

#### Examples

length(A)

### lengthSqr()

Determination of the length square of a given 3d vector.

Types:

Argument | Result |
---|---|

3d vector | double |

#### Examples

length(A)

### dist()

Distance between two points.

Types:

Argument 1 | Argument 2 | Result |
---|---|---|

3d vector | 3d vector | double |

#### Examples

dist(A,B)

### ddist()

Directed distance between two points. The first two arguments define the start point and the end point of a vector. The distance of the two points is calculated. The third argument defines a vector. If the vector defined by the first two points and this reference vector includes an angle less-90 or more than 90 degree than the result is negative else positive.

Types:

Argument 1 | Argument 2 | Argument 3 | Result |
---|---|---|---|

3d vector | 3d vector | 3d vector | double |

#### Examples

ddist(A,B, ref)

### vec()

This named function bundles the three double arguments to a 3d tuple result value. Typically this in interpreted as a vector.

Types:

Argument 1 | Argument 2 | Argument 3 | Result |
---|---|---|---|

double | double | double | 3d vector |

#### Examples

vec(x,y,z)

### angle2()

This named function with three arguments calculates the angle between arrows defined by the first two arguments. The third argument is used to define the sign of the resulting angle. It is interpreted as an arrow which defines the rotation direction to rotate the arrow from the first argument to the arrow of the second argument. If this results in angles more than 180 degrees a negativ angle is given instead.

Types:

Argument 1 | Argument 2 | Argument 3 | Result |
---|---|---|---|

3d vector | 3d vector | 3d vector | double |

#### Examples

angle2(A,B,t)

### circc()

Determination of a circles mid point where all three given arguments are laying on.

Argument 1 | Argument 2 | Argument 3 | Result |
---|---|---|---|

3d vector | 3d vector | 3d vector | 3d vector |

#### Examples

circc(A,B,C)

### angle()

This named function with two arguments calculates the so called atan2(x, y) if the arguments are of the type double. 3d vector arguments are interpreted as arrows and the angle between the two arrows are calculated.

Types:

Argument 1 | Argument 2 | Result |
---|---|---|

double | double | double |

3d vector | 3d vector | double |

#### Examples

angle(A,B)

### align()

If the vectors of both arguments are directed in the same half-space this named function results in a double value of -1, else +1.

Types:

Argument 1 | Argument 2 | Result |
---|---|---|

3d vector | 3d vector | double (-1 or +1) |

### norm()

Creates the normal vector of a plane based on three given points laying in the plane

Argument | Type | Description |
---|---|---|

1 | 3d vector | first point of a plane |

2 | 3d vector | seconds point of a plane |

3 | 3d vector | third point of a plane |

### normalize()

If the argument is a tuple with 3 elements, it is interpreted as a vector and the result is the normalized vector (length of the vector is set to 1).

Argument | Type | Description |
---|---|---|

1 | 3d vector | Normalize the vector. |

### mid()

### x()

Extracts the x/first-component of a 3d-vector.

Argument | Type | Description |
---|---|---|

1 | 3d vector | extracts the x-component auf a 3d vector. |

### y()

Argument | Type | Description |
---|---|---|

1 | 3d vector | extracts the y-component auf a 3d vector. |

### z()

Argument | Type | Description |
---|---|---|

1 | 3d vector | extracts the z-component auf a 3d vector. |

### q()

Create a quaternion from 4 double values.

Argument | Type | Description |
---|---|---|

1 | Double | x |

2 | Double | y |

3 | Double | z |

4 | Double | w |

## Special functions useful for 3D geometric calculations

### poc()

Determines a point on the line defined by the first two arguments (P0 and n0) which has the shortest distance to the line defined by the third and fourth arguments (P1,n1).

Argument | Description | Type |
---|---|---|

1 | Point to define the first line | VECTOR_3D |

2 | Direction to define the first line | VECTOR_3D |

3 | Point to define the second line | VECTOR_3D |

4 | Direction to define the second line | VECTOR_3D |

### PocL()

Point of contact straight line: The first two arguments define a straight line. The first is a point on this line and the second defines the direction of the line. A perpendicular is dropped from the point defined by the third point to this line and the result value is the point of contact in the straight line.

Argument | Description | Type |
---|---|---|

1 | Point to define a line. | VECTOR_3D |

2 | Direction to define a line. | VECTOR_3D |

3 | Point to start a second line perpendicular to the line defined by the first two arguments. | VECTOR_3D |

#### Examples

pocL(A,B,C)

### PocP()

Point of contact plane: The first two arguments define a plane. The first is a point in this plane and the second defines the direction of a normal to this plane. A perpendicular is dropped from the point defined by the third point to this plane and the result value is the point of contact in the plane.

Argument | Description | Type |
---|---|---|

1 | Point to define a plane the point lays in. | VECTOR_3D |

2 | Normal vector of the plane (direction perpendicular to the plane to define) | VECTOR_3D |

3 | Point to start a line perpendicular to the plane defined by the first two arguments. | VECTOR_3D |

#### Examples

PocP(A,B,C)

### midP()

Determines the point with the minimum distance to two given lines.

**Arguments:**

Argument | Type | Description |
---|---|---|

1 | VECTOR_3D | Point to define a the first line. |

2 | VECTOR_3D | Direction to define the first line. |

3 | VECTOR_3D | Point to define a the second line. |

4 | VECTOR_3D | Direction to define the second line. |

### PocPL()

Determines the point in the plane the arrow brakes through the plane.

**Arguments:**

Argument | Type | Description |
---|---|---|

1 | VECTOR_3D | Arbitrary point in a plane. |

2 | VECTOR_3D | Normal vector of the plane (normalization not needed). |

3 | VECTOR_3D | Point to define arrow. |

4 | VECTOR_3D | Direction of the arrow (normalization not needed). |

#### Examples

pocPL(A,B,C,D)

## Special functions useful for human motion analysis

### chordv()

Point at distance h from I in the plane IJK forming a right angle between I and J on the opposite side of IJ from K.

This function is useful in locating the center of the knee joint, from the position of the hip joint center and the position of a marker placed on the mid-thigh and lateral condyle of the knee:

- h distance in [mm] of the knee joint center to the lateral knee marker position
- I is set to the lateral knee marker position
- J to the hip joint center position,
- K to the position of the mid-thigh marker.

This is a re-implemementation of the equal named function used in Vicon clinical manager gait analysis software.

This function is used extensively in these models for defining joint centres. Three points are used to define a plane. One of these points is assumed to be a previously calculated joint centre, and a second is assumed to be a real marker, at some known, perpendicular distance (the Joint Centre Offset) from the required joint centre.

It's called a chord because by definition, the three points (two joint centres and the joint marker) lie on the periphery of a circle.

There is also a modified version of the function, which calculates the required joint centre position when the plane definition marker is rotated out of this plane by a known angle around the proposed joint centre axis.

The Knee joint centre (KJC) is calculated in the same manner in the static and dynamic model if no KAD is used.

In the dynamic model, the KJC is determined using the modified chord function, from the global position of the HJC, the thigh wand marker (THI), and the knee marker (KNE), together with the knee offset (KO), and thigh wand angle offset.

KJC is found such that the KNE marker is at a distance of KO from the KJC, in a direction perpendicular to the line from the HJC to KJC.

If a KAD is used the knee joint centre is found such that the angle between the KJC-KNE line and the KJC-THI line, projected onto a plane perpendicular to the HJC-KJC line, is the same as the thigh wand offset angle. The thigh wand offset angle is only calculated if a KAD is used.

There is only one position for the KJC that satisfies these two conditions.

Note that for static trials without a KAD, the anterior-posterior position of the KJC is determined by the position of the THI wand marker, and the value of wand offset value that is entered (if you do not enter a value, a value of zero is assumed). Correct determination of the KJC (and the AJC) is very important, especially for the kinetic calculations. In the clinic, you have to assess which method of marker positioning gives the best estimate of the KJC - using a KAD or using the THI marker.

**Types:**

Argument 1 | Argument 2 | Argument 3 | Argument 4 | Result |
---|---|---|---|---|

Real | 3d vector | 3d vector | 3d vector | 3d vector |

**Arguments:**

Argument | Description |
---|---|

h | distance in [mm] of the knee joint center to the lateral knee marker position; half joint width. |

I | Point to define a plane the point lays in, e.g. the lateral knee marker position. |

J | top joint position |

K | stick marker position |

#### Examples

chordv(70.5,I,J,K)

### chordv2()

**Types:**

Argument 1 | Argument 2 | Argument 3 | Argument 4 | Result | |
---|---|---|---|---|---|

Real | 3d vector | 3d vector | 3d vector | 3d vector | 3d vector |

**Arguments:**

Argument | Description |
---|---|

h | distance in [mm] of the knee joint center to the lateral knee marker position; half joint width. |

I | Point to define a plane the point lays in, e.g. the lateral knee marker position. |

J | top joint position |

K | stick marker position |

offset | offset angle |

## Matrix manipulation functions

### matq()

Create a matrix from a quaternion.

Argument | Type | Description |
---|---|---|

1 | Double | x |

2 | Double | y |

3 | Double | z |

4 | Double | w |

### mat()

### t()

### mat4()

### R()

Get a double component from a matrix defined by row and column index.

**Arguments:**

Argument | Type | Description | ||
---|---|---|---|---|

1 | MATRIX_3X3D | Matrix to get double components from. | ||

2 | INTEGER | row [0 | 1 | 2] |

3 | INTEGER | column [0 | 1 | 2] |

R(TCPQ,0,1,2)

## Robotics functions

### mdho()

Determines the Origin of a coordinate based on the modified Denavit-Hartenberg convention.

**Arguments:**

Argument | Type | Description |
---|---|---|

1 | VECTOR_3D | Origin the previous coordinate system |

2 | VECTOR_3D | Direction of the previous joint axis |

3 | REAL | Displacement on the previous joint axis of the origin. Typically this is 0. |

4 | VECTOR_3D | Point on the joint axis where the origin should be determined |

5 | VECTOR_3D | Direction ofthe joint axis where the origin should be determined |

#### Examples

mdhO(o1,v1,0.0,o2,v2)

### dhm()

Determines the 4×4 Matrix of the Denavit Hartenberg convention based the DH parameters.

**Arguments:**

Argument | Type | Description |
---|---|---|

1 | REAL | theta |

2 | REAL | alpha |

3 | REAL | d |

4 | REAL | r |

#### Examples

dhm(theta1, alpha1, d1, r1)