Shapeworks Studio  2.1
Shape analysis software suite
Classes | Modules | Typedefs | Functions
Geometry_Module
+ Collaboration diagram for Geometry_Module:

Classes

class  Eigen::Map< const Quaternion< _Scalar >, _Options >
 Quaternion expression mapping a constant memory buffer. More...
 
class  Eigen::Map< Quaternion< _Scalar >, _Options >
 Expression of a quaternion from a memory buffer. More...
 
class  Eigen::AlignedBox< _Scalar, _AmbientDim >
 An axis aligned box. More...
 
class  Eigen::AngleAxis< _Scalar >
 Represents a 3D rotation as a rotation angle around an arbitrary 3D axis. More...
 
class  Eigen::Hyperplane< _Scalar, _AmbientDim >
 A hyperplane. More...
 
class  Eigen::ParametrizedLine< _Scalar, _AmbientDim >
 A parametrized line. More...
 
class  Eigen::Quaternion< _Scalar >
 The quaternion class used to represent 3D orientations and rotations. More...
 
class  Eigen::Rotation2D< _Scalar >
 Represents a rotation/orientation in a 2 dimensional space. More...
 
class  Eigen::Scaling< _Scalar, _Dim >
 Represents a possibly non uniform scaling transformation. More...
 
class  Eigen::Transform< _Scalar, _Dim >
 Represents an homogeneous transformation in a N dimensional space. More...
 
class  Eigen::Translation< _Scalar, _Dim >
 Represents a translation transformation. More...
 
class  Eigen::Homogeneous< MatrixType, _Direction >
 Expression of one (or a set of) homogeneous vector(s) More...
 
class  Eigen::QuaternionBase< Derived >
 Base class for quaternion expressions. More...
 

Modules

 Global aligned box typedefs
 

Typedefs

typedef AngleAxis< float > Eigen::AngleAxisf
 
typedef AngleAxis< double > Eigen::AngleAxisd
 
typedef Quaternion< float > Eigen::Quaternionf
 
typedef Quaternion< double > Eigen::Quaterniond
 
typedef Rotation2D< float > Eigen::Rotation2Df
 
typedef Rotation2D< double > Eigen::Rotation2Dd
 
typedef Scaling< float, 2 > Eigen::Scaling2f
 
typedef Scaling< double, 2 > Eigen::Scaling2d
 
typedef Scaling< float, 3 > Eigen::Scaling3f
 
typedef Scaling< double, 3 > Eigen::Scaling3d
 
typedef Transform< float, 2 > Eigen::Transform2f
 
typedef Transform< float, 3 > Eigen::Transform3f
 
typedef Transform< double, 2 > Eigen::Transform2d
 
typedef Transform< double, 3 > Eigen::Transform3d
 
typedef Translation< float, 2 > Eigen::Translation2f
 
typedef Translation< double, 2 > Eigen::Translation2d
 
typedef Translation< float, 3 > Eigen::Translation3f
 
typedef Translation< double, 3 > Eigen::Translation3d
 
typedef Map< Quaternion< float >, 0 > Eigen::QuaternionMapf
 
typedef Map< Quaternion< double >, 0 > Eigen::QuaternionMapd
 
typedef Map< Quaternion< float >, Aligned > Eigen::QuaternionMapAlignedf
 
typedef Map< Quaternion< double >, Aligned > Eigen::QuaternionMapAlignedd
 
typedef DiagonalMatrix< float, 2 > Eigen::AlignedScaling2f
 
typedef DiagonalMatrix< double, 2 > Eigen::AlignedScaling2d
 
typedef DiagonalMatrix< float, 3 > Eigen::AlignedScaling3f
 
typedef DiagonalMatrix< double, 3 > Eigen::AlignedScaling3d
 
typedef Transform< float, 2, Isometry > Eigen::Isometry2f
 
typedef Transform< float, 3, Isometry > Eigen::Isometry3f
 
typedef Transform< double, 2, Isometry > Eigen::Isometry2d
 
