Ejemplo n.º 1
0
        private void fullList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                this.SelectedMatrix = ((VisualSignMatrix)fullList.SelectedItem).signmatrix;
                List <VisualNgon> ngons     = new List <VisualNgon>();
                List <Canvas>     ngonsvizs = new List <Canvas>();
                if (SelectedMatrix != null)
                {
                    foreach (var rawngon in SelectedMatrix.Ngons)
                    {
                        VisualNgon ngon = new VisualNgon(rawngon);

                        ngons.Add(ngon);
                        double width = 300, height = 200;
                        Canvas box = new Canvas()
                        {
                            Height = height, Width = width
                        };
                        ngon.draw(box, width, height);
                        ngonsvizs.Add(box);
                    }
                }
                panel_ngons.ItemsSource = ngonsvizs;
            }
            catch (Exception ex)
            {
            }
        }
Ejemplo n.º 2
0
        public void SignMatrixEqualsTest()
        {
            Ngon       ngon = Program.generateRandomNgon(6);
            SignMatrix a    = new SignMatrix(new PluckerMatrix(ngon));
            SignMatrix b    = new SignMatrix(new PluckerMatrix(ngon));

            Assert.IsTrue(a.Equals(b));
        }
 public VisualSignMatrix(SignMatrix signmatrix)
 {
     this.signmatrix = signmatrix;
     labels          = new Label[signmatrix.dimensions, signmatrix.dimensions];
     InitializeComponent();
     displaySigns();
     colorSigns();
     if (signmatrix.Ngons.Any(n => n.Type == MathProject.Entities.NgonType.Convex))
     {
         this.isConvex   = true;
         this.Background = Brushes.LightGreen;
     }
     else
     {
         this.isConvex   = false;
         this.Background = Brushes.LightCoral;
     }
 }
Ejemplo n.º 4
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);
            }
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
0
 public void Add(SignMatrix pluckerMatrix)
 {
     this.PluckerSignMatricesStorage.Add(pluckerMatrix);
     this.SaveChanges();
 }