template class sophus::So2Base¶
Overview¶
So2 base type - implements So2 class but is storage agnostic. More…
#include <so2.h> template <class TDerived> class So2Base { public: // typedefs using Scalar = typename Eigen::internal::traits<TDerived>::Scalar ; using ComplexT = typename Eigen::internal::traits<TDerived>::ComplexType ; using ComplexTemporaryType = Eigen::Matrix<Scalar, 2, 1, kOptions> ; using Transformation = Eigen::Matrix<Scalar, kMatrixDim, kMatrixDim> ; using Point = Eigen::Vector2<Scalar> ; using HomogeneousPoint = Eigen::Vector3<Scalar> ; using Line = Eigen::ParametrizedLine<Scalar, 2> ; using Hyperplane = Eigen::Hyperplane<Scalar, 2> ; using Tangent = Scalar ; using Adjoint = Scalar ; using ReturnScalar = typename Eigen::ScalarBinaryOpTraits<Scalar, typename TOtherDerived::Scalar>::ReturnType ; using So2Product = So2<ReturnScalar<TOtherDerived>> ; using PointProduct = Eigen::Vector2<ReturnScalar<TPointDerived>> ; using HomogeneousPointProduct = Eigen::Vector3<ReturnScalar<THPointDerived>> ; // fields static constexpr int kOptions = Eigen::internal::traits<TDerived>::kOptions; static constexpr int kDoF = 1; static constexpr int kNumParameters = 2; static constexpr int kMatrixDim = 2; static constexpr int kPointDim = 2; // methods SOPHUS_FUNC Adjoint adj() const; template <class TNewScalarType> SOPHUS_FUNC So2<TNewScalarType> cast() const; SOPHUS_FUNC Scalar* data(); SOPHUS_FUNC Scalar const* data() const; SOPHUS_FUNC So2<Scalar> inverse() const; SOPHUS_FUNC Scalar log() const; SOPHUS_FUNC void normalize(); SOPHUS_FUNC Transformation matrix() const; template <class TOtherDerived> SOPHUS_FUNC So2Base<TDerived>& operator=(So2Base<TOtherDerived> const& other); template <class TOtherDerived> SOPHUS_FUNC So2Product<TOtherDerived> operator*(So2Base<TOtherDerived> const& other) const; template < typename TPointDerived, typename = typename std::enable_if<IsFixedSizeVector<TPointDerived, 2>::value>::type > SOPHUS_FUNC PointProduct<TPointDerived> operator*(Eigen::MatrixBase<TPointDerived> const& p) const; template < typename THPointDerived, typename = typename std::enable_if<IsFixedSizeVector<THPointDerived, 3>::value>::type > SOPHUS_FUNC HomogeneousPointProduct<THPointDerived> operator*(Eigen::MatrixBase<THPointDerived> const& p) const; SOPHUS_FUNC Line operator*(Line const& l) const; SOPHUS_FUNC Hyperplane operator*(Hyperplane const& p) const; template < typename TOtherDerived, typename = typename std::enable_if<std::is_same<Scalar, ReturnScalar<TOtherDerived>>::value>::type > SOPHUS_FUNC So2Base<TDerived> operator*=(So2Base<TOtherDerived> const& other); SOPHUS_FUNC Eigen::Matrix<Scalar, kNumParameters, kDoF> dxThisMulExpXAt0() const; SOPHUS_FUNC Eigen::Vector<Scalar, kNumParameters> params() const; SOPHUS_FUNC Eigen::Matrix<Scalar, kDoF, kNumParameters> dxLogThisInvTimesXAtThis() const; SOPHUS_FUNC void setComplex(Point const& complex); SOPHUS_FUNC ComplexT const& unitComplex() const; }; // direct descendants template <class TScalar, int kOptions> class Map<sophus::So2<TScalar>, kOptions>;
Detailed Documentation¶
So2 base type - implements So2 class but is storage agnostic.
SO(2) is the group of rotations in 2d. As a matrix group, it is the set of matrices which are orthogonal such that R * R' = I
(with R'
being the transpose of R
) and have a positive determinant. In particular, the determinant is 1. Let theta
be the rotation angle, the rotation matrix can be written in close form:
| cos(theta) -sin(theta) |
| sin(theta) cos(theta) |
As a matter of fact, the first column of those matrices is isomorph to the set of unit complex numbers U(1). Thus, internally, So2 is represented as complex number with length 1.
SO(2) is a compact and commutative group. First it is compact since the set of rotation matrices is a closed and bounded set. Second it is commutative since R(alpha) * R(beta) = R(beta) * R(alpha)
, simply because alpha + beta = beta + alpha
with alpha
and beta
being rotation angles (about the same axis).
Class invariant: The 2-norm of unit_complex
must be close to 1. Technically speaking, it must hold that:
|unit_complex().squaredNorm() - 1| <= Constants::epsilon()
.
Typedefs¶
using ReturnScalar = typename Eigen::ScalarBinaryOpTraits<Scalar, typename TOtherDerived::Scalar>::ReturnType
For binary operations the return type is determined with the ScalarBinaryOpTraits feature of Eigen. This allows mixing concrete and Map types, as well as other compatible scalar types such as Ceres::Jet and double scalars with So2 operations.
Fields¶
static constexpr int kDoF = 1
Degrees of freedom of manifold, number of dimensions in tangent space (one since we only have in-plane rotations).
static constexpr int kNumParameters = 2
Number of internal parameters used (complex numbers are a tuples).
static constexpr int kMatrixDim = 2
Group transformations are 2x2 matrices.
static constexpr int kPointDim = 2
Points are 3-dimensional.
Methods¶
SOPHUS_FUNC Adjoint adj() const
Adjoint transformation.
This function return the adjoint transformation Ad
of the group element A
such that for all x
it holds that hat(Ad_A * x) = A * hat(x) A^{-1}
. See hat-operator below.
It simply 1
, since SO(2)
is a commutative group.
template <class TNewScalarType> SOPHUS_FUNC So2<TNewScalarType> cast() const
Returns copy of instance casted to NewScalarType.
SOPHUS_FUNC Scalar* data()
This provides unsafe read/write access to internal data. SO(2) is represented by a unit complex number (two parameters). When using direct write access, the user needs to take care of that the complex number stays normalized.
SOPHUS_FUNC Scalar const* data() const
Const version of data() above.
SOPHUS_FUNC So2<Scalar> inverse() const
Returns group inverse.
SOPHUS_FUNC Scalar log() const
Logarithmic map.
Computes the logarithm, the inverse of the group exponential which maps element of the group (rotation matrices) to elements of the tangent space (rotation angles).
To be specific, this function computes vee(logmat(.))
with logmat(.)
being the matrix logarithm and vee(.)
the vee-operator of SO(2).
SOPHUS_FUNC void normalize()
It re-normalizes unit_complex
to unit length.
Note: Because of the class invariant, there is typically no need to call this function directly.
SOPHUS_FUNC Transformation matrix() const
Returns 2x2 matrix representation of the instance.
For SO(2), the matrix representation is an orthogonal matrix R
with det(R)=1
, thus the so-called “rotation matrix”.
template <class TOtherDerived> SOPHUS_FUNC So2Base<TDerived>& operator=(So2Base<TOtherDerived> const& other)
Assignment-like operator from OtherDerived.
template <class TOtherDerived> SOPHUS_FUNC So2Product<TOtherDerived> operator*(So2Base<TOtherDerived> const& other) const
Group multiplication, which is rotation concatenation.
template < typename TPointDerived, typename = typename std::enable_if<IsFixedSizeVector<TPointDerived, 2>::value>::type > SOPHUS_FUNC PointProduct<TPointDerived> operator*(Eigen::MatrixBase<TPointDerived> const& p) const
Group action on 2-points.
This function rotates a 2 dimensional point p
by the So2 element bar_R_foo
(= rotation matrix): p_bar = bar_R_foo * p_foo
.
template < typename THPointDerived, typename = typename std::enable_if<IsFixedSizeVector<THPointDerived, 3>::value>::type > SOPHUS_FUNC HomogeneousPointProduct<THPointDerived> operator*(Eigen::MatrixBase<THPointDerived> const& p) const
Group action on homogeneous 2-points.
This function rotates a homogeneous 2 dimensional point p
by the So2 element bar_R_foo
(= rotation matrix): p_bar = bar_R_foo * p_foo
.
SOPHUS_FUNC Line operator*(Line const& l) const
Group action on lines.
This function rotates a parametrized line l(t) = o + t * d
by the So2 element:
Both direction d
and origin o
are rotated as a 2 dimensional point
SOPHUS_FUNC Hyperplane operator*(Hyperplane const& p) const
Group action on hyper-planes.
This function rotates a hyper-plane n.x + d = 0
by the So2 element:
Normal vector n
is rotated Offset d
is left unchanged
Note that in 2d-case hyper-planes are just another parametrization of lines
template < typename TOtherDerived, typename = typename std::enable_if<std::is_same<Scalar, ReturnScalar<TOtherDerived>>::value>::type > SOPHUS_FUNC So2Base<TDerived> operator*=(So2Base<TOtherDerived> const& other)
In-place group multiplication. This method is only valid if the return type of the multiplication is compatible with this So2 ‘s Scalar type.
SOPHUS_FUNC Eigen::Matrix<Scalar, kNumParameters, kDoF> dxThisMulExpXAt0() const
Returns derivative of this * So2::exp(x) wrt. x at x=0.
SOPHUS_FUNC Eigen::Vector<Scalar, kNumParameters> params() const
Returns internal parameters of SO(2).
It returns (c[0], c[1]), with c being the unit complex number.
SOPHUS_FUNC Eigen::Matrix<Scalar, kDoF, kNumParameters> dxLogThisInvTimesXAtThis() const
Returns derivative of log(this^{-1} * x) by x at x=this.
SOPHUS_FUNC void setComplex(Point const& complex)
Takes in complex number / tuple and normalizes it.
Precondition: The complex number must not be close to zero.
SOPHUS_FUNC ComplexT const& unitComplex() const
Accessor of unit quaternion.