typedef Transform< double, 3, Isometry > Eigen::Isometry3d
 
typedef Transform< float, 2, Affine > Eigen::Affine2f
 
typedef Transform< float, 3, Affine > Eigen::Affine3f
 
typedef Transform< double, 2, Affine > Eigen::Affine2d
 
typedef Transform< double, 3, Affine > Eigen::Affine3d
 
typedef Transform< float, 2, AffineCompact > Eigen::AffineCompact2f
 
typedef Transform< float, 3, AffineCompact > Eigen::AffineCompact3f
 
typedef Transform< double, 2, AffineCompact > Eigen::AffineCompact2d
 
typedef Transform< double, 3, AffineCompact > Eigen::AffineCompact3d
 
typedef Transform< float, 2, Projective > Eigen::Projective2f
 
typedef Transform< float, 3, Projective > Eigen::Projective3f
 
typedef Transform< double, 2, Projective > Eigen::Projective2d
 
typedef Transform< double, 3, Projective > Eigen::Projective3d
 

Functions

template<typename Derived , typename OtherDerived >
internal::umeyama_transform_matrix_type< Derived, OtherDerived >::type Eigen::umeyama (const MatrixBase< Derived > &src, const MatrixBase< OtherDerived > &dst, bool with_scaling=true)
 Returns the transformation between two point sets. More...
 
Matrix< Scalar, 3, 1 > Eigen::MatrixBase< Derived >::eulerAngles (Index a0, Index a1, Index a2) const
 

Detailed Description

Typedef Documentation

typedef Transform<double,2,Affine> Eigen::Affine2d

Definition at line 656 of file Transform.h.

typedef Transform<float,2,Affine> Eigen::Affine2f

Definition at line 652 of file Transform.h.

typedef Transform<double,3,Affine> Eigen::Affine3d

Definition at line 658 of file Transform.h.

typedef Transform<float,3,Affine> Eigen::Affine3f

Definition at line 654 of file Transform.h.

typedef Transform<double,2,AffineCompact> Eigen::AffineCompact2d

Definition at line 665 of file Transform.h.

typedef Transform<float,2,AffineCompact> Eigen::AffineCompact2f

Definition at line 661 of file Transform.h.

typedef Transform<double,3,AffineCompact> Eigen::AffineCompact3d

Definition at line 667 of file Transform.h.

typedef Transform<float,3,AffineCompact> Eigen::AffineCompact3f

Definition at line 663 of file Transform.h.

typedef DiagonalMatrix<double,2> Eigen::AlignedScaling2d
Deprecated:

Definition at line 144 of file Scaling.h.

typedef DiagonalMatrix<float, 2> Eigen::AlignedScaling2f
Deprecated:

Definition at line 142 of file Scaling.h.

typedef DiagonalMatrix<double,3> Eigen::AlignedScaling3d
Deprecated:

Definition at line 148 of file Scaling.h.

typedef DiagonalMatrix<float, 3> Eigen::AlignedScaling3f
Deprecated:

Definition at line 146 of file Scaling.h.

typedef AngleAxis< double > Eigen::AngleAxisd

double precision angle-axis type

Definition at line 152 of file AngleAxis.h.

typedef AngleAxis< float > Eigen::AngleAxisf

single precision angle-axis type

Definition at line 149 of file AngleAxis.h.

typedef Transform<double,2,Isometry> Eigen::Isometry2d

Definition at line 647 of file Transform.h.

typedef Transform<float,2,Isometry> Eigen::Isometry2f

Definition at line 643 of file Transform.h.

typedef Transform<double,3,Isometry> Eigen::Isometry3d

Definition at line 649 of file Transform.h.

typedef Transform<float,3,Isometry> Eigen::Isometry3f

Definition at line 645 of file Transform.h.

typedef Transform<double,2,Projective> Eigen::Projective2d

Definition at line 674 of file Transform.h.

typedef Transform<float,2,Projective> Eigen::Projective2f

Definition at line 670 of file Transform.h.

