10#ifndef EIGEN_UMEYAMA_H
11#define EIGEN_UMEYAMA_H
20#include "./InternalHeaderCheck.h"
24#ifndef EIGEN_PARSED_BY_DOXYGEN
34template <
typename MatrixType,
typename OtherMatrixType>
35struct umeyama_transform_matrix_type {
37 MinRowsAtCompileTime =
38 internal::min_size_prefer_dynamic(MatrixType::RowsAtCompileTime, OtherMatrixType::RowsAtCompileTime),
42 HomogeneousDimension = int(MinRowsAtCompileTime) ==
Dynamic ?
Dynamic : int(MinRowsAtCompileTime) + 1
45 typedef Matrix<typename traits<MatrixType>::Scalar, HomogeneousDimension, HomogeneousDimension,
93template <
typename Derived,
typename OtherDerived>
94typename internal::umeyama_transform_matrix_type<Derived, OtherDerived>::type
umeyama(
96 typedef typename internal::umeyama_transform_matrix_type<Derived, OtherDerived>::type TransformationMatrixType;
97 typedef typename internal::traits<TransformationMatrixType>::Scalar Scalar;
98 typedef typename NumTraits<Scalar>::Real RealScalar;
102 (internal::is_same<Scalar,
typename internal::traits<OtherDerived>::Scalar>::value),
103 YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)
105 enum { Dimension = internal::min_size_prefer_dynamic(Derived::RowsAtCompileTime, OtherDerived::RowsAtCompileTime) };
115 const RealScalar one_over_n = RealScalar(1) /
static_cast<RealScalar
>(n);
118 const VectorType src_mean = src.
rowwise().
sum() * one_over_n;
119 const VectorType dst_mean = dst.
rowwise().
sum() * one_over_n;
122 const RowMajorMatrixType src_demean = src.
colwise() - src_mean;
123 const RowMajorMatrixType dst_demean = dst.
colwise() - dst_mean;
126 const MatrixType sigma = one_over_n * dst_demean * src_demean.transpose();
131 TransformationMatrixType Rt = TransformationMatrixType::Identity(m + 1, m + 1);
134 VectorType S = VectorType::Ones(m);
146 const Scalar src_var = src_demean.rowwise().squaredNorm().sum() * one_over_n;
149 const Scalar c = Scalar(1) / src_var * svd.
singularValues().dot(S);
152 Rt.col(m).head(m) = dst_mean;
153 Rt.col(m).head(m).noalias() -= c * Rt.topLeftCorner(m, m) * src_mean;
154 Rt.block(0, 0, m, m) *= c;
156 Rt.col(m).head(m) = dst_mean;
157 Rt.col(m).head(m).noalias() -= Rt.topLeftCorner(m, m) * src_mean;
TransposeReturnType transpose()
Definition Transpose.h:160
ConstColwiseReturnType colwise() const
Definition DenseBase.h:511
ConstRowwiseReturnType rowwise() const
Definition DenseBase.h:501
EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
Definition EigenBase.h:61
EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
Definition EigenBase.h:59
Two-sided Jacobi SVD decomposition of a rectangular matrix.
Definition JacobiSVD.h:500
Base class for all dense matrices, vectors, and expressions.
Definition MatrixBase.h:52
const DiagonalWrapper< const Derived > asDiagonal() const
Definition DiagonalMatrix.h:344
Scalar determinant() const
Definition Determinant.h:90
The matrix class, also used for vectors and row-vectors.
Definition Matrix.h:186
const SingularValuesType & singularValues() const
Definition SVDBase.h:200
const MatrixUType & matrixU() const
Definition SVDBase.h:173
const MatrixVType & matrixV() const
Definition SVDBase.h:189
const SumReturnType sum() const
Definition VectorwiseOp.h:458
internal::umeyama_transform_matrix_type< Derived, OtherDerived >::type umeyama(const MatrixBase< Derived > &src, const MatrixBase< OtherDerived > &dst, bool with_scaling=true)
Returns the transformation between two point sets.
Definition Umeyama.h:94
@ ColMajor
Definition Constants.h:318
@ RowMajor
Definition Constants.h:320
@ AutoAlign
Definition Constants.h:322
const unsigned int RowMajorBit
Definition Constants.h:70
Namespace containing all symbols from the Eigen library.
Definition Core:137
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition Meta.h:83
const int Dynamic
Definition Constants.h:25
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Definition Meta.h:523