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 intMOVINGIndicates the basic type of collision MOVING = moving element colliding with another moving elementprotected SpatialElementmyCollisionElementThe moving element that will collide with myMovingElementprotected CollisionHandlerIfcmyCollisionHandlerUsed to handle the collisionprotected CoordinateIfcmyCollisionPositionThe position associated with the collisionprotected intmyCollisionTypeHolds the basic type of collisionprotected MoverIfcmyMovingElementThe element that was moving and detected the collisionprotected doublemyTimeOfCollisionThe projected time of the collisionstatic intNONEIndicates the basic type of collision NONE = no collisionstatic intSTATIONARYIndicates 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 voidclear()Clears the collision for reuseSpatialElementgetCollisionElement()The element that will collide with the movingElementCollisionHandlerIfcgetCollisionHandler()Gets the collision handler for this collision.CoordinateIfcgetCollisionPosition()The position associated with the collisionintgetCollisionType()Used to indicate the type of collision using one of the class constantsMoverIfcgetMovingElement()The element that was moving and detected the collisiondoublegetTimeOfCollision()The projected time of the collisionbooleanhasCollided()Indicates whether or not the elements have collidedvoidsetCollision(SpatialElement element, double timeOfCollision, CoordinateIfc collisionPosition, int collisionType)Sets the characteristics of the collisionvoidsetCollisionHandler(CollisionHandlerIfc collisionHandler)Sets the collision handler for this collision.protected voidsetMovingElement(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.
-
-