diff --git a/ParameterLib/CoordinateSystem.cpp b/ParameterLib/CoordinateSystem.cpp index 3e16da75c729015c3a3d68dff953c25948180588..9258f98ce360575ad0232c13226ef0ca13e5461f 100644 --- a/ParameterLib/CoordinateSystem.cpp +++ b/ParameterLib/CoordinateSystem.cpp @@ -116,4 +116,39 @@ Eigen::Matrix<double, 3, 3> CoordinateSystem::transformation<3>( #endif // NDEBUG return t; } + +template <int Dimension> +Eigen::Matrix<double, Dimension, Dimension> CoordinateSystem::rotateTensor( + std::vector<double> const& values, SpatialPosition const& pos) const +{ + assert(values.size() == Dimension * Dimension || + "Input vector has wrong dimension; expected 4 or 9 entries."); + auto const tensor = + Eigen::Map<Eigen::Matrix<double, Dimension, Dimension> const>( + values.data(), Dimension, Dimension); + auto const R = transformation<Dimension>(pos); + return R * tensor * R.transpose(); +} + +template <int Dimension> +Eigen::Matrix<double, Dimension, Dimension> +CoordinateSystem::rotateDiagonalTensor(std::vector<double> const& values, + SpatialPosition const& pos) const +{ + assert(values.size() == Dimension || + "Input vector has wrong dimension; expected 2 or 3 entries."); + auto const tensor = Eigen::Map<Eigen::Matrix<double, Dimension, 1> const>( + values.data(), Dimension, 1); + auto const R = transformation<Dimension>(pos); + return R * tensor.asDiagonal() * R.transpose(); +} + +template Eigen::Matrix<double, 2, 2> CoordinateSystem::rotateTensor<2>( + std::vector<double> const& values, SpatialPosition const& pos) const; +template Eigen::Matrix<double, 3, 3> CoordinateSystem::rotateTensor<3>( + std::vector<double> const& values, SpatialPosition const& pos) const; +template Eigen::Matrix<double, 2, 2> CoordinateSystem::rotateDiagonalTensor<2>( + std::vector<double> const& values, SpatialPosition const& pos) const; +template Eigen::Matrix<double, 3, 3> CoordinateSystem::rotateDiagonalTensor<3>( + std::vector<double> const& values, SpatialPosition const& pos) const; } // namespace ParameterLib diff --git a/ParameterLib/CoordinateSystem.h b/ParameterLib/CoordinateSystem.h index 91fe860b9bb43407c731ed7f4882186003636a87..0e18f44f71b1007dc6a5f89fb8455a6a3a5610b9 100644 --- a/ParameterLib/CoordinateSystem.h +++ b/ParameterLib/CoordinateSystem.h @@ -37,29 +37,11 @@ struct CoordinateSystem final template <int Dimension> Eigen::Matrix<double, Dimension, Dimension> rotateTensor( - std::vector<double> const& values, SpatialPosition const& pos) const - { - assert(values.size() == Dimension * Dimension || - "Input vector has wrong dimension; expected 4 or 9 entries."); - auto const tensor = - Eigen::Map<Eigen::Matrix<double, Dimension, Dimension> const>( - values.data(), Dimension, Dimension); - auto const R = transformation<Dimension>(pos); - return R * tensor * R.transpose(); - } + std::vector<double> const& values, SpatialPosition const& pos) const; template <int Dimension> Eigen::Matrix<double, Dimension, Dimension> rotateDiagonalTensor( - std::vector<double> const& values, SpatialPosition const& pos) const - { - assert(values.size() == Dimension || - "Input vector has wrong dimension; expected 2 or 3 entries."); - auto const tensor = - Eigen::Map<Eigen::Matrix<double, Dimension, 1> const>(values.data(), - Dimension, 1); - auto const R = transformation<Dimension>(pos); - return R * tensor.asDiagonal() * R.transpose(); - } + std::vector<double> const& values, SpatialPosition const& pos) const; private: std::array<Parameter<double> const*, 3> _base;