interpolate_details.hpp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. #ifndef SOPHUS_INTERPOLATE_DETAILS_HPP
  2. #define SOPHUS_INTERPOLATE_DETAILS_HPP
  3. #include "rxso2.hpp"
  4. #include "rxso3.hpp"
  5. #include "se2.hpp"
  6. #include "se3.hpp"
  7. #include "sim2.hpp"
  8. #include "sim3.hpp"
  9. #include "so2.hpp"
  10. #include "so3.hpp"
  11. namespace Sophus {
  12. namespace interp_details {
  13. template <class Group>
  14. struct Traits;
  15. template <class Scalar>
  16. struct Traits<SO2<Scalar>> {
  17. static bool constexpr supported = true;
  18. static bool hasShortestPathAmbiguity(SO2<Scalar> const& foo_T_bar) {
  19. using std::abs;
  20. Scalar angle = foo_T_bar.log();
  21. return abs(abs(angle) - Constants<Scalar>::pi()) <
  22. Constants<Scalar>::epsilon();
  23. }
  24. };
  25. template <class Scalar>
  26. struct Traits<RxSO2<Scalar>> {
  27. static bool constexpr supported = true;
  28. static bool hasShortestPathAmbiguity(RxSO2<Scalar> const& foo_T_bar) {
  29. return Traits<SO2<Scalar>>::hasShortestPathAmbiguity(foo_T_bar.so2());
  30. }
  31. };
  32. template <class Scalar>
  33. struct Traits<SO3<Scalar>> {
  34. static bool constexpr supported = true;
  35. static bool hasShortestPathAmbiguity(SO3<Scalar> const& foo_T_bar) {
  36. using std::abs;
  37. Scalar angle = foo_T_bar.logAndTheta().theta;
  38. return abs(abs(angle) - Constants<Scalar>::pi()) <
  39. Constants<Scalar>::epsilon();
  40. }
  41. };
  42. template <class Scalar>
  43. struct Traits<RxSO3<Scalar>> {
  44. static bool constexpr supported = true;
  45. static bool hasShortestPathAmbiguity(RxSO3<Scalar> const& foo_T_bar) {
  46. return Traits<SO3<Scalar>>::hasShortestPathAmbiguity(foo_T_bar.so3());
  47. }
  48. };
  49. template <class Scalar>
  50. struct Traits<SE2<Scalar>> {
  51. static bool constexpr supported = true;
  52. static bool hasShortestPathAmbiguity(SE2<Scalar> const& foo_T_bar) {
  53. return Traits<SO2<Scalar>>::hasShortestPathAmbiguity(foo_T_bar.so2());
  54. }
  55. };
  56. template <class Scalar>
  57. struct Traits<SE3<Scalar>> {
  58. static bool constexpr supported = true;
  59. static bool hasShortestPathAmbiguity(SE3<Scalar> const& foo_T_bar) {
  60. return Traits<SO3<Scalar>>::hasShortestPathAmbiguity(foo_T_bar.so3());
  61. }
  62. };
  63. template <class Scalar>
  64. struct Traits<Sim2<Scalar>> {
  65. static bool constexpr supported = true;
  66. static bool hasShortestPathAmbiguity(Sim2<Scalar> const& foo_T_bar) {
  67. return Traits<SO2<Scalar>>::hasShortestPathAmbiguity(
  68. foo_T_bar.rxso2().so2());
  69. ;
  70. }
  71. };
  72. template <class Scalar>
  73. struct Traits<Sim3<Scalar>> {
  74. static bool constexpr supported = true;
  75. static bool hasShortestPathAmbiguity(Sim3<Scalar> const& foo_T_bar) {
  76. return Traits<SO3<Scalar>>::hasShortestPathAmbiguity(
  77. foo_T_bar.rxso3().so3());
  78. ;
  79. }
  80. };
  81. } // namespace interp_details
  82. } // namespace Sophus
  83. #endif // SOPHUS_INTERPOLATE_DETAILS_HPP