Package jsl.modeling.elements.spatial
Class Collision
- java.lang.Object
-
- jsl.modeling.elements.spatial.Collision
-
public class Collision extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static int
MOVING
Indicates the basic type of collision MOVING = moving element colliding with another moving elementprotected SpatialElement
myCollisionElement
The moving element that will collide with myMovingElementprotected CollisionHandlerIfc
myCollisionHandler
Used to handle the collisionprotected CoordinateIfc
myCollisionPosition
The position associated with the collisionprotected int
myCollisionType
Holds the basic type of collisionprotected MoverIfc
myMovingElement
The element that was moving and detected the collisionprotected double
myTimeOfCollision
The projected time of the collisionstatic int
NONE
Indicates the basic type of collision NONE = no collisionstatic int
STATIONARY
Indicates the basic type of collision STATIONARY = moving element colliding with a stationary (non-moveable) element
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Clears the collision for reuseSpatialElement
getCollisionElement()
The element that will collide with the movingElementCollisionHandlerIfc
getCollisionHandler()
Gets the collision handler for this collision.CoordinateIfc
getCollisionPosition()
The position associated with the collisionint
getCollisionType()
Used to indicate the type of collision using one of the class constantsMoverIfc
getMovingElement()
The element that was moving and detected the collisiondouble
getTimeOfCollision()
The projected time of the collisionboolean
hasCollided()
Indicates whether or not the elements have collidedvoid
setCollision(SpatialElement element, double timeOfCollision, CoordinateIfc collisionPosition, int collisionType)
Sets the characteristics of the collisionvoid
setCollisionHandler(CollisionHandlerIfc collisionHandler)
Sets the collision handler for this collision.protected void
setMovingElement(MoverIfc movingElement)
-
-
-
Field Detail
-
NONE
public static final int NONE
Indicates the basic type of collision NONE = no collision- See Also:
- Constant Field Values
-
MOVING
public static final int MOVING
Indicates the basic type of collision MOVING = moving element colliding with another moving element- See Also:
- Constant Field Values
-
STATIONARY
public static final int STATIONARY
Indicates the basic type of collision STATIONARY = moving element colliding with a stationary (non-moveable) element- See Also:
- Constant Field Values
-
myMovingElement
protected MoverIfc myMovingElement
The element that was moving and detected the collision
-
myCollisionElement
protected SpatialElement myCollisionElement
The moving element that will collide with myMovingElement
-
myTimeOfCollision
protected double myTimeOfCollision
The projected time of the collision
-
myCollisionPosition
protected CoordinateIfc myCollisionPosition
The position associated with the collision
-
myCollisionType
protected int myCollisionType
Holds the basic type of collision
-
myCollisionHandler
protected CollisionHandlerIfc myCollisionHandler
Used to handle the collision
-
-
Constructor Detail
-
Collision
public Collision(MoverIfc myMovingElement)
Creates a Collision which represents a collsition in space
-
-
Method Detail
-
clear
public void clear()
Clears the collision for reuse
-
hasCollided
public final boolean hasCollided()
Indicates whether or not the elements have collided- Returns:
- true if collided
-
getCollisionType
public final int getCollisionType()
Used to indicate the type of collision using one of the class constants- Returns:
- Returns the collisionType.
-
getCollisionPosition
public final CoordinateIfc getCollisionPosition()
The position associated with the collision- Returns:
- Returns the collisionPosition.
-
getCollisionElement
public final SpatialElement getCollisionElement()
The element that will collide with the movingElement- Returns:
- Returns the collisionElement.
-
getMovingElement
public final MoverIfc getMovingElement()
The element that was moving and detected the collision- Returns:
- Returns the movingElement.
-
getTimeOfCollision
public final double getTimeOfCollision()
The projected time of the collision- Returns:
- Returns the timeOfCollision.
-
getCollisionHandler
public final CollisionHandlerIfc getCollisionHandler()
Gets the collision handler for this collision. It may be null indicating no collision handling actions- Returns:
- Returns the collisionHandler.
-
setCollision
public void setCollision(SpatialElement element, double timeOfCollision, CoordinateIfc collisionPosition, int collisionType)
Sets the characteristics of the collision- Parameters:
element
-timeOfCollision
-collisionPosition
-collisionType
- The type of collision (moving to moving, moving to stationary)
-
setCollisionHandler
public final void setCollisionHandler(CollisionHandlerIfc collisionHandler)
Sets the collision handler for this collision. It may be null indicating no collision handling- Parameters:
collisionHandler
- The collisionHandler to set.
-
setMovingElement
protected final void setMovingElement(MoverIfc movingElement)
- Parameters:
movingElement
- The movingElement to set.
-
-