4x4 Matrices

Double precision

union ksl_mat4x4_t
#include <matrix.h>

A general double precision 4x4 matrix.

This union allows accessing double precision mat4x4 quantities by field name, as a singly dimensioned array, as a doubly dimensioned array, or by accessing a specific column. If using the at or as_array operators, quantities are accessed in column major order.

The following examples illustrate how to access row 3, column 2 (using 0 based indexing) of matrix M. The following access methods are equivalent.

M.as_array[3 + 2 * 4];
M.at[2][3];
M.m32;
M.v2.w;
M.v2.at[3];
M.v[2].w;
M.v[2].at[3];

See also the ksl_mat4x4_get and ksl_mat4x4_set functions.

Public Members

double as_array[16]
struct ksl_mat4x4_t::[anonymous] [anonymous]

anonymous union allows accessing quantities at specified index in linear array, where entities are specified in column major order

double at[4][4]
struct ksl_mat4x4_t::[anonymous] [anonymous]

anonymous union allows accessing mat3x3 quantities at specified index in a doubly dimensioned array, where entities are specified in column major order

double m00
double m10
double m20
double m30
double m01
double m11
double m21
double m31
double m02
double m12
double m22
double m32
double m03
double m13
double m23
double m33
struct ksl_mat4x4_t::[anonymous] [anonymous]

anonymous union allows accessing rotation matrix quantities by field name

ksl_vec4_t v0
ksl_vec4_t v1
ksl_vec4_t v2
ksl_vec4_t v3
struct ksl_mat4x4_t::[anonymous] [anonymous]

anonymous union allows accessing columns of rotation matrix quantities by field name

ksl_vec4_t v[4]
struct ksl_mat4x4_t::[anonymous] [anonymous]

anonymous union allows accessing columns of rotation matrix quantities at specified index

ksl_mat4x4_t ksl_mat4x4(const double m00, const double m01, const double m02, const double m03, const double m10, const double m11, const double m12, const double m13, const double m20, const double m21, const double m22, const double m23, const double m30, const double m31, const double m32, const double m33)

ksl_mat4x4_t constructor.

Note that in the constructor, fields are specified in row major order. Internally, ksl_mat4x4_t datastructures are stored in column major order.

ksl_mat4x4_t ksl_mat4x4_cmo(const double m00, const double m10, const double m20, const double m30, const double m01, const double m11, const double m21, const double m31, const double m02, const double m12, const double m22, const double m32, const double m03, const double m13, const double m23, const double m33)

alternative ksl_mat4x4_t constructor.

In this alternate constructor, fields are specified in column major order to match the internal layout of ksl_mat4x4_t datastructures.

ksl_mat4x4_t ksl_mat4x4_fromSE3(const ksl_SE3_t D)

alternative ksl_mat4x4_t constructor that allows creating a ksl_mat4x4_t datastructure from a ksl_SE3_t datastructure.

ksl_mat4x4_t ksl_mat4x4_fromRt(const ksl_mat3x3_t R, const ksl_vec3_t t)

alternative ksl_mat4x4_t constructor that allows creating a ksl_mat4x4_t datastructure from ksl_mat3x3_t and ksl_vec3_t datastructures.

ksl_mat4x4_t *ksl_mat4x4_alloc(int n)

allocates n ksl_mat4x4_t datastructures on the heap. Must be freed by the user.

void ksl_mat4x4_set(ksl_mat4x4_t *M, const int row, const int column, const double value)

Set a value in a double precision 4x4 matrix at specified row and column index.

Bounds checking are performed in debug mode. Bounds checking can be disabled by compiling in release mode using the compiler flag -DNDEBUG.

Parameters
  • M: [in/out]
  • row: [in] row index, \(0 \le row \lt 4\)
  • column: [in] column index, \(0 \le column \lt 4\)
  • value: [in] value to set

void ksl_mat4x4_setIdentity(ksl_mat4x4_t *M)

Set a double precision 4x4 matrix to identity.

\( I \rightarrow M \)

Parameters
  • M: [in/out] input 4x4 matrix

void ksl_mat4x4_getTranslation(const ksl_mat4x4_t *Mi, ksl_vec3_t *to)

Obtain the 3D translation component of a double precision 4x4 matrix.

Parameters
  • Mi: [in] input 4x4 matrix
  • to: [out] translation vector returned in to

double ksl_mat4x4_get(const ksl_mat4x4_t *Mi, const int row, const int column)

Basic get function for a double precision 4x4 matrix.

Bounds checking are performed in debug mode. Bounds checking can be disabled by compiling in release mode using the compiler flag -DNDEBUG.

Return
value at specified row and column index
Parameters
  • Mi: [in] input 4x4 matrix
  • row: [in] row index
  • column: [in] column index

Single precision

