Example #1
0
        public Vector3d CalculateRepel()
        {
            Vector3d   _repel      = new Vector3d();
            PointAgent targetAgent = AllAgents[NeighbourIds[0]];
            Vector3d   move        = Position - targetAgent.Position;

            if (RepelMin <= move.Length && move.Length <= RepelMax)
            {
                move.Unitize();
                _repel = move * RepelWeight;
            }
            return(_repel);
        }
Example #2
0
        public Vector3d CalculateAttract()
        {
            Vector3d   _attract    = new Vector3d();
            PointAgent targetAgent = AllAgents[NeighbourIds[0]];
            Vector3d   move        = targetAgent.Position - Position;

            if (AttractMin < move.Length && move.Length <= AttractMax)
            {
                move.Unitize();
                _attract = move * AttractWeight;
            }
            return(_attract);
        }
        private void AddAgent()
        {
            int        lastIndex = Trail.Count - 1;
            PointAgent thisAgent = Trail[lastIndex];

            thisAgent.Update();
            Point3d  newPosition = thisAgent.Position + thisAgent.Velocity;
            Vector3d newVelocity = thisAgent.Velocity;

            Trail.Add(new PointAgent(newPosition, newVelocity));
            //update agents velocity.
            //new position = prev position + this updated velocity
            //add new agent (new position, this updated velocity)
        }
Example #4
0
        public Vector3d CalculateAlign()
        {
            Vector3d   _align      = new Vector3d();
            PointAgent targetAgent = AllAgents[NeighbourIds[0]];
            Vector3d   move        = targetAgent.Velocity;
            Vector3d   move2       = targetAgent.Position - Position;

            if (AlignMin <= move2.Length && move2.Length < AlignMax)
            {
                move.Unitize();
                _align = move * AlignWeight;
            }
            return(_align);
        }