10 #ifndef EIGEN_LGSM_LIE_GROUP_SO3_H 11 #define EIGEN_LGSM_LIE_GROUP_SO3_H 27 template<
class Derived>
33 typedef typename internal::traits<Derived>::Scalar
Scalar;
37 typedef typename internal::traits<Derived>::Coefficients
Coefficients;
49 EIGEN_STRONG_INLINE PlainObject
inverse()
const;
57 template<
class MatrixDerived> EIGEN_STRONG_INLINE Matrix<Scalar, 3, 1>
operator*(
const MatrixBase<MatrixDerived>& v)
const {
58 return this->
get() * v;
62 inline AdjointMatrix
adjoint(
void)
const;
64 template<
class AlgebraDerived>
inline Algebra
adjoint(
const LieAlgebraBase<Matrix<Scalar, 3, 1>, AlgebraDerived>& )
const;
66 template<
class AlgebraDualDerived>
inline AlgebraDual
adjointTr(
const LieAlgebraDualBase<Matrix<Scalar, 3, 1>, AlgebraDualDerived>& )
const;
71 Algebra
log(
const Scalar precision = 1e-6)
const;
78 template<
class OtherDerived> Derived&
operator=(
const MatrixBase<OtherDerived>& m){ this->
get() = m;
return this->
derived();}
81 inline const Derived&
derived()
const {
return *
static_cast<const Derived*
>(
this); }
83 inline Derived&
derived() {
return *
static_cast<Derived*
>(
this); }
87 inline Scalar
x()
const {
return this->
get().
x(); }
89 inline Scalar
y()
const {
return this->
get().
y(); }
91 inline Scalar
z()
const {
return this->
get().
z(); }
93 inline Scalar
w()
const {
return this->
get().
w(); }
96 inline Scalar&
x() {
return this->
get().
x(); }
98 inline Scalar&
y() {
return this->
get().
y(); }
100 inline Scalar&
z() {
return this->
get().
z(); }
102 inline Scalar&
w() {
return this->
get().
w(); }
109 template<
typename NewScalarType>
110 inline typename internal::cast_return_type<Derived, LieGroup<Quaternion<NewScalarType> > >::type
cast()
const 112 return typename internal::cast_return_type<Derived, LieGroup<Quaternion<NewScalarType> > >::type(
113 get().
template cast<NewScalarType>());
117 inline const VectorBlock<Coefficients,3>
vec()
const {
return this->
get().
vec(); }
120 inline VectorBlock<Coefficients,3>
vec() {
return this->
get().
vec(); }
123 Coefficients&
get() {
return derived().get(); }
125 const Coefficients&
get()
const {
return derived().get(); }
133 template<
class Derived>
137 this->
get() = other.
get();
142 template<
class Derived>
143 template<
class OtherDerived>
144 EIGEN_STRONG_INLINE Derived&
147 this->
get() = other.
get();
152 template<
class Derived>
160 template<
class Derived>
164 return PlainObject(Quaternion<Scalar>::Identity());
168 template<
class Derived>
176 template<
class Derived>
177 template<
class OtherDerived>
178 EIGEN_STRONG_INLINE Derived&
181 this->
get() *= other.
get();
186 template<
class Derived>
190 const Scalar n2 = this->
get().vec().squaredNorm();
191 const Scalar n = std::sqrt(n2);
194 return Algebra((2 / this->
get().w()) * this->
get().vec());
196 return Algebra(std::atan2(2 * n * this->
get().w(), this->
get().w() * this->
get().w() - n2) / n * this->
get().vec());
200 template<
class Derived>
204 return this->
get().toRotationMatrix();
207 template<
class Derived>
208 inline std::ostream& operator <<(std::ostream& os, const LieGroupBase<Quaternion<typename internal::traits<Derived>::Scalar>, Derived>& g)
210 os << g.w() <<
"\t" << g.x() <<
"\t" << g.y() <<
"\t" << g.z();
230 template<
typename _Scalar>
class LieGroup<Quaternion<_Scalar> > :
231 public LieGroupBase<Quaternion<_Scalar>, LieGroup<Quaternion<_Scalar> > >
242 EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(
LieGroup)
251 EIGEN_STRONG_INLINE
LieGroup(
const Coefficients& g) : m_coeffs(g) {}
252 EIGEN_STRONG_INLINE
LieGroup(
const AngleAxis<Scalar>& aa) : m_coeffs(aa) {}
255 template<
class OtherDerived>
inline LieGroup(Scalar w,
const MatrixBase<OtherDerived>& vec)
256 : m_coeffs(w, vec.coeff(0), vec.coeff(1), vec.coeff(2))
262 template<
typename Derived>
263 explicit inline LieGroup(
const MatrixBase<Derived> & other) { this->
get() = other;}
265 template<
typename Derived>
266 explicit inline LieGroup(
const Matrix<Scalar, 4, 1> & other) {
this = other;}
275 inline LieGroup(Scalar w, Scalar x, Scalar y, Scalar z) : m_coeffs(w, x, y, z) {}
276 inline LieGroup(Scalar w,
const Matrix<Scalar, 3, 1> & v) : m_coeffs(w, v.x(), v.y(), v.z()) {}
279 Coefficients&
get() {
return m_coeffs; }
281 const Coefficients&
get()
const {
return m_coeffs; }
LieGroup(Scalar w, const Matrix< Scalar, 3, 1 > &v)
internal::traits< Derived >::Coefficients Coefficients
Class describing an element of a Lie Algebra.
internal::cast_return_type< Derived, LieGroup< Quaternion< NewScalarType > > >::type cast() const
LieGroup(const Matrix< Scalar, 4, 1 > &other)
CoAlgebra adjointTr(const CoAlgebra &) const
LieGroup< Quaternion< Scalar > > PlainObject
Derived & operator=(const MatrixBase< OtherDerived > &m)
LieGroup(const LieGroupBase< typename Base::BaseType, OtherDerived > &g)
AdjointMatrix adjoint(void) const
internal::traits< LieGroup< Quaternion< Scalar > > >::Coefficients Coefficients
EIGEN_STRONG_INLINE Matrix< Scalar, 3, 1 > operator*(const MatrixBase< MatrixDerived > &v) const
internal::traits< Derived >::Scalar Scalar
VectorBlock< Coefficients, 3 > vec()
const Derived & derived() const
Quaternion< Scalar > BaseType
const Derived & derived() const
PlainObject inverse() const
LieGroup(Scalar w, const MatrixBase< OtherDerived > &vec)
LieGroup(const MatrixBase< Derived > &other)
Base class for all Lie Group class.
internal::traits< Derived >::PlainObject PlainObject
const VectorBlock< Coefficients, 3 > vec() const
LieGroupBase< Quaternion< _Scalar >, LieGroup< Quaternion< _Scalar > > > Base
Base class for all Lie Algebra class.
Matrix< Scalar, 3, 3 > AdjointMatrix
LieGroup(Scalar w, Scalar x, Scalar y, Scalar z)
LieGroupBase & operator=(const LieGroupBase< G, OtherDerived > &)
Class describing an element of a Lie Group.
Class describing an element of a Lie algebra dual.
Algebra log(const Scalar precision=1e-6) const
PlainObject operator*(const LieGroupBase< G, OtherDerived > &other) const
EIGEN_STRONG_INLINE LieGroup(const Coefficients &g)
static PlainObject Identity()
LieAlgebra< Matrix< Scalar, 3, 1 > > Algebra
EIGEN_STRONG_INLINE LieGroup(const AngleAxis< Scalar > &aa)
LieAlgebraDual< Matrix< Scalar, 3, 1 > > AlgebraDual