Example #1
0
        public void Simple2NodeGraph()
        {
            Graph g = new Graph ();
            Node q1 = new Node ();
            Node q2 = new Node ();

            q1.Location = new Point(){ X = 1, Y = 5, Z = 0 };
            q2.Location = new Point(){ X = 0, Y = -2, Z = 0 };

            g.AddNode( q1 );
            g.AddNode( q2 );

            g.Join( q1, q2 );

            int x = 0;
            double fke = 100;
            do {

                g.Compute(null);
                double ke = g.TotalKineticEnergy;

                double kediff = Math.Max( fke, ke ) - Math.Min( fke, ke );
                Console.WriteLine("kediff = {0}", kediff );

                if ( kediff < 0.001 ) break;

                if ( x++ > 1000 ) break;

                fke = ke;

            } while ( true );
        }
Example #2
0
        public void Simple3NodeGraph()
        {
            Graph g = new Graph ();
            Node q1 = new Node ();
            Node q2 = new Node ();
            Node q3 = new Node ();

            q1.Location = new Point(){ X = 1, Y = 5, Z = 0 };
            q2.Location = new Point(){ X = 0, Y = -2, Z = 0 };
            q3.Location = new Point(){ X = -4, Y = 3, Z = 5 };

            g.AddNode( q1 );
            g.AddNode( q2 );
            g.AddNode( q3 );

            g.Join( q1, q3 );
            g.Join( q1, q2 );

            g.ComputeFull( 0.0001 , null );
        }