示例#1
0
        public Indexers3()
        {
            var rnd = new RandomSystem(1);

            indices.SetByIndex(i => rnd.UniformV2i(3));
            vectors.SetByIndex(i => new Vector(rnd.CreateUniformDoubleArray(3)));
            matrices.SetByIndex(i => new Matrix(rnd.CreateUniformDoubleArray(9)));
        }
        public __type__()
        {
            var rnd = new RandomSystem(1);

            indices.SetByIndex(i => rnd.UniformV2i(__n__));
            vectors.SetByIndex(i => new __vtype__(rnd.CreateUniformDoubleArray(__n__)));
            matrices.SetByIndex(i => new __nmtype__(rnd.CreateUniformDoubleArray(__nm__)));
        }
示例#3
0
        public void MatrixMultiplicationTest()
        {
            using (Report.JobTimed("Matrix multiplication tests"))
            {
                var rand = new RandomSystem();

                Test.Begin("Row vector with matrix");
                var m = new M44d(rand.CreateUniformDoubleArray(16));
                var v = new V4d(rand.CreateUniformDoubleArray(4));

                Test.IsTrue(v * m == m.Transposed * v);
                Test.End();
            }
        }
示例#4
0
        public MatrixMinor()
        {
            var rnd = new RandomSystem(1);

            A.SetByIndex(i => new M44d(rnd.CreateUniformDoubleArray(16)));
            rows.SetByIndex(i => rnd.UniformInt(4));
            columns.SetByIndex(i => rnd.UniformInt(4));
        }
示例#5
0
        public void BoxTransformTest()
        {
            var cnt    = 10000;
            var rnd    = new RandomSystem(1);
            var trafos = new M44d[cnt].SetByIndex(i => new M44d(rnd.CreateUniformDoubleArray(16)));
            //var trafos = new M44d[cnt].SetByIndex(i => M44d.FromBasis(rnd.UniformV3d(), rnd.UniformV3d(), rnd.UniformV3d(), rnd.UniformV3d()));
            //var trafos = new M44d[cnt].SetByIndex(i => M44d.Translation(rnd.UniformV3d()));
            //var trafos = new M44d[cnt].SetByIndex(i => M44d.Rotation(rnd.UniformV3d()) * M44d.Translation(rnd.UniformV3d()));
            var boxes    = new Box3d[cnt].SetByIndex(i => Box3d.FromCenterAndSize(rnd.UniformV3d(), rnd.UniformV3d()));
            var refBoxes = boxes.Map((b, i) => Transform1(b, trafos[i]));

            for (int j = 0; j < 10; j++)
            {
                Report.BeginTimed("Transform Boxes Aardvark");
                for (int i = 0; i < trafos.Length; i++)
                {
                    var test = boxes[i].Transformed(trafos[i]);
                    Assert.IsTrue(test.Min.ApproximateEquals(refBoxes[i].Min, 1e-7) && test.Max.ApproximateEquals(refBoxes[i].Max, 1e-7));
                }
                Report.End();

                Report.BeginTimed("Transform Boxes1");
                for (int i = 0; i < trafos.Length; i++)
                {
                    var test = Transform1(boxes[i], trafos[i]);
                    Assert.IsTrue(test.Min.ApproximateEquals(refBoxes[i].Min, 1e-7) && test.Max.ApproximateEquals(refBoxes[i].Max, 1e-7));
                }
                Report.End();


                Report.BeginTimed("Transform Boxes2");
                for (int i = 0; i < trafos.Length; i++)
                {
                    var test = Transform2(boxes[i], trafos[i]);
                    Assert.IsTrue(test.Min.ApproximateEquals(refBoxes[i].Min, 1e-7) && test.Max.ApproximateEquals(refBoxes[i].Max, 1e-7));
                }
                Report.End();

                Report.BeginTimed("Transform Boxes3");
                for (int i = 0; i < trafos.Length; i++)
                {
                    var test = Transform3(boxes[i], trafos[i]);
                    Assert.IsTrue(test.Min.ApproximateEquals(refBoxes[i].Min, 1e-7) && test.Max.ApproximateEquals(refBoxes[i].Max, 1e-7));
                }
                Report.End();

                Report.BeginTimed("Transform Boxes4");
                for (int i = 0; i < trafos.Length; i++)
                {
                    var test = Transform4(boxes[i], trafos[i]);
                    Assert.IsTrue(test.Min.ApproximateEquals(refBoxes[i].Min, 1e-7) && test.Max.ApproximateEquals(refBoxes[i].Max, 1e-7));
                }
                Report.End();
            }
        }
示例#6
0
        public void InPlaceTransposeTest()
        {
            var rand = new RandomSystem();

            var m          = new M44d(rand.CreateUniformDoubleArray(16));
            var transposed = m.Transposed;

            Mat.Transpose(ref m);

            Assert.IsTrue(Fun.ApproximateEquals(m, transposed, 0.0001));
        }
示例#7
0
        public void TransformedInfinite()
        {
            var rnd = new RandomSystem(123);

            for (int i = 0; i < 1000; i++)
            {
                var mat  = new M44d(rnd.CreateUniformDoubleArray(16));
                var test = Box3d.Infinite.Transformed(mat);
                if (test.Min.AnyInfinity || test.Max.AnyInfinity)
                {
                    Report.Line("Max -> Infinite");                                               // NOTE: some max values will be infinite
                }
                Assert.False(test.Max.AnyNaN || test.Min.AnyNaN || test.IsEmpty);
            }
        }
示例#8
0
        public void TransformedEmpty()
        {
            var rnd = new RandomSystem(123);

            for (int i = 0; i < 1000; i++)
            {
                var mat  = new M44d(rnd.CreateUniformDoubleArray(16));
                var test = Box3d.Invalid.Transformed(mat);
                Assert.True(test.IsEmpty);
                Assert.False(test.Max.AnyNaN || test.Min.AnyNaN || test.IsNonEmpty);
                if (test.Min.AnyInfinity || test.Max.AnyInfinity)
                {
                    Report.Line("Max -> Infinite");
                }
            }
        }
示例#9
0
 public static M44d GetRandom4x4(RandomSystem rnd)
 => new M44d(rnd.CreateUniformDoubleArray(16));
示例#10
0
 public static M33d GetRandom3x3(RandomSystem rnd)
 => new M33d(rnd.CreateUniformDoubleArray(16));