Eigen/src/Geometry/Scaling.h
Go to the documentation of this file.
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
5 //
6 // This Source Code Form is subject to the terms of the Mozilla
7 // Public License v. 2.0. If a copy of the MPL was not distributed
8 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 
10 #ifndef EIGEN_SCALING_H
11 #define EIGEN_SCALING_H
12 
13 namespace Eigen {
14 
32 template<typename _Scalar>
33 class UniformScaling
34 {
35 public:
37  typedef _Scalar Scalar;
38 
39 protected:
40 
41  Scalar m_factor;
42 
43 public:
44 
48  explicit inline UniformScaling(const Scalar& s) : m_factor(s) {}
49 
50  inline const Scalar& factor() const { return m_factor; }
51  inline Scalar& factor() { return m_factor; }
52 
54  inline UniformScaling operator* (const UniformScaling& other) const
55  { return UniformScaling(m_factor * other.factor()); }
56 
58  template<int Dim>
60 
62  template<int Dim, int Mode, int Options>
64  {
66  res.prescale(factor());
67  return res;
68  }
69 
71  // TODO returns an expression
72  template<typename Derived>
74  { return other * m_factor; }
75 
76  template<typename Derived,int Dim>
78  { return r.toRotationMatrix() * m_factor; }
79 
81  inline UniformScaling inverse() const
82  { return UniformScaling(Scalar(1)/m_factor); }
83 
89  template<typename NewScalarType>
91  { return UniformScaling<NewScalarType>(NewScalarType(m_factor)); }
92 
94  template<typename OtherScalarType>
95  inline explicit UniformScaling(const UniformScaling<OtherScalarType>& other)
96  { m_factor = Scalar(other.factor()); }
97 
102  bool isApprox(const UniformScaling& other, const typename NumTraits<Scalar>::Real& prec = NumTraits<Scalar>::dummy_precision()) const
103  { return internal::isApprox(m_factor, other.factor(), prec); }
104 
105 };
106 
109 
113 // NOTE this operator is defiend in MatrixBase and not as a friend function
114 // of UniformScaling to fix an internal crash of Intel's ICC
115 template<typename Derived,typename Scalar>
116 EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(Derived,Scalar,product)
117 operator*(const MatrixBase<Derived>& matrix, const UniformScaling<Scalar>& s)
118 { return matrix.derived() * s.factor(); }
119 
125 template<typename RealScalar>
126 inline UniformScaling<std::complex<RealScalar> > Scaling(const std::complex<RealScalar>& s)
128 
130 template<typename Scalar>
131 inline DiagonalMatrix<Scalar,2> Scaling(const Scalar& sx, const Scalar& sy)
132 { return DiagonalMatrix<Scalar,2>(sx, sy); }
134 template<typename Scalar>
135 inline DiagonalMatrix<Scalar,3> Scaling(const Scalar& sx, const Scalar& sy, const Scalar& sz)
136 { return DiagonalMatrix<Scalar,3>(sx, sy, sz); }
137 
141 template<typename Derived>
143 { return coeffs.asDiagonal(); }
144 
154 
155 template<typename Scalar>
156 template<int Dim>
159 {
161  res.matrix().setZero();
162  res.linear().diagonal().fill(factor());
163  res.translation() = factor() * t.vector();
164  res(Dim,Dim) = Scalar(1);
165  return res;
166 }
167 
168 } // end namespace Eigen
169 
170 #endif // EIGEN_SCALING_H
EIGEN_DEVICE_FUNC RotationMatrixType toRotationMatrix() const
Definition: RotationBase.h:45
bool isApprox(const UniformScaling &other, const typename NumTraits< Scalar >::Real &prec=NumTraits< Scalar >::dummy_precision()) const
UniformScaling operator*(const UniformScaling &other) const
DiagonalMatrix< float, 3 > AlignedScaling3f
DiagonalMatrix< float, 2 > AlignedScaling2f
Matrix< Scalar, Dim, Dim > operator*(const RotationBase< Derived, Dim > &r) const
Represents a diagonal matrix with its storage.
const Scalar & factor() const
Definition: LDLT.h:16
EIGEN_DEVICE_FUNC const VectorType & vector() const
Definition: Translation.h:87
DiagonalMatrix< double, 3 > AlignedScaling3d
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
Definition: NumTraits.h:150
EIGEN_DEVICE_FUNC ConstTranslationPart translation() const
Definition: Transform.h:410
UniformScaling< float > Scaling(float s)
Represents a translation transformation.
UniformScaling< NewScalarType > cast() const
UniformScaling(const UniformScaling< OtherScalarType > &other)
UniformScaling inverse() const
EIGEN_DEVICE_FUNC const MatrixType & matrix() const
Definition: Transform.h:395
EIGEN_DEVICE_FUNC Transform & prescale(const MatrixBase< OtherDerived > &other)
Common base class for compact rotation representations.
DiagonalMatrix< double, 2 > AlignedScaling2d
EIGEN_DEVICE_FUNC ConstLinearPart linear() const
Definition: Transform.h:400
Expression of a diagonal matrix.
const EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(Derived, typename Derived::Scalar, pow) pow(const Eigen
EIGEN_DEVICE_FUNC const DiagonalWrapper< const Derived > asDiagonal() const
The matrix class, also used for vectors and row-vectors.
Definition: Matrix.h:178
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:48
Represents an homogeneous transformation in a N dimensional space.


hebiros
Author(s): Xavier Artache , Matthew Tesch
autogenerated on Thu Sep 3 2020 04:08:44