//------------------------------ Pursuit ---------------------------------
        //
        //  this behavior creates a force that steers the agent towards the 
        //  evader
        //------------------------------------------------------------------------
        public Vector2D Pursuit(MovingEntity evader)
        {
            //if the evader is ahead and facing the agent then we can just seek
            //for the evader's current position.
            Vector2D ToEvader = evader.Pos - m_parentMovingEntity.Pos;

            double RelativeHeading = m_parentMovingEntity.Heading().Dot(evader.Heading());

            if ((ToEvader.Dot(m_parentMovingEntity.Heading()) > 0) && (RelativeHeading < -0.95))  //acos(0.95)=18 degs
            {
                return Seek(evader.Pos);
            }

            //Not considered ahead so we predict where the evader will be.

            //the lookahead time is propotional to the distance between the evader
            //and the pursuer; and is inversely proportional to the sum of the
            //agent's velocities
            double LookAheadTime = ToEvader.Length() /
                                  (m_parentMovingEntity.MaxSpeed + evader.Speed());

            //now seek to the predicted future position of the evader
            return Seek(evader.Pos + evader.Velocity * LookAheadTime);
        }
        private void RenderVehicle(MovingEntity objVehicle, Graphics objGraphics, Pen objPen)
        {
            PointF pntLeft,pntFront,pntRight;

            if (UseSmoothing)
            {
                Vector2D SmoothedPerp = objVehicle.SmoothedHeading().Perp();

                pntLeft = (PointF)(objVehicle.Pos + (SmoothedPerp * objVehicle.BRadius));
                pntFront = (PointF)(objVehicle.Pos + (objVehicle.SmoothedHeading() * (objVehicle.BRadius * 2)));
                pntRight = (PointF)(objVehicle.Pos - (SmoothedPerp * objVehicle.BRadius));
            }
            else
            {
                 pntLeft = (PointF)(objVehicle.Pos + (objVehicle.Side() * objVehicle.BRadius));
                 pntFront = (PointF)(objVehicle.Pos + (objVehicle.Heading() * (objVehicle.BRadius * 2)));
                 pntRight = (PointF)(objVehicle.Pos - (objVehicle.Side() * objVehicle.BRadius));
            }

            PointF[] points = new PointF[4];

            points[0] = pntLeft;
            points[1] = pntFront;
            points[2] = pntRight;
            points[3] = pntLeft;

            objGraphics.DrawPolygon(objPen, points);
        }
        //------------------------- Offset Pursuit -------------------------------
        //
        //  Produces a steering force that keeps a vehicle at a specified offset
        //  from a leader vehicle
        //------------------------------------------------------------------------
        public Vector2D OffsetPursuit(MovingEntity leader, Vector2D offset)
        {
            //calculate the offset's position in world space
            Vector2D WorldOffsetPos = Utils.PointToWorldSpace(offset,
                                                             leader.Heading(),
                                                             leader.Side(),
                                                             leader.Pos);

            Vector2D ToOffset = WorldOffsetPos - m_parentMovingEntity.Pos;

            //the lookahead time is propotional to the distance between the leader
            //and the pursuer; and is inversely proportional to the sum of both
            //agent's velocities
            double LookAheadTime = ToOffset.Length() /
                                  (m_parentMovingEntity.MaxSpeed + leader.Speed());

            //now Arrive at the predicted future position of the offset
            return Arrive(WorldOffsetPos + leader.Velocity * LookAheadTime, (int)Deceleration.fast);
        }
        private void renderDetectionBox(MovingEntity objVehicle, Graphics objGraphics, Pen objPen)
        {
            List<Vector2D> points = new List<Vector2D>();

            points.Add(new Vector2D(0, objVehicle.BRadius));
            points.Add(new Vector2D(objVehicle.Steering().DBoxLength(), objVehicle.BRadius));
            points.Add(new Vector2D(objVehicle.Steering().DBoxLength(), -objVehicle.BRadius));
            points.Add(new Vector2D(0, -objVehicle.BRadius));

            if (UseSmoothing)
            {
                points = Utils.WorldTransform(points, objVehicle.Pos, objVehicle.SmoothedHeading(), objVehicle.SmoothedHeading().Perp());
            }
            else
            {
                points = Utils.WorldTransform(points, objVehicle.Pos, objVehicle.Heading(), objVehicle.Side());                
            }

            objGraphics.DrawLine(objPen, (PointF)points[0], (PointF)points[1]);
            objGraphics.DrawLine(objPen, (PointF)points[1], (PointF)points[2]);
            objGraphics.DrawLine(objPen, (PointF)points[2], (PointF)points[3]);
        }