CalculateFuturePosition() public method

Given a time this method returns the ball position at that time in the future
public CalculateFuturePosition ( double time ) : Vector2D
time double
return Vector2D
コード例 #1
0
        /// <summary>
        /// This behavior creates a force that steers the agent towards the
        //  ball
        /// </summary>
        /// <param name="ball"></param>
        /// <returns></returns>
        protected Vector2D calculatePursuitVector(SoccerBall ball)
        {
            Vector2D toBall = ball.Position - _player.Position;

            //the lookahead time is proportional to the distance between the ball
            //and the pursuer;
            double lookAheadTime = 0.0;

            if (Math.Abs(ball.Speed) > Geometry.MinPrecision)
            {
                lookAheadTime = toBall.Length / ball.Speed;
            }

            //calculate where the ball will be at this time in the future
            _target = ball.CalculateFuturePosition(lookAheadTime);

            //now seek to the predicted future position of the ball
            return(calculateArriveVector(_target, DecelerationState.Fast));
        }
コード例 #2
0
        /// <summary>
        /// This behavior creates a force that steers the agent towards the 
        //  ball
        /// </summary>
        /// <param name="ball"></param>
        /// <returns></returns>
        protected Vector2D calculatePursuitVector(SoccerBall ball)
        {
            Vector2D toBall = ball.Position - _player.Position;

            //the lookahead time is proportional to the distance between the ball
            //and the pursuer; 
            double lookAheadTime = 0.0;

            if (Math.Abs(ball.Speed) > Geometry.MinPrecision)
            {
                lookAheadTime = toBall.Length / ball.Speed;
            }

            //calculate where the ball will be at this time in the future
            _target = ball.CalculateFuturePosition(lookAheadTime);

            //now seek to the predicted future position of the ball
            return  calculateArriveVector(_target, DecelerationState.Fast);
        }