10#ifndef EIGEN_UMEYAMA_H 
   11#define EIGEN_UMEYAMA_H 
   20#include "./InternalHeaderCheck.h" 
   32template <
typename MatrixType, 
typename OtherMatrixType>
 
   33struct umeyama_transform_matrix_type {
 
   35    MinRowsAtCompileTime =
 
   36        internal::min_size_prefer_dynamic(MatrixType::RowsAtCompileTime, OtherMatrixType::RowsAtCompileTime),
 
   40    HomogeneousDimension = int(MinRowsAtCompileTime) == 
Dynamic ? 
Dynamic : int(MinRowsAtCompileTime) + 1
 
   43  typedef Matrix<typename traits<MatrixType>::Scalar, HomogeneousDimension, HomogeneousDimension,
 
   89template <
typename Derived, 
typename OtherDerived>
 
   90typename internal::umeyama_transform_matrix_type<Derived, OtherDerived>::type 
umeyama(
 
   92  typedef typename internal::umeyama_transform_matrix_type<Derived, OtherDerived>::type TransformationMatrixType;
 
   93  typedef typename internal::traits<TransformationMatrixType>::Scalar 
Scalar;
 
   94  typedef typename NumTraits<Scalar>::Real RealScalar;
 
   96  EIGEN_STATIC_ASSERT(!NumTraits<Scalar>::IsComplex, NUMERIC_TYPE_MUST_BE_REAL)
 
   98      (internal::is_same<
Scalar, 
typename internal::traits<OtherDerived>::Scalar>::value),
 
   99      YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)
 
  101  enum { Dimension = internal::min_size_prefer_dynamic(Derived::RowsAtCompileTime, OtherDerived::RowsAtCompileTime) };
 
  105  typedef typename internal::plain_matrix_type_row_major<Derived>::type RowMajorMatrixType;
 
  107  const Index m = src.rows();  
 
  108  const Index n = src.cols();  
 
  111  const RealScalar one_over_n = RealScalar(1) / 
static_cast<RealScalar
>(n);
 
  114  const VectorType src_mean = src.
rowwise().
sum() * one_over_n;
 
  115  const VectorType dst_mean = dst.
rowwise().
sum() * one_over_n;
 
  118  const RowMajorMatrixType src_demean = src.
colwise() - src_mean;
 
  119  const RowMajorMatrixType dst_demean = dst.
colwise() - dst_mean;
 
  122  const MatrixType sigma = one_over_n * dst_demean * src_demean.transpose();
 
  127  TransformationMatrixType Rt = TransformationMatrixType::Identity(m + 1, m + 1);
 
  130  VectorType S = VectorType::Ones(m);
 
  132  if (svd.
matrixU().determinant() * svd.
matrixV().determinant() < 0) {
 
  138  Rt.block(0, 0, m, m).noalias() = svd.
matrixU() * S.asDiagonal() * svd.
matrixV().transpose();
 
  142    const Scalar src_var = src_demean.rowwise().squaredNorm().sum() * one_over_n;
 
  148    Rt.col(m).head(m) = dst_mean;
 
  149    Rt.col(m).head(m).noalias() -= c * Rt.topLeftCorner(m, m) * src_mean;
 
  150    Rt.block(0, 0, m, m) *= c;
 
  152    Rt.col(m).head(m) = dst_mean;
 
  153    Rt.col(m).head(m).noalias() -= Rt.topLeftCorner(m, m) * src_mean;
 
 
ConstColwiseReturnType colwise() const
Definition DenseBase.h:518
ConstRowwiseReturnType rowwise() const
Definition DenseBase.h:508
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
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:469
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:90
@ 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 B01_Experimental.dox:1
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition Meta.h:82
const int Dynamic
Definition Constants.h:25