Ejemplo n.º 1
0
        public static void MultiplicationFull2x3Test()
        {
            TrafoTesting.GenericTest(rnd =>
            {
                var m = TrafoTesting.GetRandom2x3(rnd);
                var r = TrafoTesting.GetRandomRot2(rnd);

                var mr = m * r;
                var rm = r * m;

                var mr_ref = m * (M33d)r;
                var rm_ref = (M23d)r * (M33d)m;

                {
                    var p          = rnd.UniformV2d() * rnd.UniformInt(1000);
                    var res_mr     = mr.TransformPos(p);
                    var res_mr_ref = mr_ref.TransformPos(p);
                    var res_rm     = rm.TransformPos(p);
                    var res_rm_ref = rm_ref.TransformPos(p);

                    TrafoTesting.AreEqual(res_mr, res_mr_ref);
                    TrafoTesting.AreEqual(res_rm, res_rm_ref);
                }
            });
        }
Ejemplo n.º 2
0
        public static void MultiplicationScaleTest()
        => TrafoTesting.GenericTest(rnd =>
        {
            var a = TrafoTesting.GetRandomRot2(rnd);
            var b = TrafoTesting.GetRandomScale2(rnd);

            var p = rnd.UniformV2d() * rnd.UniformInt(1000);

            {
                var trafo = a * b;
                var res   = trafo.TransformPos(p);

                var trafoRef = (M33d)a * (M33d)b;
                var resRef   = trafoRef.TransformPos(p);

                TrafoTesting.AreEqual(res, resRef);
            }

            {
                var trafo = b * a;
                var res   = trafo.TransformPos(p);

                var trafoRef = (M33d)b * (M33d)a;
                var resRef   = trafoRef.TransformPos(p);

                TrafoTesting.AreEqual(res, resRef);
            }
        });
Ejemplo n.º 3
0
        public static void DistanceTest()
        {
            TrafoTesting.GenericTest(rnd =>
            {
                var delta = (rnd.UniformDouble() - 0.5) * 2.0 * Constant.Pi;
                var r1    = TrafoTesting.GetRandomRot2(rnd);
                var r2    = new Rot2d(r1.Angle + (delta + Constant.PiTimesTwo * rnd.UniformInt(10)));

                var dist = r1.Distance(r2);
                TrafoTesting.AreEqual(dist, Fun.Abs(delta));
            });
        }
Ejemplo n.º 4
0
        public static void InverseTest()
        {
            TrafoTesting.GenericTest(rnd =>
            {
                var r = TrafoTesting.GetRandomRot2(rnd);

                var p = rnd.UniformV2d() * rnd.UniformInt(1000);
                var q = r.Transform(p);

                // Inverse property
                var res = r.Inverse.Transform(q);

                // Invert method
                Rot.Invert(ref r);
                var res2 = r.Transform(q);

                TrafoTesting.AreEqual(p, res);
                TrafoTesting.AreEqual(p, res2);
            });
        }
Ejemplo n.º 5
0
        public static void Multiplication2x3Test()
        {
            TrafoTesting.GenericTest(rnd =>
            {
                var r1 = TrafoTesting.GetRandomRot2(rnd);
                var r2 = TrafoTesting.GetRandomRot2(rnd);
                var r  = r1 * r2;
                var rm = (M23d)r1 * r2;
                var mr = r1 * (M23d)r2;

                {
                    var p    = rnd.UniformV2d() * rnd.UniformInt(1000);
                    var res  = r.Transform(p);
                    var res2 = rm.TransformPos(p);
                    var res3 = mr.TransformPos(p);

                    TrafoTesting.AreEqual(res, res2);
                    TrafoTesting.AreEqual(res, res3);
                }
            });
        }