Ejemplo n.º 1
0
        /// <summary>
        /// Executes the pursuit behavior.
        /// </summary>
        /// <param name="quarry">The car that should be pursuited.</param>
        /// <returns>The pursuit steering force.</returns>
        private Vector2 Pursuit(Car quarry)
        {
            Vector2 distance = quarry.GPSPosition - this.GPSPosition;
            //t is predicted time until interception.
            float t = distance.Length() / (this.Velocity - quarry.Velocity).Length();

            //Seek predicted position.
            return Seek(AutonomousCar.PredictFuturePosition(quarry, t));
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Executes the leader following behavior.
 /// </summary>
 /// <param name="leader">The car that is designated as leader.</param>
 /// <returns>The leader following steering force.</returns>
 private Vector2 FollowLeader(Car leader)
 {
     float distanceOffset = this.CollisionDist;
     return Arrive(leader.GPSPosition - distanceOffset * leader.Velocity);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Executes the interpose behavior.
        /// </summary>
        /// <param name="car1">The first car.</param>
        /// <param name="car2">The second car.</param>
        /// <returns>The interpose steering force.</returns>
        private Vector2 Interpose(Car car1, Car car2)
        {
            float distance = (((car1.GPSPosition + car2.GPSPosition) / 2) - this.GPSPosition).Length();
            float T = distance / this.Velocity.Length();

            Vector2 desiredPosition = (PredictFuturePosition(car1, T) + PredictFuturePosition(car2, T)) / 2;
            return Seek(desiredPosition);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Predicts the position of the specified car after the specified time.
 /// </summary>
 /// <param name="car">The car of which the position should be predicted.</param>
 /// <param name="t">The point in time at which the position should be predicted, in seconds.</param>
 /// <returns>The predicted future position.</returns>
 private static Vector2 PredictFuturePosition(Car car, float t)
 {
     return car.GPSPosition + car.Velocity * t;
 }