Chemical Data Processing Library C++ API - Version 1.4.0
Public Types | Public Member Functions | List of all members
CDPL::Math::KabschAlgorithm< T > Class Template Reference

Implementation of the Kabsch algorithm [KABA]. More...

#include <KabschAlgorithm.hpp>

+ Inheritance diagram for CDPL::Math::KabschAlgorithm< T >:

Public Types

typedef T ValueType
 The scalar value type. More...
 
typedef Matrix< T > MatrixType
 The matrix type used for the transformation, the covariance matrix and the working buffers. More...
 
typedef Vector< T > VectorType
 The vector type used for the centroids and singular-value vectors. More...
 

Public Member Functions

template<typename M1 , typename M2 , typename V >
bool align (const MatrixExpression< M1 > &points, const MatrixExpression< M2 > &ref_points, const VectorExpression< V > &weights, bool do_center=true, std::size_t max_svd_iter=0)
 Computes the rigid body transformation that aligns a set of \( N \) \( D \)-dimensional points points with a corresponding set of reference points ref_points at a minimum RMSD. More...
 
template<typename M1 , typename M2 >
bool align (const MatrixExpression< M1 > &points, const MatrixExpression< M2 > &ref_points, bool do_center=true, std::size_t max_svd_iter=0)
 Computes the rigid body transformation that aligns a set of \( N \) \( D \)-dimensional points points with a corresponding set of reference points ref_points at a minimum RMSD. More...
 
const MatrixTypegetTransform () const
 Returns the rigid-body transformation produced by the most recent successful align() call. More...
 

Detailed Description

template<typename T>
class CDPL::Math::KabschAlgorithm< T >

Implementation of the Kabsch algorithm [KABA].

Finds the least Root Mean Square Distance between two sets of \( N \) points in \( D \) dimensions and the rigid transformation (i.e. translation and rotation) to employ in order to bring one set that close to the other.

Note that the points are paired, i.e. it is known which point in one set should be compared to a given point in the other set. It is possible to give weights to the points. Those weights are determined a priori and do not depend on the distances.

The convention is used that points are column vectors of the input matrices.

Member Typedef Documentation

◆ ValueType

template<typename T >
typedef T CDPL::Math::KabschAlgorithm< T >::ValueType

The scalar value type.

◆ MatrixType

template<typename T >
typedef Matrix<T> CDPL::Math::KabschAlgorithm< T >::MatrixType

The matrix type used for the transformation, the covariance matrix and the working buffers.

◆ VectorType

template<typename T >
typedef Vector<T> CDPL::Math::KabschAlgorithm< T >::VectorType

The vector type used for the centroids and singular-value vectors.

Member Function Documentation

◆ align() [1/2]

template<typename T >
template<typename M1 , typename M2 , typename V >
bool CDPL::Math::KabschAlgorithm< T >::align ( const MatrixExpression< M1 > &  points,
const MatrixExpression< M2 > &  ref_points,
const VectorExpression< V > &  weights,
bool  do_center = true,
std::size_t  max_svd_iter = 0 
)
inline

Computes the rigid body transformation that aligns a set of \( N \) \( D \)-dimensional points points with a corresponding set of reference points ref_points at a minimum RMSD.

Parameters
pointsA \( D \times N \)-matrix storing the points to align as column vectors.
ref_pointsA \( D \times N \)-matrix storing the reference points as column vectors.
weightsA \( N \)-dimensional vector storing the non-negative weights that are assigned to the points.
do_centertrue if centering of the data points needs to be performed, and false if not.
max_svd_iterThe maximum number of iterations to perform in the SV-decomposition, or 0 if no limit.
Returns
true if convergence in the internal SV-decomposition has been reached in max_svd_iter iterations, and false otherwise.
Precondition
points().getSize1() == ref_points().getSize1()
points().getSize2() == ref_points().getSize2()
weights().getSize() == points().getSize2()
weights()(i) >= 0 && sum(weights) > 0
Exceptions
Base::SizeErroror Base::ValueError if preconditions got violated.

◆ align() [2/2]

template<typename T >
template<typename M1 , typename M2 >
bool CDPL::Math::KabschAlgorithm< T >::align ( const MatrixExpression< M1 > &  points,
const MatrixExpression< M2 > &  ref_points,
bool  do_center = true,
std::size_t  max_svd_iter = 0 
)
inline

Computes the rigid body transformation that aligns a set of \( N \) \( D \)-dimensional points points with a corresponding set of reference points ref_points at a minimum RMSD.

Parameters
pointsA \( D \times N \)-matrix storing the points to align as column vectors.
ref_pointsA \( D \times N \)-matrix storing the reference points as column vectors.
do_centertrue if centering of the data points needs to be performed, and false if not.
max_svd_iterThe maximum number of iterations to perform in the SV-decomposition, or 0 if no limit.
Returns
true if convergence in the internal SV-decomposition has been reached in max_svd_iter iterations, and false otherwise.
Precondition
points().getSize1() == ref_points().getSize1()
points().getSize2() == ref_points().getSize2()
Exceptions
Base::SizeErrorif preconditions got violated.

◆ getTransform()

template<typename T >
const MatrixType& CDPL::Math::KabschAlgorithm< T >::getTransform ( ) const
inline

Returns the rigid-body transformation produced by the most recent successful align() call.

Returns
A const reference to the \( (D+1) \times (D+1) \) transformation matrix (homogeneous form).

The documentation for this class was generated from the following file: