mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-09-25 07:43:14 +08:00
* add Transform explicit constructors taking translation/scaling/rotation
* add Transform::operator= taking rotation. An old remnant was left commented out. Why was it disabled? * slight optimization in operator= taking translation * slight optimization (perhaps) in the new memory assertion
This commit is contained in:
parent
6700f07fb0
commit
09fd69d734
@ -40,7 +40,7 @@ template <typename T, int Size, bool Align> struct ei_aligned_array
|
|||||||
|
|
||||||
ei_aligned_array()
|
ei_aligned_array()
|
||||||
{
|
{
|
||||||
ei_assert(reinterpret_cast<unsigned int>(array)%16 == 0
|
ei_assert((reinterpret_cast<unsigned int>(array) & 0xf) == 0
|
||||||
&& "this assertion is explained here: http://eigen.tuxfamily.org/api/UnalignedArrayAssert.html **** READ THIS WEB PAGE !!! ****");
|
&& "this assertion is explained here: http://eigen.tuxfamily.org/api/UnalignedArrayAssert.html **** READ THIS WEB PAGE !!! ****");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -100,6 +100,11 @@ public:
|
|||||||
inline Transform(const Transform& other)
|
inline Transform(const Transform& other)
|
||||||
{ m_matrix = other.m_matrix; }
|
{ m_matrix = other.m_matrix; }
|
||||||
|
|
||||||
|
inline explicit Transform(const TranslationType& t) { *this = t; }
|
||||||
|
inline explicit Transform(const ScalingType& s) { *this = s; }
|
||||||
|
template<typename Derived>
|
||||||
|
inline explicit Transform(const RotationBase<Derived, Dim>& r) { *this = r; }
|
||||||
|
|
||||||
inline Transform& operator=(const Transform& other)
|
inline Transform& operator=(const Transform& other)
|
||||||
{ m_matrix = other.m_matrix; return *this; }
|
{ m_matrix = other.m_matrix; return *this; }
|
||||||
|
|
||||||
@ -226,8 +231,8 @@ public:
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
// template<typename Derived>
|
template<typename Derived>
|
||||||
// inline Transform& operator=(const Rotation<Derived,Dim>& t);
|
inline Transform& operator=(const RotationBase<Derived,Dim>& r);
|
||||||
template<typename Derived>
|
template<typename Derived>
|
||||||
inline Transform& operator*=(const RotationBase<Derived,Dim>& r) { return rotate(r.toRotationMatrix()); }
|
inline Transform& operator*=(const RotationBase<Derived,Dim>& r) { return rotate(r.toRotationMatrix()); }
|
||||||
template<typename Derived>
|
template<typename Derived>
|
||||||
@ -523,8 +528,10 @@ Transform<Scalar,Dim>::preshear(Scalar sx, Scalar sy)
|
|||||||
template<typename Scalar, int Dim>
|
template<typename Scalar, int Dim>
|
||||||
inline Transform<Scalar,Dim>& Transform<Scalar,Dim>::operator=(const TranslationType& t)
|
inline Transform<Scalar,Dim>& Transform<Scalar,Dim>::operator=(const TranslationType& t)
|
||||||
{
|
{
|
||||||
setIdentity();
|
linear().setIdentity;
|
||||||
translation() = t.vector();
|
translation() = t.vector();
|
||||||
|
m_matrix.template block<1,Dim>(Dim,0).setZero();
|
||||||
|
m_matrix(Dim,Dim) = Scalar(1);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -553,6 +560,17 @@ inline Transform<Scalar,Dim> Transform<Scalar,Dim>::operator*(const ScalingType&
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename Scalar, int Dim>
|
||||||
|
template<typename Derived>
|
||||||
|
inline Transform<Scalar,Dim>& Transform<Scalar,Dim>::operator=(const RotationBase<Derived,Dim>& r)
|
||||||
|
{
|
||||||
|
linear() = ei_toRotationMatrix<Scalar,Dim>(r);
|
||||||
|
translation().setZero();
|
||||||
|
m_matrix.template block<1,Dim>(Dim,0).setZero();
|
||||||
|
m_matrix(Dim,Dim) = Scalar(1);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
template<typename Scalar, int Dim>
|
template<typename Scalar, int Dim>
|
||||||
template<typename Derived>
|
template<typename Derived>
|
||||||
inline Transform<Scalar,Dim> Transform<Scalar,Dim>::operator*(const RotationBase<Derived,Dim>& r) const
|
inline Transform<Scalar,Dim> Transform<Scalar,Dim>::operator*(const RotationBase<Derived,Dim>& r) const
|
||||||
@ -617,8 +635,8 @@ Transform<Scalar,Dim>::fromPositionOrientationScale(const MatrixBase<PositionDer
|
|||||||
linear() = ei_toRotationMatrix<Scalar,Dim>(orientation);
|
linear() = ei_toRotationMatrix<Scalar,Dim>(orientation);
|
||||||
linear() *= scale.asDiagonal();
|
linear() *= scale.asDiagonal();
|
||||||
translation() = position;
|
translation() = position;
|
||||||
m_matrix(Dim,Dim) = 1.;
|
|
||||||
m_matrix.template block<1,Dim>(Dim,0).setZero();
|
m_matrix.template block<1,Dim>(Dim,0).setZero();
|
||||||
|
m_matrix(Dim,Dim) = Scalar(1);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user