LCOV - code coverage report
Current view: top level - elsa/generators - PhantomDefines.cpp (source / functions) Hit Total Coverage
Test: coverage-all.lcov Lines: 26 32 81.2 %
Date: 2024-05-16 04:22:26 Functions: 3 3 100.0 %

          Line data    Source code
       1             : #include "PhantomDefines.h"
       2             : 
       3             : namespace elsa::phantoms
       4             : {
       5             : 
       6             :     template <typename data_t>
       7             :     void fillRotationMatrix(Vec3X<data_t> eulers, Eigen::Matrix<data_t, 3, 3>& rot)
       8         212 :     {
       9             :         // convert to radians
      10         212 :         auto phiRad = eulers[INDEX_PHI] * pi<double> / 180.0;
      11         212 :         auto thetaRad = eulers[INDEX_THETA] * pi<double> / 180.0;
      12         212 :         auto psiRad = eulers[INDEX_PSI] * pi<double> / 180.0;
      13             : 
      14         212 :         auto cosPhi = std::cos(phiRad);
      15         212 :         auto sinPhi = std::sin(phiRad);
      16         212 :         auto cosTheta = std::cos(thetaRad);
      17         212 :         auto sinTheta = std::sin(thetaRad);
      18         212 :         auto cosPsi = std::cos(psiRad);
      19         212 :         auto sinPsi = std::sin(psiRad);
      20             : 
      21             :         // setup ZXZ Euler rotation matrix
      22             :         // first column
      23         212 :         rot(0, 0) = cosPhi * cosPsi - cosTheta * sinPhi * sinPsi;
      24         212 :         rot(1, 0) = cosPsi * sinPhi + cosPhi * cosTheta * sinPsi;
      25         212 :         rot(2, 0) = sinTheta * sinPsi;
      26             : 
      27             :         // second column
      28         212 :         rot(0, 1) = -cosPhi * sinPsi - cosTheta * cosPsi * sinPhi;
      29         212 :         rot(1, 1) = cosPhi * cosTheta * cosPsi - sinPhi * sinPsi;
      30         212 :         rot(2, 1) = cosPsi * sinTheta;
      31             : 
      32             :         // third column
      33         212 :         rot(0, 2) = sinPhi * sinTheta;
      34         212 :         rot(1, 2) = -cosPhi * sinTheta;
      35         212 :         rot(2, 2) = cosTheta;
      36         212 :     }
      37             : 
      38             :     std::string getString(Orientation o)
      39          47 :     {
      40          47 :         switch (o) {
      41           0 :             case Orientation::X_AXIS:
      42           0 :                 return "X_AXIS";
      43           0 :             case Orientation::Y_AXIS:
      44           0 :                 return "Y_AXIS";
      45          47 :             case Orientation::Z_AXIS:
      46          47 :                 return "Z_AXIS";
      47           0 :             default:
      48           0 :                 return "xxxx";
      49          47 :         }
      50          47 :     }
      51             : 
      52             :     // explicit template instantiation
      53             :     template void fillRotationMatrix<double>(Vec3X<double>, Eigen::Matrix<double, 3, 3>&);
      54             :     template void fillRotationMatrix<float>(Vec3X<float>, Eigen::Matrix<float, 3, 3>&);
      55             : 
      56             :     // explicit template instantiation
      57             :     template void blend<Blending::ADDITION, double>(DataContainer<double>& dc, index_t index,
      58             :                                                     double amplit);
      59             :     template void blend<Blending::ADDITION, float>(DataContainer<float>& dc, index_t index,
      60             :                                                    float amplit);
      61             :     template void blend<Blending::OVERWRITE, double>(DataContainer<double>& dc, index_t index,
      62             :                                                      double amplit);
      63             :     template void blend<Blending::OVERWRITE, float>(DataContainer<float>& dc, index_t index,
      64             :                                                     float amplit);
      65             : 
      66             : } // namespace elsa::phantoms

Generated by: LCOV version 1.14