Home > Resources > MBDyn Tutorial > 13. Various ways to define general and orientation matrices
MBDyn Tutorial

## 13. Various ways to define general and orientation matrices

There are many places in an MBDyn input file where we have to define general or orientation matrices, such as inertial matrices of bodies and orientation matrices of structural nodes. MBDyn provides us a number of ways to define general or orientation matrices, which are introduced here.

### 3 x 3 matrices

#### (1) General case

```   matr, <a11>, <a12>, <a13>, <a21>, <a22>, <a23>, <a31>, <a32>, <a33>
```

#### (2) Symmetric matrix

```   sym, <a11>, <a12>, <a13>, <a22>, <a23>, <a33>
```

#### (3) Skew-symmetric matrix

```   skew, <v1>, <v2>, <v3>
```

#### (4) Diagonal matrix

```   diag, <a11>, <a22>, <a33>
```

#### (5) Identity matrix

```   eye
```

#### (6) Null matrix

```   null
```

### 3 x 3 orientation matrices

#### (1) General case: Two vectors that define an orthonormal reference system

The direction of <index1> is (p1, p2, p3) and the direction of <index2> is (q1, q2, q3)

```   <index1>, <p1>, <p2>, <p3>, <index2>, <q1>, <q2>, <q3>
```

where <index1> and <index2> are integers 1,2, or 3 corresponding to x, y, or z, respectively. For example, if we want to define an orientation with a reference system whose x-axis points to (0., 1., 0.) and z-axis points to (0., 0., 1.), we write as follows.

```  1, 0., 1., 0., 3, 0., 0., 1.
```

If the two vectors are not exactly perpendicular, the first vector points to the desired direction and the second vector defines a plane that is perpendicular to the third vector.

In a special case when only one direction (rather than a full orientation) really matters, we can write, for example, as

```   1, <p1>, <p2>, <p3>, 2, guess
```

where guess is the keyword that generates a vector perpendicular to the first vector in some deterministic procedure.

#### (2) Identity matrix

```   eye
```

This means "no rotation".

#### (3) Complete orientation matrix

```   matr, <a11>, <a12>, <a13>, <a21>, <a22>, <a23>, <a31>, <a32>, <a33>
```

Note that no orthogonality check is performed.

#### (4) Euler angles (xyz)

```   euler, <alpha>, <beta>, <gamma>
```

See Chapter 7.

#### (5) Orientation vector

```   vector, <v1>, <v2>, <v3>
```

The direction of the vector defines the axis of rotation and the length of the vector defines the angle of rotation.

### Examples of 3 x 3 orientation matrices

All of the following define the orientation matrix representing a rotation of 90 degrees about the global Z-axis.

```   1, 0., 1., 0., 3, 0., 0., 1.

1, 0., 1., 0., 2, -1., 0., 0.

matr, cos(pi/2.), -sin(pi/2.), 0., sin(pi/2.), cos(pi/2.), 0., 0., 0., 1.

euler, 0., 0., pi/2.

vector, 0., 0., pi/2.
```