6#include <Eigen/Geometry>
8#include "detail/macro.hpp"
9#include "detail/so3.hpp"
10#include "lie_group_base.hpp"
15template<
typename Scalar>
53template<
typename _Derived>
62 SMOOTH_INHERIT_TYPEDEFS;
67 Eigen::Map<Eigen::Quaternion<Scalar>>
quat()
70 return Eigen::Map<Eigen::Quaternion<Scalar>>(
static_cast<_Derived &
>(*this).data());
76 Eigen::Map<const Eigen::Quaternion<Scalar>>
quat()
const
78 return Eigen::Map<const Eigen::Quaternion<Scalar>>(
static_cast<const _Derived &
>(*this).data());
91 Eigen::Vector3<Scalar>
eulerAngles(Eigen::Index
i1 = 2, Eigen::Index
i2 = 1, Eigen::Index
i3 = 0)
const
93 return quat().toRotationMatrix().eulerAngles(
i1,
i2,
i3);
99 template<
typename EigenDerived>
100 Eigen::Vector3<Scalar>
operator*(
const Eigen::MatrixBase<EigenDerived> &
v)
const
112 template<
typename EigenDerived>
113 Eigen::Matrix3<Scalar>
dr_action(
const Eigen::MatrixBase<EigenDerived> &
v)
const
129 const auto q =
quat();
139template<
typename _Scalar>
144template<
typename _Scalar>
147 static constexpr bool is_mutable =
true;
149 using Impl = SO3Impl<_Scalar>;
152 template<
typename NewScalar>
162template<
typename _Scalar>
167 SMOOTH_GROUP_API(
SO3);
177 template<
typename Derived>
180 if (m_coeffs(3) < 0) { m_coeffs *=
Scalar(-1); }
189 using std::cos, std::sin;
193 if (
ret.coeffs()(3) < 0) {
ret.coeffs() *=
Scalar(-1); }
203 using std::cos, std::sin;
207 if (
ret.coeffs()(3) < 0) {
ret.coeffs() *=
Scalar(-1); }
217 using std::cos, std::sin;
221 if (
ret.coeffs()(3) < 0) {
ret.coeffs() *=
Scalar(-1); }
227template<
typename _Scalar>
237template<
typename _Scalar>
246template<
typename _Scalar>
249 static constexpr bool is_mutable =
false;
258template<
typename _Scalar>
263 SMOOTH_CONST_MAP_API();
272#if __has_include(<format>)
276template<
class Scalar>
277struct std::formatter<smooth::
SO3<Scalar>>
281 constexpr auto parse(std::format_parse_context & ctx)
284 for (
auto it = ctx.begin(); it != ctx.end(); ++
it) {
287 if (c ==
'}')
return it;
292 auto format(
const smooth::SO3<Scalar> & obj, std::format_context & ctx)
const
294 const auto fmtSting = std::format(
"[{0}, {0}, {0}, {0}]", m_format);
295 return std::vformat_to(
296 ctx.out(), fmtSting, std::make_format_args(obj.quat().w(), obj.quat().x(), obj.quat().y(), obj.quat().z()));
Base class for Lie group types.
typename traits::Scalar Scalar
Scalar type.
auto & coeffs() const
Access underlying storages.
static constexpr bool is_mutable
True if underlying storage supports modification.
static Matrix hat(const Eigen::MatrixBase< TangentDerived > &a) noexcept
Lie algebra hat map.
Matrix matrix() const noexcept
Return as matrix Lie group element in .
Eigen::Matrix< Scalar, Dim, Dim > Matrix
Lie group matrix type.
Memory mapping of internal Lie group types.
Storage implementation of SO2 Lie group.
Base class for SO3 Lie group types.
Eigen::Vector3< Scalar > operator*(const Eigen::MatrixBase< EigenDerived > &v) const
Rotation action on 3D vector.
Eigen::Map< Eigen::Quaternion< Scalar > > quat()
Access quaterion.
SO2< Scalar > project_so2() const
Project to SO2.
Eigen::Vector3< Scalar > eulerAngles(Eigen::Index i1=2, Eigen::Index i2=1, Eigen::Index i3=0) const
Return euler angles.
Eigen::Matrix3< Scalar > dr_action(const Eigen::MatrixBase< EigenDerived > &v) const
Jacobian of rotation action w.r.t. group.
Eigen::Map< const Eigen::Quaternion< Scalar > > quat() const
Access const quaterion.
Storage implementation of SO3 Lie group.
static SO3 rot_z(const Scalar &angle)
SO3 representing rotation around the z axis.
static SO3 rot_x(const Scalar &angle)
SO3 representing rotation around the x axis.
static SO3 rot_y(const Scalar &angle)
SO3 representing rotation around the y axis.
SO3(const Eigen::QuaternionBase< Derived > &quat)
Construct from quaternion.
typename traits::man< M >::Scalar Scalar
Manifold scalar type.
typename traits::man< M >::PlainObject PlainObject
Manifold default type.
Type trait that maps a type to Lie group operations.