mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-07-15 01:21:48 +08:00
Fix preshear transformation.
Fixes #2777. The `preshear` function seems to have always used an invalid constructor internally, and has been broken for a while. Fixed the implementation and added a test. (cherry picked from commit 45da84e21570bf70238cf489ad862b2f09242c5f)
This commit is contained in:
parent
b86ac5f1e7
commit
42b04a08c4
@ -985,7 +985,8 @@ Transform<Scalar,Dim,Mode,Options>::preshear(const Scalar& sx, const Scalar& sy)
|
|||||||
{
|
{
|
||||||
EIGEN_STATIC_ASSERT(int(Dim)==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
|
EIGEN_STATIC_ASSERT(int(Dim)==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
|
||||||
EIGEN_STATIC_ASSERT(Mode!=int(Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)
|
EIGEN_STATIC_ASSERT(Mode!=int(Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)
|
||||||
m_matrix.template block<Dim,HDim>(0,0) = LinearMatrixType(1, sx, sy, 1) * m_matrix.template block<Dim,HDim>(0,0);
|
m_matrix.template block<Dim, HDim>(0, 0) =
|
||||||
|
LinearMatrixType({{1, sy}, {sx, 1}}) * m_matrix.template block<Dim, HDim>(0, 0);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -276,6 +276,12 @@ template<typename Scalar, int Mode, int Options> void transformations()
|
|||||||
VERIFY( (t20.fromPositionOrientationScale(v20,a,v21)
|
VERIFY( (t20.fromPositionOrientationScale(v20,a,v21)
|
||||||
* (t21.prescale(v21.cwiseInverse()).translate(-v20))).matrix().isIdentity(test_precision<Scalar>()) );
|
* (t21.prescale(v21.cwiseInverse()).translate(-v20))).matrix().isIdentity(test_precision<Scalar>()) );
|
||||||
|
|
||||||
|
t20.setIdentity();
|
||||||
|
t20.shear(Scalar(2), Scalar(3));
|
||||||
|
Transform2 t23 = t20 * t21;
|
||||||
|
t21.preshear(Scalar(2), Scalar(3));
|
||||||
|
VERIFY_IS_APPROX(t21, t23);
|
||||||
|
|
||||||
// Transform - new API
|
// Transform - new API
|
||||||
// 3D
|
// 3D
|
||||||
t0.setIdentity();
|
t0.setIdentity();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user