19 AnyManifold() {
throw std::runtime_error(
"Can not default-construct"); }
23 explicit AnyManifold(
const M & m) : m_val(std::make_unique<wrapper<std::decay_t<M>>>(m))
35 m_val = m.m_val->clone();
42 m_val = std::move(m.m_val);
50 return static_cast<wrapper<M> *
>(m_val.get())->
get();
57 return static_cast<const wrapper<M> *
>(m_val.get())->
get();
61 Eigen::Index
dof()
const {
return m_val->dof(); }
73 virtual ~wrapper_base() =
default;
74 virtual Eigen::Index
dof()
const = 0;
75 virtual std::unique_ptr<wrapper_base>
rplus(Eigen::Ref<const Eigen::VectorXd>)
const = 0;
76 virtual Eigen::VectorXd
rminus(
const std::unique_ptr<wrapper_base> & o)
const = 0;
77 virtual std::unique_ptr<wrapper_base> clone()
const = 0;
81 class wrapper :
public wrapper_base
84 explicit wrapper(
const M & val) : m_val(val) {}
85 explicit wrapper(M && val) : m_val(std::move(val)) {}
86 Eigen::Index
dof()
const override { return ::smooth::dof(m_val); }
87 std::unique_ptr<wrapper_base>
rplus(Eigen::Ref<const Eigen::VectorXd> a)
const override
89 return std::make_unique<wrapper<M>>(::smooth::rplus(m_val, a));
91 Eigen::VectorXd
rminus(
const std::unique_ptr<wrapper_base> & o)
const override
93 return ::smooth::rminus(m_val,
static_cast<const wrapper<M> *
>(o.get())->m_val);
95 std::unique_ptr<wrapper_base> clone()
const override {
return std::make_unique<wrapper<M>>(m_val); }
96 M & get() {
return m_val; }
97 const M & get()
const {
return m_val; }
104 explicit AnyManifold(std::unique_ptr<wrapper_base> val) : m_val(std::move(val)) {}
105 std::unique_ptr<wrapper_base> m_val;
115 template<
typename NewScalar>
118 static constexpr int Dof = -1;
122 static inline PlainObject Default(Eigen::Index) {
throw std::runtime_error(
"AnyManifold: default not supported"); }
124 template<
typename NewScalar>
127 throw std::runtime_error(
"AnyManifold: cast not supported");
130 template<
typename Derived>
138 return m1.rminus(m2);
Type erasure Manifold class.
Eigen::VectorXd rminus(const AnyManifold &m2) const
Right-minus.
AnyManifold(AnyManifold &&m)
Move constructor.
AnyManifold & operator=(const AnyManifold &m)
Copy assignment.
AnyManifold rplus(Eigen::Ref< const Eigen::VectorXd > a) const
Right-plus.
AnyManifold & operator=(AnyManifold &&m)
Move assignment.
const M & get() const
Get value (const).
Eigen::Index dof() const
Degrees of freedom.
AnyManifold()
Constructor.
AnyManifold(const AnyManifold &m)
Copy constructor.
AnyManifold(const M &m)
Construct from typed manifoild.
M & get()
Get value (mutable).
PlainObject< M > Default()
Default-initialized Manifold with static dof.
typename traits::man< M >::Scalar Scalar
Manifold scalar type.
Eigen::Index dof(const M &m)
Manifold degrees of freedom (tangent space dimension)
Tangent< M > rminus(const M &g1, const Mo &g2)
Manifold right-minus.
PlainObject< M > rplus(const M &m, const Eigen::MatrixBase< Derived > &a)
Manifold right-plus.
typename traits::man< M >::template CastT< NewScalar > CastT
Cast'ed type.
CastT< NewScalar, M > cast(const M &m)
Cast to different scalar type.
typename traits::man< M >::PlainObject PlainObject
Manifold default type.