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()); } }
// .......................... 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(); }