smooth
A C++ library for Lie theory
Loading...
Searching...
No Matches
se_k_3.hpp
1// Copyright (C) 2021-2022 Petter Nilsson. MIT License.
2
3#pragma once
4
5#include <Eigen/Core>
6#include <Eigen/Geometry>
7
8#include "detail/macro.hpp"
9#include "detail/se_k_3.hpp"
10#include "detail/utils.hpp"
11#include "lie_group_base.hpp"
12#include "so3.hpp"
13
14SMOOTH_BEGIN_NAMESPACE
15
64template<typename _Derived>
65class SE_K_3Base : public LieGroupBase<_Derived>
66{
68 using Impl = typename liebase_info<_Derived>::Impl;
69
70protected:
71 SE_K_3Base() = default;
72
73public:
74 SMOOTH_INHERIT_TYPEDEFS;
75
79 static constexpr auto K = Impl::K;
80
85 requires is_mutable
86 {
87 return Map<SO3<Scalar>>(static_cast<_Derived &>(*this).data() + 3 * K);
88 }
89
94 {
95 return Map<const SO3<Scalar>>(static_cast<const _Derived &>(*this).data() + 3 * K);
96 }
97
103 template<int Ksel>
104 Eigen::Map<Eigen::Vector3<Scalar>> r3()
105 requires(is_mutable && Ksel < K)
106 {
107 return Eigen::Map<Eigen::Vector3<Scalar>>(static_cast<_Derived &>(*this).data() + 3 * Ksel);
108 }
109
115 Eigen::Map<Eigen::Vector3<Scalar>> r3(int k)
116 requires is_mutable
117 {
118 assert(k < K);
119 return Eigen::Map<Eigen::Vector3<Scalar>>(static_cast<_Derived &>(*this).data() + 3 * k);
120 }
121
127 template<int Ksel>
128 Eigen::Map<const Eigen::Vector3<Scalar>> r3() const
129 requires(Ksel < K)
130 {
131 return Eigen::Map<const Eigen::Vector3<Scalar>>(static_cast<const _Derived &>(*this).data() + 3 * Ksel);
132 }
133
139 Eigen::Map<const Eigen::Vector3<Scalar>> r3(int k) const
140 {
141 assert(k < K);
142 return Eigen::Map<const Eigen::Vector3<Scalar>>(static_cast<const _Derived &>(*this).data() + 3 * k);
143 }
144};
145
146// \cond
147template<typename _Scalar, int K>
148class SE_K_3;
149// \endcond
150
151// \cond
152template<typename _Scalar, int K>
153struct liebase_info<SE_K_3<_Scalar, K>>
154{
155 static constexpr bool is_mutable = true;
156
157 using Impl = SE_K_3Impl<_Scalar, K>;
158 using Scalar = _Scalar;
159
160 template<typename NewScalar>
162};
163// \endcond
164
175template<typename _Scalar, int K>
176class SE_K_3 : public SE_K_3Base<SE_K_3<_Scalar, K>>
177{
179
180 SMOOTH_GROUP_API(SE_K_3);
181
182public:
189 template<typename SO3Derived, typename... RnDerived>
190 SE_K_3(const SO3Base<SO3Derived> & so3, const Eigen::MatrixBase<RnDerived> &... r3s)
191 requires(sizeof...(r3s) == K)
192 {
193 const auto tpl = std::forward_as_tuple(r3s...);
194 Base::so3() = static_cast<const SO3Derived &>(so3);
195#ifdef __clang__
196#pragma GCC diagnostic push
197#pragma GCC diagnostic ignored "-Wunused-lambda-capture"
198#endif
199 utils::static_for<K>([this, &tpl](auto i) { Base::template r3<i>() = std::get<i>(tpl); });
200#ifdef __clang__
201#pragma GCC diagnostic pop
202#endif
203 }
204};
205
206// \cond
207template<typename _Scalar, int _K>
208struct liebase_info<Map<SE_K_3<_Scalar, _K>>> : public liebase_info<SE_K_3<_Scalar, _K>>
209{};
210// \endcond
211
217template<typename _Scalar, int _K>
218class Map<SE_K_3<_Scalar, _K>> : public SE_K_3Base<Map<SE_K_3<_Scalar, _K>>>
219{
221
222 SMOOTH_MAP_API();
223};
224
225// \cond
226template<typename _Scalar, int _K>
227struct liebase_info<Map<const SE_K_3<_Scalar, _K>>> : public liebase_info<SE_K_3<_Scalar, _K>>
228{
229 static constexpr bool is_mutable = false;
230};
231// \endcond
232
238template<typename _Scalar, int _K>
239class Map<const SE_K_3<_Scalar, _K>> : public SE_K_3Base<Map<const SE_K_3<_Scalar, _K>>>
240{
242
243 SMOOTH_CONST_MAP_API();
244};
245
246SMOOTH_END_NAMESPACE
Base class for Lie group types.
static constexpr bool is_mutable
True if underlying storage supports modification.
Eigen::Matrix< Scalar, Dim, Dim > Matrix
Lie group matrix type.
Memory mapping of internal Lie group types.
Base class for SE_k(3) Lie group types.
Definition se_k_3.hpp:66
Eigen::Map< const Eigen::Vector3< Scalar > > r3() const
Const access R3 parts.
Definition se_k_3.hpp:128
static constexpr auto K
Number of R3 variables.
Definition se_k_3.hpp:79
Eigen::Map< Eigen::Vector3< Scalar > > r3(int k)
Access R3 parts.
Definition se_k_3.hpp:115
Map< SO3< Scalar > > so3()
Access SO(3) part.
Definition se_k_3.hpp:84
Eigen::Map< Eigen::Vector3< Scalar > > r3()
Access R3 parts.
Definition se_k_3.hpp:104
Eigen::Map< const Eigen::Vector3< Scalar > > r3(int k) const
Const access R3 parts.
Definition se_k_3.hpp:139
Map< const SO3< Scalar > > so3() const
Const access SO(3) part.
Definition se_k_3.hpp:93
Storage implementation of Lie group.
Definition se_k_3.hpp:177
Base::so3()
Construct from SO3 and translation.
typename traits::man< M >::Scalar Scalar
Manifold scalar type.
Definition manifold.hpp:88
typename traits::man< M >::PlainObject PlainObject
Manifold default type.
Definition manifold.hpp:94
Type trait that maps a type to Lie group operations.