Ejemplo n.º 1
0
        public void FieldRTree()
        {
            foreach (AgentPlane ag in agentPlanes)
            {
                // clear neighbour list
                ag.neighbours.Clear();
                ag.neighTens.Clear();

                // calculate field vector from mesh
                // Eventhandler function for RTree search
                EventHandler <RTreeEventArgs> rTreeCallback = (object sender, RTreeEventArgs args) =>
                {
                    ag.neighbours.Add(MEnvironment.Vertices[args.Id]);
                    ag.neighTens.Add(TensorField[args.Id]);
                };

                MeshRTree.Search(new Sphere(MEnvironment.ClosestPoint(ag.O), MeshSeekRadius), rTreeCallback);

                // this resets the acceleration (or desired direction)
                // in case a different update sequence is implemented
                // remember to reset desired before calculating the new iteration
                ag.ResetDesired();

                // Other methods
                ag.SeekMeshNeighbours(); // seek Mesh Neighbor points
                // Interact with scalar field (flee dark areas)
                ag.SeekColor();
                // Compute Alignment
                ag.ComputeFieldAlign(ag.ComputeFieldVector());
            }
        }
Ejemplo n.º 2
0
        public Plane PlaneOut()
        {
            Vector3d oV = new Vector3d(O);

            oV.Unitize();

            Vector3d nV = MEnvironment.NormalAt(MEnvironment.ClosestMeshPoint(O, 100));

            this.Y = Vector3d.CrossProduct(X, nV);
            Vector3d newX = Vector3d.CrossProduct(nV, this.Y);

            return(new Plane(O, newX, Y));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Main installer method, choose colour of installer, choose desired username and reports if a FAT error occurs
        /// </summary>
        public static void Main()
        {
            ScreenSetup();
            WriteLine("Welcome to the Medli installer.");
            PressAnyKey();

            try
            {
                Accounts.InitNewUser(); Done();

                WriteLine("Enter the root password: "******"Writing root password...");
                MEnvironment.WriteRootPass(); Done();
            }
            catch (Exception ex)
            {
                Bluescreen.Init(ex, true);
                Console.ReadKey(true);
            }

            WriteLine("Please enter a machine name:");
            Kernel.pcname = ReadLine();

            try
            {
                WritePrefix("Creating machineinfo file...    "); File.Create(Kernel.pcinfo).Dispose(); Done();
                WritePrefix("Writing machineinfo to file...  "); File.WriteAllText(Kernel.pcinfo, Kernel.pcname); Done();
            }
            catch
            {
                WriteLine("OOOPS!");
                PressAnyKey("Press any key to view the stop error: ");
                ErrorHandler.BlueScreen.Init(5, @"The Installer was unable to create the user directory and other files. 
This may be due to a failing hard drive or other internal error", "FAT Error");
            }

            WriteLine("Awesome - you're all set!");
            PressAnyKey("Press any key to start Medli!");
            Console.Clear();
        }
Ejemplo n.º 4
0
        // ..........................    methods

        public void Update()
        {
            // . . . . . . . . . . environmental and stigmergic interactions

            // calculate field influence vector for agents

            foreach (AgentPlane ag in agentPlanes)
            {
                // clear neighbour list
                ag.neighbours.Clear();
                ag.neighTens.Clear();

                // calculate field vector from mesh
                // Eventhandler function for RTree search
                EventHandler <RTreeEventArgs> rTreeCallback = (object sender, RTreeEventArgs args) =>
                {
                    ag.neighbours.Add(MEnvironment.Vertices[args.Id]);
                    ag.neighTens.Add(TensorField[args.Id]);
                };

                MeshRTree.Search(new Sphere(MEnvironment.ClosestPoint(ag.O), MeshSeekRadius), rTreeCallback);

                // this resets the acceleration (or desired direction)
                // in case a different update sequence is implemented
                // remember to reset desired before calculating the new iteration
                ag.ResetDesired();
                ag.SeekMeshNeighbours();
                ag.SeekColor();
                ag.ComputeFieldAlign(ag.ComputeFieldVector(), FieldStrength);
            }

            // . . . . . . . . . . peer-to-peer interaction
            FLockRTree();

            // . . . . . . . . . . update position and direction
            UpdateAgentsDirection();
        }