1c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// This file is part of Eigen, a lightweight C++ template library
2c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// for linear algebra.
3c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath//
4c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
5c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath//
6c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// This Source Code Form is subject to the terms of the Mozilla
7c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// Public License v. 2.0. If a copy of the MPL was not distributed
8c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
10c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath#ifndef EIGEN_TRANSLATION_H
11c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath#define EIGEN_TRANSLATION_H
12c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
13c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathnamespace Eigen {
14c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
15c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** \geometry_module \ingroup Geometry_Module
16c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
17c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \class Translation
18c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
19c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \brief Represents a translation transformation
20c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
21c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \param _Scalar the scalar type, i.e., the type of the coefficients.
22c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \param _Dim the  dimension of the space, can be a compile time value or Dynamic
23c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
24c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \note This class is not aimed to be used to store a translation transformation,
25c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * but rather to make easier the constructions and updates of Transform objects.
26c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
27c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \sa class Scaling, class Transform
28c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  */
29c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<typename _Scalar, int _Dim>
30c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathclass Translation
31c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
32c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathpublic:
33c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(_Scalar,_Dim)
34c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  /** dimension of the space */
35c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  enum { Dim = _Dim };
36c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  /** the scalar type of the coefficients */
37c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  typedef _Scalar Scalar;
38c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  /** corresponding vector type */
39c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  typedef Matrix<Scalar,Dim,1> VectorType;
40c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  /** corresponding linear transformation matrix type */
41c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  typedef Matrix<Scalar,Dim,Dim> LinearMatrixType;
42c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  /** corresponding affine transformation type */
43c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  typedef Transform<Scalar,Dim,Affine> AffineTransformType;
44c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  /** corresponding isometric transformation type */
45c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  typedef Transform<Scalar,Dim,Isometry> IsometryTransformType;
46c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
47c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathprotected:
48c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
49c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  VectorType m_coeffs;
50c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
51c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathpublic:
52c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
53c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  /** Default constructor without initialization. */
54c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  Translation() {}
55c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  /**  */
56c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  inline Translation(const Scalar& sx, const Scalar& sy)
57c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  {
58c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath    eigen_assert(Dim==2);
59c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath    m_coeffs.x() = sx;
60c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath    m_coeffs.y() = sy;
61c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  }
62c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  /**  */
63c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  inline Translation(const Scalar& sx, const Scalar& sy, const Scalar& sz)
64c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  {
65c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath    eigen_assert(Dim==3);
66c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath    m_coeffs.x() = sx;
67c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath    m_coeffs.y() = sy;
68c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath    m_coeffs.z() = sz;
69c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  }
70c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  /** Constructs and initialize the translation transformation from a vector of translation coefficients */
71c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  explicit inline Translation(const VectorType& vector) : m_coeffs(vector) {}
72c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
73c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  /** \brief Retruns the x-translation by value. **/
74c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  inline Scalar x() const { return m_coeffs.x(); }
75c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  /** \brief Retruns the y-translation by value. **/
76c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  inline Scalar y() const { return m_coeffs.y(); }
77c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  /** \brief Retruns the z-translation by value. **/
78c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  inline Scalar z() const { return m_coeffs.z(); }
79c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
80c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  /** \brief Retruns the x-translation as a reference. **/
81c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  inline Scalar& x() { return m_coeffs.x(); }
82c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  /** \brief Retruns the y-translation as a reference. **/
83c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  inline Scalar& y() { return m_coeffs.y(); }
84c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  /** \brief Retruns the z-translation as a reference. **/
85c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  inline Scalar& z() { return m_coeffs.z(); }
86c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
87c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  const VectorType& vector() const { return m_coeffs; }
88c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  VectorType& vector() { return m_coeffs; }
89c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
90c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  const VectorType& translation() const { return m_coeffs; }
91c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  VectorType& translation() { return m_coeffs; }
92c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
93c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  /** Concatenates two translation */
94c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  inline Translation operator* (const Translation& other) const
95c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  { return Translation(m_coeffs + other.m_coeffs); }
96c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
97c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  /** Concatenates a translation and a uniform scaling */
98c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  inline AffineTransformType operator* (const UniformScaling<Scalar>& other) const;
99c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
100c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  /** Concatenates a translation and a linear transformation */
101c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  template<typename OtherDerived>
102c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  inline AffineTransformType operator* (const EigenBase<OtherDerived>& linear) const;
103c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
104c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  /** Concatenates a translation and a rotation */
105c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  template<typename Derived>
106c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  inline IsometryTransformType operator*(const RotationBase<Derived,Dim>& r) const
107c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  { return *this * IsometryTransformType(r); }
108c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
109c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  /** \returns the concatenation of a linear transformation \a l with the translation \a t */
110c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  // its a nightmare to define a templated friend function outside its declaration
111c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  template<typename OtherDerived> friend
112c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  inline AffineTransformType operator*(const EigenBase<OtherDerived>& linear, const Translation& t)
113c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  {
114c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath    AffineTransformType res;
115c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath    res.matrix().setZero();
116c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath    res.linear() = linear.derived();
117c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath    res.translation() = linear.derived() * t.m_coeffs;
118c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath    res.matrix().row(Dim).setZero();
119c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath    res(Dim,Dim) = Scalar(1);
120c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath    return res;
121c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  }
122c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
123c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  /** Concatenates a translation and a transformation */
124c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  template<int Mode, int Options>
125c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  inline Transform<Scalar,Dim,Mode> operator* (const Transform<Scalar,Dim,Mode,Options>& t) const
126c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  {
127c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath    Transform<Scalar,Dim,Mode> res = t;
128c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath    res.pretranslate(m_coeffs);
129c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath    return res;
130c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  }
131c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
132c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  /** Applies translation to vector */
133c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  inline VectorType operator* (const VectorType& other) const
134c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  { return m_coeffs + other; }
135c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
136c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  /** \returns the inverse translation (opposite) */
137c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  Translation inverse() const { return Translation(-m_coeffs); }
138c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
139c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  Translation& operator=(const Translation& other)
140c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  {
141c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath    m_coeffs = other.m_coeffs;
142c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath    return *this;
143c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  }
144c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
145c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  static const Translation Identity() { return Translation(VectorType::Zero()); }
146c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
147c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  /** \returns \c *this with scalar type casted to \a NewScalarType
148c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath    *
149c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath    * Note that if \a NewScalarType is equal to the current scalar type of \c *this
150c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath    * then this function smartly returns a const reference to \c *this.
151c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath    */
152c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  template<typename NewScalarType>
153c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  inline typename internal::cast_return_type<Translation,Translation<NewScalarType,Dim> >::type cast() const
154c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  { return typename internal::cast_return_type<Translation,Translation<NewScalarType,Dim> >::type(*this); }
155c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
156c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  /** Copy constructor with scalar type conversion */
157c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  template<typename OtherScalarType>
158c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  inline explicit Translation(const Translation<OtherScalarType,Dim>& other)
159c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  { m_coeffs = other.vector().template cast<Scalar>(); }
160c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
161c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  /** \returns \c true if \c *this is approximately equal to \a other, within the precision
162c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath    * determined by \a prec.
163c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath    *
164c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath    * \sa MatrixBase::isApprox() */
165c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  bool isApprox(const Translation& other, typename NumTraits<Scalar>::Real prec = NumTraits<Scalar>::dummy_precision()) const
166c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  { return m_coeffs.isApprox(other.m_coeffs, prec); }
167c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
168c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath};
169c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
170c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** \addtogroup Geometry_Module */
171c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath//@{
172c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtypedef Translation<float, 2> Translation2f;
173c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtypedef Translation<double,2> Translation2d;
174c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtypedef Translation<float, 3> Translation3f;
175c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtypedef Translation<double,3> Translation3d;
176c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath//@}
177c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
178c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<typename Scalar, int Dim>
179c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathinline typename Translation<Scalar,Dim>::AffineTransformType
180c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan KamathTranslation<Scalar,Dim>::operator* (const UniformScaling<Scalar>& other) const
181c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
182c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  AffineTransformType res;
183c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  res.matrix().setZero();
184c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  res.linear().diagonal().fill(other.factor());
185c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  res.translation() = m_coeffs;
186c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  res(Dim,Dim) = Scalar(1);
187c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  return res;
188c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
189c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
190c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<typename Scalar, int Dim>
191c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<typename OtherDerived>
192c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathinline typename Translation<Scalar,Dim>::AffineTransformType
193c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan KamathTranslation<Scalar,Dim>::operator* (const EigenBase<OtherDerived>& linear) const
194c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
195c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  AffineTransformType res;
196c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  res.matrix().setZero();
197c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  res.linear() = linear.derived();
198c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  res.translation() = m_coeffs;
199c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  res.matrix().row(Dim).setZero();
200c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  res(Dim,Dim) = Scalar(1);
201c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  return res;
202c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
203c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
204c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath} // end namespace Eigen
205c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
206c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath#endif // EIGEN_TRANSLATION_H
207