smooth
A C++ library for Lie theory
Loading...
Searching...
No Matches
rn.hpp
Go to the documentation of this file.
1// Copyright (C) 2021-2022 Petter Nilsson. MIT License.
2
3#pragma once
4
6#include "smooth/detail/traits.hpp"
7
13SMOOTH_BEGIN_NAMESPACE
14
15namespace traits {
19template<RnType G>
20struct lie<G>
21{
22 // \cond
23 static constexpr int Dof = G::SizeAtCompileTime;
24 static constexpr bool IsCommutative = true;
25
26 using Scalar = typename G::Scalar;
27 using PlainObject = Eigen::Vector<Scalar, Dof>;
28 template<typename NewScalar>
29 using CastT = Eigen::Vector<NewScalar, Dof>;
30
31 // group interface
32
33 static inline PlainObject Identity(Eigen::Index dof) { return G::Zero(dof); }
34 static inline PlainObject Random(Eigen::Index dof) { return G::Random(dof); }
35 static inline Eigen::Matrix<Scalar, Dof, Dof> Ad(const G & g)
36 {
37 return Eigen::Matrix<Scalar, Dof, Dof>::Identity(g.size(), g.size());
38 }
39 template<typename Derived>
40 static inline PlainObject composition(const G & g1, const Eigen::MatrixBase<Derived> & g2)
41 {
42 return g1 + g2;
43 }
44 static inline Eigen::Index dof(const G & g) { return g.size(); }
45 static inline PlainObject inverse(const G & g) { return -g; }
46 template<typename Derived>
47 static inline bool isApprox(const G & g, const Eigen::MatrixBase<Derived> & g2, Scalar eps)
48 {
49 return g.isApprox(g2, eps);
50 }
51 static inline Eigen::Vector<Scalar, Dof> log(const G & g) { return g; }
52 template<typename NewScalar>
53 static inline Eigen::Vector<NewScalar, Dof> cast(const G & g)
54 {
55 return g.template cast<NewScalar>();
56 }
57
58 // tangent interface
59
60 template<typename Derived>
61 static inline Eigen::Matrix<Scalar, Dof, Dof> ad(const Eigen::MatrixBase<Derived> & a)
62 {
63 return Eigen::Matrix<Scalar, Dof, Dof>::Zero(a.size(), a.size());
64 }
65 template<typename Derived>
66 static inline PlainObject exp(const Eigen::MatrixBase<Derived> & a)
67 {
68 return a;
69 }
70 template<typename Derived>
71 static inline Eigen::Matrix<Scalar, Dof, Dof> dr_exp(const Eigen::MatrixBase<Derived> & a)
72 {
73 return Eigen::Matrix<Scalar, Dof, Dof>::Identity(a.size(), a.size());
74 }
75 template<typename Derived>
76 static inline Eigen::Matrix<Scalar, Dof, Dof> dr_expinv(const Eigen::MatrixBase<Derived> & a)
77 {
78 return Eigen::Matrix<Scalar, Dof, Dof>::Identity(a.size(), a.size());
79 }
80 template<typename Derived>
81 static inline Eigen::Matrix<Scalar, Dof, (Dof > 0 ? Dof * Dof : -1)> d2r_exp(const Eigen::MatrixBase<Derived> & a)
82 {
83 return Eigen::Matrix<Scalar, Dof, (Dof > 0 ? Dof * Dof : -1)>::Zero(a.size(), a.size() * a.size());
84 }
85 template<typename Derived>
86 static inline Eigen::Matrix<Scalar, Dof, (Dof > 0 ? Dof * Dof : -1)> d2r_expinv(const Eigen::MatrixBase<Derived> & a)
87 {
88 return Eigen::Matrix<Scalar, Dof, (Dof > 0 ? Dof * Dof : -1)>::Zero(a.size(), a.size() * a.size());
89 }
90 // \endcond
91};
92
93} // namespace traits
94
95SMOOTH_END_NAMESPACE
TangentMap< G > Ad(const G &g)
Group adjoint .
PlainObject< G > Random()
Random element in Lie group with static Dof.
Hessian< G > d2r_exp(Arg &&a)
Right Hessian of exponential map.
bool isApprox(const G &g, Arg &&a, typename traits::lie< G >::Scalar eps=Eigen::NumTraits< typename traits::lie< G >::Scalar >::dummy_precision())
Check if two group elements are approximately equal.
Tangent< G > log(const G &g)
Group logarithm.
TangentMap< G > dr_exp(Arg &&a)
Right Jacobian of exponential map.
PlainObject< G > composition(const G &g, Arg &&a)
Group binary composition.
PlainObject< G > exp(Arg &&a)
Lie algebra exponential.
Hessian< G > d2r_expinv(Arg &&a)
Right Hessian of exponential map inverse.
PlainObject< G > Identity()
Identity in Lie group with static Dof.
TangentMap< G > ad(Arg &&a)
Lie algebra adjoint .
PlainObject< G > inverse(const G &g)
Group inverse.
TangentMap< G > dr_expinv(Arg &&a)
Right Jacobian of exponential map inverse.
typename traits::man< M >::Scalar Scalar
Manifold scalar type.
Definition manifold.hpp:88
Eigen::Index dof(const M &m)
Manifold degrees of freedom (tangent space dimension)
Definition manifold.hpp:145
typename traits::man< M >::template CastT< NewScalar > CastT
Cast'ed type.
Definition manifold.hpp:100
CastT< NewScalar, M > cast(const M &m)
Cast to different scalar type.
Definition manifold.hpp:154
typename traits::man< M >::PlainObject PlainObject
Manifold default type.
Definition manifold.hpp:94