|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectmovements.CollisionAvoidanceGenerator
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.
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 |
private PersonMovement adjustedMovement1
private PersonMovement adjustedMovement2
| Constructor Detail |
CollisionAvoidanceGenerator(PersonMovement originalMovement1,
PersonMovement originalMovement2)
throws InevitableCollisionException
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.
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 |
PersonMovement getAdjustedMovement1()
PersonMovement getAdjustedMovement2()
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||