movements
Class CollisionAvoidanceGenerator

java.lang.Object
  extended bymovements.CollisionAvoidanceGenerator

class CollisionAvoidanceGenerator
extends java.lang.Object

The dance specification allows a 'collision avoidance' element. Movements within the 'collision avoidance' element may cause people to collide. The 'collision avoidance' element specifies how the movements should be adjusted to avoid a collision.

Collisions are usually avoided by one participant giving way to the other. This usually involves one participant slowing down and the other participant speeding up. A collision may also be avoided by the two participants altering their tracks slightly. In real life collisions are usually avoided by a combination of the two.

This implementation avoids collisions by altering the speed at which the participants move. The track taken by each participant is never altered in this implementation.

The speed of the tracks are altered by making use of a PersonMovementTimeShifted object. This object is constructed from the original PersonMovement object and from an array of time adjustments. The time adjustments are used to shift the time before passing on the request for the participant's position to the underlying PersonMovement object. For example, if a request is made to the PersonMovementTimeShifted object for the position at tick 8 and the time adjustments indicate that the participant has been slowed and is currently two ticks behind where the participant would normally be, then the PersonMovementTimeShifted object will pass tick 6 onto the underlying PersonMovement to obtain the position.

See Also:
PersonMovementTimeShifted

Field Summary
private  PersonMovement adjustedMovement1
           
private  PersonMovement adjustedMovement2
           
 
Constructor Summary
(package private) CollisionAvoidanceGenerator(PersonMovement originalMovement1, PersonMovement originalMovement2)
          Construct an object that takes as input the two original paths for a pair of participants and generates adjusted paths for the two participants that have been adjusted, if necessary, so that the two participants do not collide.
 
Method Summary
(package private)  PersonMovement getAdjustedMovement1()
          Gets the movements for the participant who must yield.
(package private)  PersonMovement getAdjustedMovement2()
          Gets the movements for the participant who has the right of way.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

adjustedMovement1

private PersonMovement adjustedMovement1

adjustedMovement2

private PersonMovement adjustedMovement2
Constructor Detail

CollisionAvoidanceGenerator

CollisionAvoidanceGenerator(PersonMovement originalMovement1,
                            PersonMovement originalMovement2)
                      throws InevitableCollisionException
Construct an object that takes as input the two original paths for a pair of participants and generates adjusted paths for the two participants that have been adjusted, if necessary, so that the two participants do not collide.

Parameters:
originalMovement1 - The movement that would have been done by the yielding person if no adjustment were made to avoid a collision.
originalMovement2 - The movement that would have been done by the person with the right of way if no adjustment were made to avoid a collision.
Throws:
InevitableCollisionException - In extreme cases it may not be possible to avoid a collision. For example, if the person who has the right of way dances through the yielding person's starting position then it would be impossible to avoid a collision however much the yielding person holds back or the person with the right of way speeds up.
Method Detail

getAdjustedMovement1

PersonMovement getAdjustedMovement1()
Gets the movements for the participant who must yield.

Returns:
An object that gives the movements of the yielding participant with the movements adjusted (i.e. delayed) to avoid the other participant.

getAdjustedMovement2

PersonMovement getAdjustedMovement2()
Gets the movements for the participant who has the right of way.

Returns:
An object that gives the movements of the participant with the right of way with the movements adjusted (i.e. brought forward) to avoid the other participant.


Copyright © 2003 Nigel Westbury