X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fmath%2FSGMathTest.cxx;h=aeedc7a9629fafe5c3ccc44e4222825c3fa430eb;hb=dfea3623f6549c9173fed5149da41285863fc290;hp=3f0d5cc67fc136fc3d9b456522885cf471f052f6;hpb=c5d677ac7b879036aa241379cbc32f868c1599bf;p=simgear.git diff --git a/simgear/math/SGMathTest.cxx b/simgear/math/SGMathTest.cxx index 3f0d5cc6..aeedc7a9 100644 --- a/simgear/math/SGMathTest.cxx +++ b/simgear/math/SGMathTest.cxx @@ -174,14 +174,22 @@ MatrixTest(void) // Create some test matrix SGVec3 v0(2, 7, 17); SGQuat q0 = SGQuat::fromAngleAxis(SGMisc::pi(), normalize(v0)); - SGMatrix m0(q0, v0); - - // Check the tqo forms of the inverse for that kind of special matrix - SGMatrix m1, m2; - invert(m1, m0); - m2 = transNeg(m0); + SGMatrix m0 = SGMatrix::unit(); + m0.postMultTranslate(v0); + m0.postMultRotate(q0); + + // Check the three forms of the inverse for that kind of special matrix + SGMatrix m1 = SGMatrix::unit(); + m1.preMultTranslate(-v0); + m1.preMultRotate(inverse(q0)); + + SGMatrix m2, m3; + invert(m2, m0); + m3 = transNeg(m0); if (!equivalent(m1, m2)) return false; + if (!equivalent(m2, m3)) + return false; // Check matrix multiplication and inversion if (!equivalent(m0*m1, SGMatrix::unit())) @@ -192,6 +200,10 @@ MatrixTest(void) return false; if (!equivalent(m2*m0, SGMatrix::unit())) return false; + if (!equivalent(m0*m3, SGMatrix::unit())) + return false; + if (!equivalent(m3*m0, SGMatrix::unit())) + return false; return true; } @@ -200,10 +212,10 @@ bool GeodesyTest(void) { // We know that the values are on the order of 1 - double epsDeg = 10*SGLimits::epsilon(); + double epsDeg = 10*360*SGLimits::epsilon(); // For the altitude values we need to tolerate relative errors in the order // of the radius - double epsM = 1e6*SGLimits::epsilon(); + double epsM = 10*6e6*SGLimits::epsilon(); SGVec3 cart0, cart1; SGGeod geod0, geod1; @@ -236,7 +248,9 @@ sgInterfaceTest(void) SGVec3f v3f = SGVec3f::e2(); SGVec4f v4f = SGVec4f::e2(); SGQuatf qf = SGQuatf::fromEulerRad(1.2, 1.3, -0.4); - SGMatrixf mf(qf, v3f); + SGMatrixf mf; + mf.postMultTranslate(v3f); + mf.postMultRotate(qf); // Copy to and from plibs types check if result is equal, // test for exact equality @@ -283,7 +297,9 @@ sgdInterfaceTest(void) SGVec3d v3d = SGVec3d::e2(); SGVec4d v4d = SGVec4d::e2(); SGQuatd qd = SGQuatd::fromEulerRad(1.2, 1.3, -0.4); - SGMatrixd md(qd, v3d); + SGMatrixd md; + md.postMultTranslate(v3d); + md.postMultRotate(qd); // Copy to and from plibs types check if result is equal, // test for exact equality