typedef Transform<double,3,Projective> Eigen::Projective3d

Definition at line 676 of file Transform.h.

typedef Transform<float,3,Projective> Eigen::Projective3f

Definition at line 672 of file Transform.h.

typedef Quaternion< double > Eigen::Quaterniond

double precision quaternion type

Definition at line 211 of file Quaternion.h.

typedef Quaternion< float > Eigen::Quaternionf

single precision quaternion type

Definition at line 208 of file Quaternion.h.

typedef Map<Quaternion<double>, Aligned> Eigen::QuaternionMapAlignedd

Map a 16-bits aligned array of double precision scalars as a quaternion

Definition at line 412 of file Quaternion.h.

typedef Map<Quaternion<float>, Aligned> Eigen::QuaternionMapAlignedf

Map a 16-bits aligned array of double precision scalars as a quaternion

Definition at line 409 of file Quaternion.h.

typedef Map<Quaternion<double>, 0> Eigen::QuaternionMapd

Map an unaligned array of double precision scalar as a quaternion

Definition at line 406 of file Quaternion.h.

typedef Map<Quaternion<float>, 0> Eigen::QuaternionMapf

Map an unaligned array of single precision scalar as a quaternion

Definition at line 403 of file Quaternion.h.

typedef Rotation2D< double > Eigen::Rotation2Dd

double precision 2D rotation type

Definition at line 119 of file Rotation2D.h.

typedef Rotation2D< float > Eigen::Rotation2Df

single precision 2D rotation type

Definition at line 116 of file Rotation2D.h.

typedef Transform<double,2> Eigen::Transform2d

Definition at line 286 of file Transform.h.

typedef Transform<float,2> Eigen::Transform2f

Definition at line 282 of file Transform.h.

typedef Transform<double,3> Eigen::Transform3d

Definition at line 288 of file Transform.h.

typedef Transform<float,3> Eigen::Transform3f

Definition at line 284 of file Transform.h.

Function Documentation

template<typename Derived >
Matrix< typename MatrixBase< Derived >::Scalar, 3, 1 > Eigen::MatrixBase< Derived >::eulerAngles ( Index  a0,
Index  a1,
Index  a2 
) const
inline
Returns
the Euler-angles of the rotation matrix *this using the convention defined by the triplet (a0,a1,a2)

Each of the three parameters a0,a1,a2 represents the respective rotation axis as an integer in {0,1,2}. For instance, in:

Vector3f ea = mat.eulerAngles(2, 0, 2);

"2" represents the z axis and "0" the x axis, etc. The returned angles are such that we have the following equality:

mat == AngleAxisf(ea[0], Vector3f::UnitZ())
* AngleAxisf(ea[1], Vector3f::UnitX())
* AngleAxisf(ea[2], Vector3f::UnitZ());

This corresponds to the right-multiply conventions (with right hand side frames).

The returned angles are in the ranges [0:pi]x[0:pi]x[-pi:pi].

See also
class AngleAxis

Definition at line 37 of file EulerAngles.h.

