Unlike other langages (such as Matlab, Python...) there is no native functions for matrix and vector operations in C.

With the particularity of our indexing convention the matrix and vector manipulation is a little different from the usual code you may have. So we provide some functions that do the operations for you.

Most of the functions ends with "_1" or "_0". This suffix indicates whether the function is dedicated to vector and matrix using our convention or not (i.e. starting at 0 or 1).

Some functions have been set allowing you to get allocated matrix and vector. For matrices, the memory allocated is contiguous. See the following functions:

Replacing the "d" letter by "i" gives you matrix and vectors of integers.

All the memory that you asked must be freed by the corresponding functions:

To compute the norm (ie. the length) of a vector uses one of the following functions:

- norm_dvec_1() : dedicated to vector with our convention of starting index 1.
- norm_dvec_0() : dedicated to vector with starting index 0.

To get the unit vector aligned with a vector uses:

To multiply a vector by a scalar, uses:

- number_product() : dedicated to vector of 3 components with starting index 1.

For the scalar product between two vectors uses:

- scalar_product(): dedicated to vector of 3 components with starting index 1.
- scalar_product_0(): dedicated to vector of any length but requires vector not using our conventions.

For the dot product between matrix and vector uses:

- matrix_product(): dedicated to matrix of 3 by 3 components multiplied by a vector of 3 components both with starting index 1.
- matrix_product_0(): dedicated to matrix and vector of any length but requires not using our conventions

For the dot product between matrices uses:

- mult_dmat_0(): dedicated to matrices of any size not using our conventions.

For the cross product between two vectors use:

- cross_product(): dedicated to vector of 3 components with starting index 1.

To get the transpose of matrix uses:

- transpose(): dedicated to matrix of 3 by 3 components with starting index 1.
- transpose_dmat_0(): dedicated to matrix of any size not using our conventions.

Others utility functions have been created over time (and still will be created). Explore the following headers:

If some is missing feel free to contribute.

In MBsysC the convention has been taken to start filling arrays (vectors and matrices) at the index number "1" (instead of "0"). This choice has been done to help the user accessing to its joints (and also historical reason).

Indeed the joint numbering in the graphical editor of the model (MBsysPAD) start a "1", in his code the user can get the coordinate of the joint by reading MbsData::q with the same index:

double q1_coord = mbs_data->q[1]

This convention have been extended to the whole (or almost) source code.

Generated on Thu Sep 16 2021 13:42:20 for Robotran C Documentation by 1.8.17