7 #include "fwMath/MatrixFunctions.hpp" 9 #include "fwMath/VectorFunctions.hpp" 11 #include <glm/gtc/matrix_transform.hpp> 12 #include <glm/mat4x4.hpp> 19 void multVecMatrix(
const fwMatrix4x4& matrix,
const fwVec3d& source, fwVec3d& dest)
24 ::glm::dmat4x4 mat(matrix[0][0], matrix[1][0], matrix[2][0], matrix[3][0],
25 matrix[0][1], matrix[1][1], matrix[2][1], matrix[3][1],
26 matrix[0][2], matrix[1][2], matrix[2][2], matrix[3][2],
27 matrix[0][3], matrix[1][3], matrix[2][3], matrix[3][3]);
29 ::glm::dvec4 vec(source[0], source[1], source[2], 1.0);
30 ::glm::dvec4 res = mat * vec;
44 ::glm::dmat4x4 mat(matrix[0][0], matrix[1][0], matrix[2][0], matrix[3][0],
45 matrix[0][1], matrix[1][1], matrix[2][1], matrix[3][1],
46 matrix[0][2], matrix[1][2], matrix[2][2], matrix[3][2],
47 matrix[0][3], matrix[1][3], matrix[2][3], matrix[3][3]);
49 ::glm::dmat4x4 matInv = ::glm::inverse(mat);
51 fwMatrix4x4 inverse = {matInv[0][0], matInv[1][0], matInv[2][0], matInv[3][0],
52 matInv[0][1], matInv[1][1], matInv[2][1], matInv[3][1],
53 matInv[0][2], matInv[1][2], matInv[2][2], matInv[3][2],
54 matInv[0][3], matInv[1][3], matInv[2][3], matInv[3][3]};
64 const double FV0 = _vecNorm[0];
65 const double FV1 = _vecNorm[1];
66 const double YP = sqrt( FV0 * FV0 + FV1 * FV1 );
67 const double RZ = -atan2(FV0, FV1);
68 const double RX = -atan2(YP, _vecNorm[2]);
84 R[1][0] = -cos(RX) * sin(RZ);
85 R[1][1] = cos(RX) * cos(RZ);
89 R[2][0] = sin(RX) * sin(RZ);
90 R[2][1] = -sin(RX) * cos(RZ);
107 fwMatrix4x4 operator*(
const fwMatrix4x4& matrix1,
const fwMatrix4x4& matrix2 )
109 ::glm::dmat4x4 mat1(matrix1[0][0], matrix1[1][0], matrix1[2][0], matrix1[3][0],
110 matrix1[0][1], matrix1[1][1], matrix1[2][1], matrix1[3][1],
111 matrix1[0][2], matrix1[1][2], matrix1[2][2], matrix1[3][2],
112 matrix1[0][3], matrix1[1][3], matrix1[2][3], matrix1[3][3]);
114 ::glm::dmat4x4 mat2(matrix2[0][0], matrix2[1][0], matrix2[2][0], matrix2[3][0],
115 matrix2[0][1], matrix2[1][1], matrix2[2][1], matrix2[3][1],
116 matrix2[0][2], matrix2[1][2], matrix2[2][2], matrix2[3][2],
117 matrix2[0][3], matrix2[1][3], matrix2[2][3], matrix2[3][3]);
119 ::glm::dmat4x4 prod = mat1 * mat2;
121 fwMatrix4x4 product = {prod[0][0], prod[1][0], prod[2][0], prod[3][0],
122 prod[0][1], prod[1][1], prod[2][1], prod[3][1],
123 prod[0][2], prod[1][2], prod[2][2], prod[3][2],
124 prod[0][3], prod[1][3], prod[2][3], prod[3][3]};
FWMATH_API fwMatrix4x4 getInverse(const fwMatrix4x4 &matrix)
Computes the inverse of a matrix.
The namespace fwMath contains classes which provide the implementation of several mathematic function...
FWMATH_API fwMatrix4x4 getRotationMatrix(const fwVec3d &_vecNorm)
Compute a matrix rotation.
FWMATH_API void multVecMatrix(const fwMatrix4x4 &_matrix, const fwVec3d &_source, fwVec3d &_dest)
Multiply a matrix by a vector.