38 {
39  using std::atan2;
40  using std::sin;
41  using std::cos;
42  /* Implemented from Graphics Gems IV */
43  EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(Derived,3,3)
44 
45  Matrix<Scalar,3,1> res;
46  typedef Matrix<typename Derived::Scalar,2,1> Vector2;
47 
48  const Index odd = ((a0+1)%3 == a1) ? 0 : 1;
49  const Index i = a0;
50  const Index j = (a0 + 1 + odd)%3;
51  const Index k = (a0 + 2 - odd)%3;
52 
53  if (a0==a2)
54  {
55  res[0] = atan2(coeff(j,i), coeff(k,i));
56  if((odd && res[0]<Scalar(0)) || ((!odd) && res[0]>Scalar(0)))
57  {
58  res[0] = (res[0] > Scalar(0)) ? res[0] - Scalar(M_PI) : res[0] + Scalar(M_PI);
59  Scalar s2 = Vector2(coeff(j,i), coeff(k,i)).norm();
60  res[1] = -atan2(s2, coeff(i,i));
61  }
62  else
63  {
64  Scalar s2 = Vector2(coeff(j,i), coeff(k,i)).norm();
65  res[1] = atan2(s2, coeff(i,i));
66  }
67 
68  // With a=(0,1,0), we have i=0; j=1; k=2, and after computing the first two angles,
69  // we can compute their respective rotation, and apply its inverse to M. Since the result must
70  // be a rotation around x, we have:
71  //
72  // c2 s1.s2 c1.s2 1 0 0
73  // 0 c1 -s1 * M = 0 c3 s3
74  // -s2 s1.c2 c1.c2 0 -s3 c3
75  //
76  // Thus: m11.c1 - m21.s1 = c3 & m12.c1 - m22.s1 = s3
77 
78  Scalar s1 = sin(res[0]);
79  Scalar c1 = cos(res[0]);
80  res[2] = atan2(c1*coeff(j,k)-s1*coeff(k,k), c1*coeff(j,j) - s1 * coeff(k,j));
81  }
82  else
83  {
84  res[0] = atan2(coeff(j,k), coeff(k,k));
85  Scalar c2 = Vector2(coeff(i,i), coeff(i,j)).norm();
86  if((odd && res[0]<Scalar(0)) || ((!odd) && res[0]>Scalar(0))) {
87  res[0] = (res[0] > Scalar(0)) ? res[0] - Scalar(M_PI) : res[0] + Scalar(M_PI);
88  res[1] = atan2(-coeff(i,k), -c2);
89  }
90  else
91  res[1] = atan2(-coeff(i,k), c2);
92  Scalar s1 = sin(res[0]);
93  Scalar c1 = cos(res[0]);
94  res[2] = atan2(s1*coeff(k,i)-c1*coeff(j,i), c1*coeff(j,j) - s1 * coeff(k,j));
95  }
96  if (!odd)
97  res = -res;
98 
99  return res;
100 }
template<typename Derived , typename OtherDerived >
internal::umeyama_transform_matrix_type<Derived, OtherDerived>::type Eigen::umeyama ( const MatrixBase< Derived > &  src,
const MatrixBase< OtherDerived > &  dst,
bool  with_scaling = true 
)

Returns the transformation between two point sets.

The algorithm is based on: "Least-squares estimation of transformation parameters between two point patterns", Shinji Umeyama, PAMI 1991, DOI: 10.1109/34.88573

It estimates parameters $ c, \mathbf{R}, $ and $ \mathbf{t} $ such that

\begin{align*} \frac{1}{n} \sum_{i=1}^n \vert\vert y_i - (c\mathbf{R}x_i + \mathbf{t}) \vert\vert_2^2 \end{align*}

is minimized.

The algorithm is based on the analysis of the covariance matrix $ \Sigma_{\mathbf{x}\mathbf{y}} \in \mathbb{R}^{d \times d} $ of the input point sets $ \mathbf{x} $ and $ \mathbf{y} $ where $d$ is corresponding to the dimension (which is typically small). The analysis is involving the SVD having a complexity of $O(d^3)$ though the actual computational effort lies in the covariance matrix computation which has an asymptotic lower bound of $O(dm)$ when the input point sets have dimension $d \times m$.

Currently the method is working only for floating point matrices.

Todo:
Should the return type of umeyama() become a Transform?
Parameters
srcSource points $ \mathbf{x} = \left( x_1, \hdots, x_n \right) $.
dstDestination points $ \mathbf{y} = \left( y_1, \hdots, y_n \right) $.
with_scalingSets $ c=1 $ when false is passed.
Returns
The homogeneous transformation

\begin{align*} T = \begin{bmatrix} c\mathbf{R} & \mathbf{t} \\ \mathbf{0} & 1 \end{bmatrix} \end{align*}

minimizing the resudiual above. This transformation is always returned as an Eigen::Matrix.

Definition at line 95 of file Umeyama.h.

