diff --git a/src/rmagine_core/include/rmagine/math/types/Quaternion.hpp b/src/rmagine_core/include/rmagine/math/types/Quaternion.hpp index f6b3a88..155de83 100644 --- a/src/rmagine_core/include/rmagine/math/types/Quaternion.hpp +++ b/src/rmagine_core/include/rmagine/math/types/Quaternion.hpp @@ -43,6 +43,7 @@ #include "definitions.h" #include #include +#include "Gaussian3D.hpp" #include "CrossStatistics.hpp" namespace rmagine @@ -125,6 +126,12 @@ struct Quaternion_ RMAGINE_INLINE_FUNCTION Vector3_ mult(const Vector3_& p) const; + /** + * @brief Rotate gaussian with this quaternion + */ + RMAGINE_INLINE_FUNCTION + Gaussian3D_ mult(const Gaussian3D_& g) const; + /** * @brief Rotate cross statistics with this quaternion */ diff --git a/src/rmagine_core/include/rmagine/math/types/Quaternion.tcc b/src/rmagine_core/include/rmagine/math/types/Quaternion.tcc index 0ce8493..4d4a74a 100644 --- a/src/rmagine_core/include/rmagine/math/types/Quaternion.tcc +++ b/src/rmagine_core/include/rmagine/math/types/Quaternion.tcc @@ -74,6 +74,18 @@ Vector3_ Quaternion_::mult(const Vector3_& p) const return {PT.x, PT.y, PT.z}; } +template +RMAGINE_INLINE_FUNCTION +Gaussian3D_ Quaternion_::mult(const Gaussian3D_& g) const +{ + Gaussian3D_ res; + res.mean = mult(g.mean); + const Matrix_ M = *this; + res.sigma = M * g.sigma * M.T(); + res.n_meas = g.n_meas; + return res; +} + template RMAGINE_INLINE_FUNCTION CrossStatistics_ Quaternion_::mult(const CrossStatistics_& stats) const diff --git a/src/rmagine_core/include/rmagine/math/types/Transform.hpp b/src/rmagine_core/include/rmagine/math/types/Transform.hpp index 090689e..e2621e5 100644 --- a/src/rmagine_core/include/rmagine/math/types/Transform.hpp +++ b/src/rmagine_core/include/rmagine/math/types/Transform.hpp @@ -45,6 +45,7 @@ #include "Vector3.hpp" #include "Quaternion.hpp" #include "CrossStatistics.hpp" +#include "Gaussian3D.hpp" namespace rmagine { @@ -109,6 +110,9 @@ struct Transform_ RMAGINE_INLINE_FUNCTION Vector3_ mult(const Vector3_& v) const; + RMAGINE_INLINE_FUNCTION + Gaussian3D_ mult(const Gaussian3D_& g) const; + RMAGINE_INLINE_FUNCTION CrossStatistics_ mult(const CrossStatistics_& stats) const; diff --git a/src/rmagine_core/include/rmagine/math/types/Transform.tcc b/src/rmagine_core/include/rmagine/math/types/Transform.tcc index bb05733..d3c578c 100644 --- a/src/rmagine_core/include/rmagine/math/types/Transform.tcc +++ b/src/rmagine_core/include/rmagine/math/types/Transform.tcc @@ -61,6 +61,18 @@ Vector3_ Transform_::mult(const Vector3_& v) const return R * v + t; } +template +RMAGINE_INLINE_FUNCTION +Gaussian3D_ Transform_::mult(const Gaussian3D_& g) const +{ + Gaussian3D_ res; + res.mean = mult(g.mean); + const Matrix_ M = R; // TODO: can we do the two steps more efficient? + res.sigma = M * g.sigma * M.T(); + res.n_meas = g.n_meas; + return res; +} + template RMAGINE_INLINE_FUNCTION CrossStatistics_ Transform_::mult(const CrossStatistics_& stats) const