union ksl_mat4x4f_t
#include <matrix.h>

A general single precision 4x4 matrix.

This union allows accessing single precision mat4x4 quantities by field name, as a singly dimensioned array, as a doubly dimensioned array, or by accessing a specific column. If using the at or as_array operators, quantities are accessed in column major order.

The following examples illustrate how to access row 3, column 2 (using 0 based indexing) of matrix M. The following access methods are equivalent.

M.as_array[3 + 2 * 4];
M.at[2][3];
M.m32;
M.v2.w;
M.v2.at[3];
M.v[2].w;
M.v[2].at[3];

See also the ksl_mat4x4f_get and ksl_mat4x4f_set functions.

Public Members

float as_array[16]
struct ksl_mat4x4f_t::[anonymous] [anonymous]

allows accessing quantities at specified index in linear array, where entities are specified in column major order

float at[4][4]
struct ksl_mat4x4f_t::[anonymous] [anonymous]

allows accessing mat3x3 quantities at specified index in a doubly dimensioned array, where entities are specified in column major order

float m00
float m10
float m20
float m30
float m01
float m11
float m21
float m31
float m02
float m12
float m22
float m32
float m03
float m13
float m23
float m33
struct ksl_mat4x4f_t::[anonymous] [anonymous]

anonymous union allows accessing rotation matrix quantities by field name

ksl_vec4f_t v0
ksl_vec4f_t v1
ksl_vec4f_t v2
ksl_vec4f_t v3
struct ksl_mat4x4f_t::[anonymous] [anonymous]

anonymous union allows accessing columns of rotation matrix quantities by field name

ksl_vec4f_t v[4]
struct ksl_mat4x4f_t::[anonymous] [anonymous]

anonymous union allows accessing columns of rotation matrix quantities at specified index

ksl_mat4x4f_t ksl_mat4x4f(const float m00, const float m01, const float m02, const float m03, const float m10, const float m11, const float m12, const float m13, const float m20, const float m21, const float m22, const float m23, const float m30, const float m31, const float m32, const float m33)

ksl_mat4x4f_t constructor.

Note that in the constructor, fields are specified in row major order. Internally, ksl_mat4x4f_t datastructures are stored in column major order.

ksl_mat4x4f_t ksl_mat4x4f_cmo(const float m00, const float m10, const float m20, const float m30, const float m01, const float m11, const float m21, const float m31, const float m02, const float m12, const float m22, const float m32, const float m03, const float m13, const float m23, const float m33)

alternative ksl_mat4x4f_t constructor.

In this alternate constructor, fields are specified in column major order to match the internal layout of ksl_mat4x4f_t datastructures.

ksl_mat4x4f_t ksl_mat4x4f_fromSE3f(const ksl_SE3f_t D)

alternative ksl_mat4x4f_t constructor that allows creating a ksl_mat4x4f_t datastructure from a ksl_SE3f_t datastructure.

ksl_mat4x4f_t ksl_mat4x4f_fromRt(const ksl_mat3x3f_t R, const ksl_vec3f_t t)

alternative ksl_mat4x4f_t constructor that allows creating a ksl_mat4x4f_t datastructure from ksl_mat3x3f_t and ksl_vec3f_t datastructures.

ksl_mat4x4f_t *ksl_mat4x4f_alloc(int n)

allocates n ksl_mat4x4f_t datastructures on the heap. Must be freed by the user.

void ksl_mat4x4f_set(ksl_mat4x4f_t *D, int row, int column, float value)

Set a value in a single precision 4x4 matrix at specified row and column index.

Bounds checking are performed in debug mode. Bounds checking can be disabled by compiling in release mode using the compiler flag -DNDEBUG.

Parameters
  • M: [in/out]
  • row: [in] row index, \(0 \le row \lt 4\)
  • column: [in] column index, \(0 \le column \lt 4\)
  • value: [in] value to set

void ksl_mat4x4f_setIdentity(ksl_mat4x4f_t *M)

Set a single precision 4x4 matrix to identity.

\( I \rightarrow M \)

Parameters
  • M: [in/out] input 4x4 matrix

void ksl_mat4x4f_getTranslation(const ksl_mat4x4f_t *Mi, ksl_vec3f_t *to)

Obtain the 3D translation component of a single precision 4x4 matrix.

Parameters
  • Mi: [in] input 4x4 matrix
  • to: [out] translation vector returned in to

float ksl_mat4x4f_get(const ksl_mat4x4f_t *Mi, const int row, const int column)

Basic get function for a single precision 4x4 matrix.

Bounds checking are performed in debug mode. Bounds checking can be disabled by compiling in release mode using the compiler flag -DNDEBUG.

Return
value at specified row and column index
Parameters
  • Mi: [in] input 4x4 matrix
  • row: [in] row index
  • column: [in] column index