Example #1
0
        void TestDecompose(Trafo3d trafo, Rot3d jitter)
        {
            var x = (M44d)jitter;

            trafo = trafo * new Trafo3d(x, x.Inverse);

            V3d r_d, s_d, t_d;

            trafo.Decompose(out s_d, out r_d, out t_d);

            var recomposed = Trafo3d.FromComponents(s_d, r_d, t_d);

            Assert.IsFalse(s_d.AnyNaN || r_d.AnyNaN || t_d.AnyNaN, "something NaN");

            var dt = trafo.Forward - recomposed.Forward;
            var e  = dt.NormMax.Abs();

            Assert.IsTrue(e < 1e-9, "DIFF");

            var eq = CheckForwardBackwardConsistency(new Trafo3d(trafo.Forward, recomposed.Backward)) &&
                     CheckForwardBackwardConsistency(new Trafo3d(recomposed.Forward, trafo.Backward));



            Assert.True(eq, "trafo not consistent");
        }
Example #2
0
        void TestDecompose(V3d scale, V3d rotation, V3d translation)
        {
            var trafo = Trafo3d.FromComponents(scale, rotation, translation);
            V3d r_d, s_d, t_d;

            trafo.Decompose(out s_d, out r_d, out t_d);

            var recomposed = Trafo3d.FromComponents(s_d, r_d, t_d);

            Assert.IsFalse(s_d.AnyNaN || r_d.AnyNaN || t_d.AnyNaN, "something NaN");

            ValidateTrafos(trafo, recomposed);
        }
Example #3
0
        public static Trafo3d GetRandomTrafo(RandomSystem rnd, bool withPerspective)
        {
            var rot   = rnd.UniformV3dFull() * Constant.PiTimesFour - Constant.PiTimesTwo;
            var trans = rnd.UniformV3dFull() * 10 - 5;
            var scale = rnd.UniformV3dFull() * 4 - 2;

            var trafo = Trafo3d.FromComponents(scale, rot, trans);

            if (withPerspective)
            {
                trafo *= Trafo3d.PerspectiveProjectionRH(-1, 1, -1, 1, rnd.UniformDouble(), rnd.UniformDouble() * 100);
            }

            return(trafo);
        }
Example #4
0
        void TestDecompose(V3d scale, V3d rotation, V3d translation)
        {
            var trafo = Trafo3d.FromComponents(scale, rotation, translation);
            V3d r_d, s_d, t_d;

            trafo.Decompose(out s_d, out r_d, out t_d);

            var recomposed = Trafo3d.FromComponents(s_d, r_d, t_d);

            Assert.IsFalse(s_d.AnyNaN || r_d.AnyNaN || t_d.AnyNaN, "something NaN");

            var eq = CheckForwardBackwardConsistency(new Trafo3d(trafo.Forward, recomposed.Backward)) &&
                     CheckForwardBackwardConsistency(new Trafo3d(recomposed.Forward, trafo.Backward));

            Assert.True(eq, "trafo not consistent");
        }
Example #5
0
        void TestDecompose(Trafo3d trafo)
        {
            trafo = trafo * Trafo3d.RotationXInDegrees(0.000000000000000001);

            V3d r_d, s_d, t_d;

            trafo.Decompose(out s_d, out r_d, out t_d);

            var recomposed = Trafo3d.FromComponents(s_d, r_d, t_d);

            Assert.IsFalse(s_d.AnyNaN || r_d.AnyNaN || t_d.AnyNaN, "something NaN");

            var eq = CheckForwardBackwardConsistency(new Trafo3d(trafo.Forward, recomposed.Backward)) &&
                     CheckForwardBackwardConsistency(new Trafo3d(recomposed.Forward, trafo.Backward));

            Assert.True(eq, "trafo not consistent");
        }
Example #6
0
        void TestDecompose(V3d scale, V3d rotation, V3d translation)
        {
            var trafo = Trafo3d.FromComponents(scale, rotation, translation);
            V3d r_d, s_d, t_d;

            trafo.Decompose(out s_d, out r_d, out t_d);

            var recomposed = Trafo3d.FromComponents(s_d, r_d, t_d);

            Assert.IsFalse(s_d.AnyNaN || r_d.AnyNaN || t_d.AnyNaN, "something NaN");

            var e_scale = (s_d.Abs() - scale.Abs()).LengthSquared;
            var e_trans = (t_d - translation).LengthSquared;

            Assert.True(e_scale < 1e-5, "Scale");
            Assert.True(e_trans < 1e-5, "Translation");

            ValidateTrafos(trafo, recomposed);
        }