コード例 #1
0
 public void signChambersPluckerTest()
 {
     double[][] problem = new double[][]
     {
         new double[] { 1, -10, 35 },
         new double[] { 3, -49, 80 },
         new double[] { -13, 10, 99 }
     };
     int[][] answer = new int[][]
     {
         new int[] { 1, -1, 1 },
         new int[] { 1, -1, 1 },
         new int[] { -1, 1, 1 }
     };
     int[][] result = new PluckerMatrix()
     {
         columnVectors = problem
     }.signChambers();
     for (int i = 0; i < answer.Count(); i++)
     {
         for (int j = 0; j < answer[i].Count(); j++)
         {
             Assert.IsTrue(answer[i][j] == result[i][j]);
         }
     }
 }
コード例 #2
0
        public void PluckerMatrixTest()
        {
            Ngon          n = Program.generateRandomNgon(10);
            PluckerMatrix D = new PluckerMatrix(n);

            for (int i = 0; i < D.columnVectors.Count(); i++)
            {
                for (int j = 0; j < D.columnVectors[i].Count(); j++)
                {
                    Assert.AreEqual(-D.columnVectors[i][j], D.columnVectors[j][i]);
                }
            }
        }
コード例 #3
0
        public PluckerMatrix PluckerMatrixTest(Ngon ngon)
        {
            PluckerMatrix D = new PluckerMatrix(ngon);

            for (int j = 0; j < ngon.getOrthonormal().Length; j++)
            {
                for (int i = 0; i < ngon.getOrthonormal()[j].Length; i++)
                {
                    //double fromEdgeVectors = ngon.getOrthonormal()[i][0] * ngon.getOrthonormal()[j][1] - ngon.getOrthonormal()[j][0] * ngon.getOrthonormal()[i][1];
                    //Assert.AreEqual(fromEdgeVectors, D.columnVectors[i][j]);
                }
            }
            return(D);
        }
コード例 #4
0
        public void PluckerAndProjectionMatrixEquality()
        {
            Ngon             ngon       = Program.generateRandomNgon(4);
            PluckerMatrix    plucker    = PluckerMatrixTest(ngon);
            ProjectionMatrix projection = ProjectionMatrixTest(ngon);

            Matrix <double> D = Matrix <double> .Build.DenseOfColumnArrays(plucker.columnVectors);

            string          d    = D.ToString();
            Matrix <double> Dnsq = (D.Multiply(D)).Negate();
            string          dnsq = Dnsq.ToString();
            Matrix <double> P    = Matrix <double> .Build.DenseOfColumnArrays(projection.columnVectors);

            string p = P.ToString();

            compareMatricies(Dnsq, P);
        }
コード例 #5
0
        public void isConvexXorTest()
        {
            long sampleSize = 1000000;

            for (int i = 0; i < sampleSize; i++)
            {
                var           ngon       = Program.generateRandomNgon(5);
                PluckerMatrix plucker    = new PluckerMatrix(ngon);
                SignMatrix    signMatrix = new SignMatrix(plucker);
                ngon.PluckerSignMatrix = signMatrix;
                bool xorOutput = ngon.isConvexXor();
                bool result    = ngon.Type == NgonType.Convex;
                if (result != xorOutput)
                {
                    ngon = null;
                }
                Assert.AreEqual(xorOutput, result);
            }
        }
コード例 #6
0
        private static void addNgonToDatabase(int n, int sampleSize = 1)
        {
            NgonDatabase database = new NgonDatabase(n);

            List <Ngon> ngons = new List <Ngon>();

            for (int i = 0; i < sampleSize; i++)
            {
                Ngon          ngon       = Program.generateRandomNgon(n);
                PluckerMatrix plucker    = new PluckerMatrix(ngon);
                SignMatrix    signMatrix = new SignMatrix(plucker);
                SignMatrix    existing   = null;
                try { existing = database.PluckerSignMatricesStorage.FirstOrDefault(m => m.encodedColumnVectors == signMatrix.encodedColumnVectors); }
                catch (Exception e) { }
                if (existing == null)
                {
                    database.Add(signMatrix);
                    existing = signMatrix;
                }
                ngon.PluckerSignMatrix = existing;
                ngons.Add(ngon);
            }
            database.Add(ngons);
        }