Tekkotsu uses vectors to represent the coordinates of things, such as
shapes in the DualCoding vision system, or points on the robot's body
in the kinematics engine. Matrices are used to represent
transformations between coordinate systems, such as between camera
space and local space (DualCoding), or between the tip of a limb and
the body's base coordinate frame (kinematics). Both vectors and
matrices are represented using the fmat package, written by Ethan
Tira-Thompson. Tekkotsu also incorporates the NEWMAT package, which
is designed for representing large or dynamically-sized arrays, while
ffmat is optimized for small, fixed-size arrays that are common in
coordinate calculations.
The fmat package can be found in Shared/fmat.h, and uses the fmat
namespace. To access its documentation, go to the main Tekkotsu
reference page and, under Library Sub-Documentation, click on
"fmat".
Column and Row Vectors
The column vector class, fmat::Column, is a templated class with the
first template parameter indicating the length of the column. Points
are represented as 4-element column vectors. Points are declared and
initialized this way:
For completeness, row vectors are also provided. Column and row
vectors are mutual transposes. Internally, their layout in memory is
the same.
fmat::Row<4> r = p1.fmat::transpose();
Matrices, Subvectors, and Submatrices
Matrices are laid out in memory in column-major order, i.e.,
all the elements of the first column are followed
[x,
y, z, 1]T. The purpose of the fourth
component will be explained later. The "T" superscript denotes a
transpose operation, in this case turning a row vector
[x, y ,z, 1] into a column
vector.