| #ifndef TYPES_H |
| #define TYPES_H |
|
|
| #include <eigen/Eigen/Dense> |
|
|
| #ifdef USE_FLOAT_SCALAR |
| typedef float Scalar |
| #else |
| typedef double Scalar; |
| #endif |
|
|
| #ifdef EIGEN_DONT_ALIGN |
| #define EIGEN_ALIGNMENT Eigen::DontAlign |
| #else |
| #define EIGEN_ALIGNMENT Eigen::AutoAlign |
| #endif |
|
|
|
|
| template < int Rows, int Cols, int Options = (Eigen::ColMajor | EIGEN_ALIGNMENT) > |
| using MatrixT = Eigen::Matrix<Scalar, Rows, Cols, Options>; |
| typedef MatrixT<2, 1> Vector2; |
| typedef MatrixT<2, 2> Matrix22; |
| typedef MatrixT<2, 3> Matrix23; |
| typedef MatrixT<3, 1> Vector3; |
| typedef MatrixT<3, 2> Matrix32; |
| typedef MatrixT<3, 3> Matrix33; |
| typedef MatrixT<3, 4> Matrix34; |
| typedef MatrixT<4, 1> Vector4; |
| typedef MatrixT<4, 4> Matrix44; |
| typedef MatrixT<4, Eigen::Dynamic> Matrix4X; |
| typedef MatrixT<3, Eigen::Dynamic> Matrix3X; |
| typedef MatrixT<Eigen::Dynamic, 3> MatrixX3; |
| typedef MatrixT<2, Eigen::Dynamic> Matrix2X; |
| typedef MatrixT<Eigen::Dynamic, 2> MatrixX2; |
| typedef MatrixT<Eigen::Dynamic, 1> VectorX; |
| typedef MatrixT<Eigen::Dynamic, Eigen::Dynamic> MatrixXX; |
| typedef Eigen::Matrix<Scalar, 12, 12, 0, 12, 12> EigenMatrix12; |
|
|
| |
| typedef Eigen::AngleAxis<Scalar> EigenAngleAxis; |
| typedef Eigen::Quaternion<Scalar, Eigen::DontAlign> EigenQuaternion; |
|
|
| |
| template<typename Vec_T> |
| inline Vector3 to_eigen_vec3(const Vec_T &vec) |
| { |
| return Vector3(vec[0], vec[1], vec[2]); |
| } |
|
|
|
|
| template<typename Vec_T> |
| inline Vec_T from_eigen_vec3(const Vector3 &vec) |
| { |
| Vec_T v; |
| v[0] = vec(0); |
| v[1] = vec(1); |
| v[2] = vec(2); |
|
|
| return v; |
| } |
|
|
|
|
| class Matrix3333 // 3x3 matrix: each element is a 3x3 matrix |
| { |
| public: |
| Matrix3333(); |
| Matrix3333(const Matrix3333& other); |
| ~Matrix3333() {} |
|
|
| void SetZero(); |
| void SetIdentity(); |
|
|
| |
| Matrix33& operator() (int row, int col); |
| Matrix3333 operator+ (const Matrix3333& plus); |
| Matrix3333 operator- (const Matrix3333& minus); |
| Matrix3333 operator* (const Matrix33& multi); |
| friend Matrix3333 operator* (const Matrix33& multi1, Matrix3333& multi2); |
| Matrix3333 operator* (Scalar multi); |
| friend Matrix3333 operator* (Scalar multi1, Matrix3333& multi2); |
| Matrix3333 transpose(); |
| Matrix33 Contract(const Matrix33& multi); |
| Matrix3333 Contract(Matrix3333& multi); |
|
|
| |
|
|
| Matrix33 mat[3][3]; |
| }; |
|
|
| class Matrix2222 // 2x2 matrix: each element is a 2x2 matrix |
| { |
| public: |
| Matrix2222(); |
| Matrix2222(const Matrix2222& other); |
| ~Matrix2222() {} |
|
|
| void SetZero(); |
| void SetIdentity(); |
|
|
| |
| Matrix22& operator() (int row, int col); |
| Matrix2222 operator+ (const Matrix2222& plus); |
| Matrix2222 operator- (const Matrix2222& minus); |
| Matrix2222 operator* (const Matrix22& multi); |
| friend Matrix2222 operator* (const Matrix22& multi1, Matrix2222& multi2); |
| Matrix2222 operator* (Scalar multi); |
| friend Matrix2222 operator* (Scalar multi1, Matrix2222& multi2); |
| Matrix2222 transpose(); |
| Matrix22 Contract(const Matrix22& multi); |
| Matrix2222 Contract(Matrix2222& multi); |
|
|
| protected: |
|
|
| Matrix22 mat[2][2]; |
| }; |
|
|
| |
| void directProduct(Matrix3333& dst, const Matrix33& src1, const Matrix33& src2); |
| void directProduct(Matrix2222& dst, const Matrix22& src1, const Matrix22& src2); |
| #endif |
| |
|
|