Template Class Matrix4

Class Documentation

template<typename BaseVecT>
class Matrix4

A 4x4 matrix class implementation for use with the provided vertex types.

Public Types

using ValueType = typename BaseVecT::CoordType

Public Functions

inline Matrix4()

Default constructor. Initializes a identity matrix.

template<typename T>
inline Matrix4(T *matrix)

Initializes a matrix wit the given data array. Ensure that the array has exactly 16 fields.

template<typename T>
inline Matrix4(const Matrix4<T> &other)

Copy constructor.

template<typename T>
inline Matrix4(T axis, ValueType angle)

Constructs a matrix from given axis and angle. Trys to avoid a gimbal lock.

template<typename T>
inline Matrix4(const T &position, const T &angles)
Matrix4(string filename)
inline ~Matrix4()
inline Matrix4 &operator=(const Eigen::Matrix4d &mat)
inline Eigen::Matrix4d toEigenMatrix()
inline Matrix4<BaseVecT> operator*(const ValueType &scale) const

Scales the matrix elemnts by the given factor.

template<typename T>
inline Matrix4<BaseVecT> operator*(const Matrix4<T> &other) const

Matrix-Matrix multiplication. Returns the new matrix.

template<typename T>
inline Matrix4<BaseVecT> operator+(const Matrix4<T> &other) const

Matrix addition operator. Returns a new matrix.

template<typename T>
inline Matrix4<BaseVecT> operator+=(const Matrix4<T> &other)

Matrix addition operator.

template<typename T>
inline Matrix4<BaseVecT> operator*(const T *&other) const

Matrix-Matrix multiplication (array based). Mainly implemented for compatibility with other math libs. ensure that the used array has at least 16 elements to avoid memory access violations.

template<typename T>
inline T operator*(const T &v) const

Multiplication of Matrix and Vertex types.

template<typename T>
inline Normal<T> operator*(const Normal<T> &v) const

Multiplication of Matrix and Vertex types.

inline void set(int i, ValueType value)

Sets the given index of the Matrix’s data field to the provided value.

Parameters:
  • i – Field index of the matrix

  • value – new value

inline void transpose()

Transposes the current matrix.

inline void toPostionAngle(ValueType pose[6])

Computes an Euler representation (x, y, z) plus three rotation values in rad. Rotations are with respect to the x, y, z axes.

inline void loadFromFile(string filename)

Loads matrix values from a given file.

template<typename T>
inline void operator*=(const T scale)

Matrix scaling with self assignment.

template<typename T>
inline void operator*=(const Matrix4<T> &other)

Matrix-Matrix multiplication with self assigment.

template<typename T>
inline void operator*=(const T *other)

Matrix-Matrix multiplication (array based). See operator*}.

inline ValueType *getData()

Returns the internal data array. Unsafe. Will probably removed in one of the next versions.

inline floatArr toFloatArray()
inline std::vector<ValueType> getVector()
ValueType at(const int i) const

Returns the element at the given index.

inline ValueType operator[](const int index) const

Indexed element (reading) access.

inline ValueType &operator[](const int index)

Writeable index access.

inline ValueType det()

Returns the matrix’s determinant.

inline Matrix4<BaseVecT> inv(bool &success)

Public Members

ValueType m[16]