96 {
97  typedef typename internal::umeyama_transform_matrix_type<Derived, OtherDerived>::type TransformationMatrixType;
98  typedef typename internal::traits<TransformationMatrixType>::Scalar Scalar;
99  typedef typename NumTraits<Scalar>::Real RealScalar;
100  typedef typename Derived::Index Index;
101 
102  EIGEN_STATIC_ASSERT(!NumTraits<Scalar>::IsComplex, NUMERIC_TYPE_MUST_BE_REAL)
103  EIGEN_STATIC_ASSERT((internal::is_same<Scalar, typename internal::traits<OtherDerived>::Scalar>::value),
104  YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)
105 
106  enum { Dimension = EIGEN_SIZE_MIN_PREFER_DYNAMIC(Derived::RowsAtCompileTime, OtherDerived::RowsAtCompileTime) };
107 
108  typedef Matrix<Scalar, Dimension, 1> VectorType;
109  typedef Matrix<Scalar, Dimension, Dimension> MatrixType;
110  typedef typename internal::plain_matrix_type_row_major<Derived>::type RowMajorMatrixType;
111 
112  const Index m = src.rows(); // dimension
113  const Index n = src.cols(); // number of measurements
114 
115  // required for demeaning ...
116  const RealScalar one_over_n = 1 / static_cast<RealScalar>(n);
117 
118  // computation of mean
119  const VectorType src_mean = src.rowwise().sum() * one_over_n;
120  const VectorType dst_mean = dst.rowwise().sum() * one_over_n;
121 
122  // demeaning of src and dst points
123  const RowMajorMatrixType src_demean = src.colwise() - src_mean;
124  const RowMajorMatrixType dst_demean = dst.colwise() - dst_mean;
125 
126  // Eq. (36)-(37)
127  const Scalar src_var = src_demean.rowwise().squaredNorm().sum() * one_over_n;
128 
129  // Eq. (38)
130  const MatrixType sigma = one_over_n * dst_demean * src_demean.transpose();
131 
132  JacobiSVD<MatrixType> svd(sigma, ComputeFullU | ComputeFullV);
133 
134  // Initialize the resulting transformation with an identity matrix...
135  TransformationMatrixType Rt = TransformationMatrixType::Identity(m+1,m+1);
136 
137  // Eq. (39)
138  VectorType S = VectorType::Ones(m);
139  if (sigma.determinant()<0) S(m-1) = -1;
140 
141  // Eq. (40) and (43)
142  const VectorType& d = svd.singularValues();
143  Index rank = 0; for (Index i=0; i<m; ++i) if (!internal::isMuchSmallerThan(d.coeff(i),d.coeff(0))) ++rank;
144  if (rank == m-1) {
145  if ( svd.matrixU().determinant() * svd.matrixV().determinant() > 0 ) {
146  Rt.block(0,0,m,m).noalias() = svd.matrixU()*svd.matrixV().transpose();
147  } else {
148  const Scalar s = S(m-1); S(m-1) = -1;
149  Rt.block(0,0,m,m).noalias() = svd.matrixU() * S.asDiagonal() * svd.matrixV().transpose();
150  S(m-1) = s;
151  }
152  } else {
153  Rt.block(0,0,m,m).noalias() = svd.matrixU() * S.asDiagonal() * svd.matrixV().transpose();
154  }
155 
156  if (with_scaling)
157  {
158  // Eq. (42)
159  const Scalar c = 1/src_var * svd.singularValues().dot(S);
160 
161  // Eq. (41)
162  Rt.col(m).head(m) = dst_mean;
163  Rt.col(m).head(m).noalias() -= c*Rt.topLeftCorner(m,m)*src_mean;
164  Rt.block(0,0,m,m) *= c;
165  }
166  else
167  {
168  Rt.col(m).head(m) = dst_mean;
169  Rt.col(m).head(m).noalias() -= Rt.topLeftCorner(m,m)*src_mean;
170  }
171 
172  return Rt;
173 }