mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Big change in DiagonalMatrix and Geometry/Scaling:
* previous DiagonalMatrix expression is now DiagonalMatrixWrapper * DiagonalMatrix class is now for storage * add the DiagonalMatrixBase class to factorize code of the two previous classes * remove Scaling class (it is now a global function) * add UniformScaling helper class (don't use it directly, use the Scaling function) * add the Scaling global function to simplify the creation of scaling objects There is still a lot to do, in particular about DiagonalProduct for which the goal is to get rid of the "if()" in the coeff() function. At least it is not worse than before ! Also need to uptade the tutorial and add more doc.
This commit is contained in:
@@ -43,8 +43,8 @@ template<typename Scalar> void geometry(void)
|
||||
typedef AngleAxis<Scalar> AngleAxisx;
|
||||
typedef Transform<Scalar,2> Transform2;
|
||||
typedef Transform<Scalar,3> Transform3;
|
||||
typedef Scaling<Scalar,2> Scaling2;
|
||||
typedef Scaling<Scalar,3> Scaling3;
|
||||
typedef DiagonalMatrix<Scalar,2> AlignedScaling2;
|
||||
typedef DiagonalMatrix<Scalar,3> AlignedScaling3;
|
||||
typedef Translation<Scalar,2> Translation2;
|
||||
typedef Translation<Scalar,3> Translation3;
|
||||
|
||||
@@ -220,7 +220,7 @@ template<typename Scalar> void geometry(void)
|
||||
t4 *= tv3;
|
||||
VERIFY_IS_APPROX(t5.matrix(), t4.matrix());
|
||||
|
||||
Scaling3 sv3(v3);
|
||||
AlignedScaling3 sv3(v3);
|
||||
Transform3 t6(sv3);
|
||||
t4 = sv3;
|
||||
VERIFY_IS_APPROX(t6.matrix(), t4.matrix());
|
||||
@@ -260,30 +260,34 @@ template<typename Scalar> void geometry(void)
|
||||
// 3D
|
||||
t0.setIdentity();
|
||||
t0.rotate(q1).scale(v0).translate(v0);
|
||||
// mat * scaling and mat * translation
|
||||
t1 = (Matrix3(q1) * Scaling3(v0)) * Translation3(v0);
|
||||
// mat * aligned scaling and mat * translation
|
||||
t1 = (Matrix3(q1) * AlignedScaling3(v0)) * Translation3(v0);
|
||||
VERIFY_IS_APPROX(t0.matrix(), t1.matrix());
|
||||
// mat * transformation and scaling * translation
|
||||
t1 = Matrix3(q1) * (Scaling3(v0) * Translation3(v0));
|
||||
t1 = (Matrix3(q1) * Scaling(v0)) * Translation3(v0);
|
||||
VERIFY_IS_APPROX(t0.matrix(), t1.matrix());
|
||||
t1 = (q1 * Scaling(v0)) * Translation3(v0);
|
||||
VERIFY_IS_APPROX(t0.matrix(), t1.matrix());
|
||||
// mat * transformation and aligned scaling * translation
|
||||
t1 = Matrix3(q1) * (AlignedScaling3(v0) * Translation3(v0));
|
||||
VERIFY_IS_APPROX(t0.matrix(), t1.matrix());
|
||||
|
||||
t0.setIdentity();
|
||||
t0.prerotate(q1).prescale(v0).pretranslate(v0);
|
||||
// translation * scaling and transformation * mat
|
||||
t1 = (Translation3(v0) * Scaling3(v0)) * Matrix3(q1);
|
||||
// translation * aligned scaling and transformation * mat
|
||||
t1 = (Translation3(v0) * AlignedScaling3(v0)) * Matrix3(q1);
|
||||
VERIFY_IS_APPROX(t0.matrix(), t1.matrix());
|
||||
// scaling * mat and translation * mat
|
||||
t1 = Translation3(v0) * (Scaling3(v0) * Matrix3(q1));
|
||||
t1 = Translation3(v0) * (AlignedScaling3(v0) * Matrix3(q1));
|
||||
VERIFY_IS_APPROX(t0.matrix(), t1.matrix());
|
||||
|
||||
t0.setIdentity();
|
||||
t0.scale(v0).translate(v0).rotate(q1);
|
||||
// translation * mat and scaling * transformation
|
||||
t1 = Scaling3(v0) * (Translation3(v0) * Matrix3(q1));
|
||||
// translation * mat and aligned scaling * transformation
|
||||
t1 = AlignedScaling3(v0) * (Translation3(v0) * Matrix3(q1));
|
||||
VERIFY_IS_APPROX(t0.matrix(), t1.matrix());
|
||||
// transformation * scaling
|
||||
// transformation * aligned scaling
|
||||
t0.scale(v0);
|
||||
t1 = t1 * Scaling3(v0);
|
||||
t1 = t1 * AlignedScaling3(v0);
|
||||
VERIFY_IS_APPROX(t0.matrix(), t1.matrix());
|
||||
// transformation * translation
|
||||
t0.translate(v0);
|
||||
@@ -304,9 +308,9 @@ template<typename Scalar> void geometry(void)
|
||||
t1 = t1 * (Translation3(v1) * q1);
|
||||
VERIFY_IS_APPROX(t0.matrix(), t1.matrix());
|
||||
|
||||
// scaling * quaternion
|
||||
// aligned scaling * quaternion
|
||||
t0.scale(v1).rotate(q1);
|
||||
t1 = t1 * (Scaling3(v1) * q1);
|
||||
t1 = t1 * (AlignedScaling3(v1) * q1);
|
||||
VERIFY_IS_APPROX(t0.matrix(), t1.matrix());
|
||||
|
||||
// quaternion * transform
|
||||
@@ -319,9 +323,9 @@ template<typename Scalar> void geometry(void)
|
||||
t1 = t1 * (q1 * Translation3(v1));
|
||||
VERIFY_IS_APPROX(t0.matrix(), t1.matrix());
|
||||
|
||||
// quaternion * scaling
|
||||
// quaternion * aligned scaling
|
||||
t0.rotate(q1).scale(v1);
|
||||
t1 = t1 * (q1 * Scaling3(v1));
|
||||
t1 = t1 * (q1 * AlignedScaling3(v1));
|
||||
VERIFY_IS_APPROX(t0.matrix(), t1.matrix());
|
||||
|
||||
// translation * vector
|
||||
@@ -329,10 +333,10 @@ template<typename Scalar> void geometry(void)
|
||||
t0.translate(v0);
|
||||
VERIFY_IS_APPROX(t0 * v1, Translation3(v0) * v1);
|
||||
|
||||
// scaling * vector
|
||||
// AlignedScaling * vector
|
||||
t0.setIdentity();
|
||||
t0.scale(v0);
|
||||
VERIFY_IS_APPROX(t0 * v1, Scaling3(v0) * v1);
|
||||
VERIFY_IS_APPROX(t0 * v1, AlignedScaling3(v0) * v1);
|
||||
|
||||
// test transform inversion
|
||||
t0.setIdentity();
|
||||
@@ -343,10 +347,10 @@ template<typename Scalar> void geometry(void)
|
||||
t0.translate(v0).rotate(q1);
|
||||
VERIFY_IS_APPROX(t0.inverse(Isometry), t0.matrix().inverse());
|
||||
|
||||
// test extract rotation and scaling
|
||||
t0.setIdentity();
|
||||
t0.translate(v0).rotate(q1).scale(v1);
|
||||
VERIFY_IS_APPROX(t0.rotation() * v1, Matrix3(q1) * v1);
|
||||
// test extract rotation and aligned scaling
|
||||
// t0.setIdentity();
|
||||
// t0.translate(v0).rotate(q1).scale(v1);
|
||||
// VERIFY_IS_APPROX(t0.rotation() * v1, Matrix3(q1) * v1);
|
||||
|
||||
Matrix3 mat_rotation, mat_scaling;
|
||||
t0.setIdentity();
|
||||
@@ -372,10 +376,10 @@ template<typename Scalar> void geometry(void)
|
||||
Translation<double,3> tr1d = tr1.template cast<double>();
|
||||
VERIFY_IS_APPROX(tr1d.template cast<Scalar>(),tr1);
|
||||
|
||||
Scaling3 sc1(v0);
|
||||
Scaling<float,3> sc1f = sc1.template cast<float>();
|
||||
AlignedScaling3 sc1(v0);
|
||||
DiagonalMatrix<float,3> sc1f; sc1f = sc1.template cast<float>();
|
||||
VERIFY_IS_APPROX(sc1f.template cast<Scalar>(),sc1);
|
||||
Scaling<double,3> sc1d = sc1.template cast<double>();
|
||||
DiagonalMatrix<double,3> sc1d; sc1d = (sc1.template cast<double>());
|
||||
VERIFY_IS_APPROX(sc1d.template cast<Scalar>(),sc1);
|
||||
|
||||
Quaternion<float> q1f = q1.template cast<float>();
|
||||
@@ -428,7 +432,6 @@ template<typename Scalar> void geometry(void)
|
||||
mcross = mat3.rowwise().cross(vec3);
|
||||
VERIFY_IS_APPROX(mcross.row(i), mat3.row(i).cross(vec3));
|
||||
|
||||
|
||||
}
|
||||
|
||||
void test_geometry()
|
||||
|
||||
Reference in New Issue
Block a user