7 #include "fwDataTools/TransformationMatrix3D.hpp" 9 #include <glm/gtc/type_ptr.hpp> 10 #include <glm/matrix.hpp> 18 ::fwData::TransformationMatrix3D::sptr& _output)
22 const ::glm::dmat4x4 mat = ::glm::make_mat4<double>(_input->getCoefficients().data());
23 const ::glm::dmat4x4 matInverse = ::glm::inverse(mat);
25 auto& coefs = _output->getCoefficients();
26 for (
size_t i = 0; i < 4; ++i)
28 const size_t rowDst = i * 4;
29 const ::glm::length_t rowSrc =
static_cast< ::glm::length_t
>(i);
30 for (
size_t j = 0; j < 4; ++j)
32 const ::glm::length_t colSrc =
static_cast< ::glm::length_t
>(j);
33 coefs[rowDst+j] = matInverse[rowSrc][colSrc];
43 const ::fwData::TransformationMatrix3D::csptr& _trfB,
44 ::fwData::TransformationMatrix3D::sptr& _output)
49 const ::glm::dmat4x4 matA = ::glm::make_mat4<double>(_trfA->getCoefficients().data());
50 const ::glm::dmat4x4 matB = ::glm::make_mat4<double>(_trfB->getCoefficients().data());
52 const ::glm::dmat4x4 matC = matB * matA;
54 auto& coefs = _output->getCoefficients();
55 for (
size_t i = 0; i < 4; ++i)
57 const size_t rowDst = i * 4;
58 const ::glm::length_t rowSrc =
static_cast< ::glm::length_t
>(i);
59 for (
size_t j = 0; j < 4; ++j)
61 const ::glm::length_t colSrc =
static_cast< ::glm::length_t
>(j);
62 coefs[rowDst + j] = matC[rowSrc][colSrc];
71 for (
size_t i = 0; i < 4; ++i)
73 for (
size_t j = 0; j < 4; ++j)
75 _trf->setCoefficient(i, j, i == j ? 1 : 0);
83 const ::fwData::Point::csptr& _input, ::fwData::Point::sptr& _output)
88 const ::glm::dmat4x4 mat = ::glm::make_mat4<double>(_trf->getCoefficients().data());
90 const auto& inCoord = _input->getCoord();
97 ::glm::dvec4 out = in * mat;
98 std::array<double, 3> res = {{ out[0], out[1], out[2] }};
99 _output->setCoord(res);
106 static const ::fwData::TransformationMatrix3D::sptr s_IDENTITY = ::fwData::TransformationMatrix3D::New();
108 const ::fwData::TransformationMatrix3D::TMCoefArray& arrayID = s_IDENTITY->getCoefficients();
109 const ::fwData::TransformationMatrix3D::TMCoefArray& arrayTrf = _trf->getCoefficients();
111 for(
size_t i = 0; i < arrayID.size(); ++i)
113 if(std::abs(arrayID[i] - arrayTrf[i]) > _epsilon)