Class ContinuousPhysics2DEnvironment
-
- All Implemented Interfaces:
-
it.unibo.alchemist.model.Environment
,it.unibo.alchemist.model.EuclideanEnvironment
,it.unibo.alchemist.model.environments.Euclidean2DEnvironment
,it.unibo.alchemist.model.physics.PhysicsEnvironment
,it.unibo.alchemist.model.physics.environments.Physics2DEnvironment
,java.io.Serializable
,kotlin.collections.Iterable
,kotlin.collections.MutableIterable
public class ContinuousPhysics2DEnvironment<T extends Object> extends Continuous2DEnvironment<T> implements Physics2DEnvironment<T>
Implementation of Physics2DEnvironment.
-
-
Field Summary
Fields Modifier and Type Field Description private final Euclidean2DShapeFactory
shapeFactory
private final ListSet<GlobalReaction<T>>
globalReactions
private final ListSet<Node<T>>
nodes
private final Euclidean2DPosition
origin
-
Constructor Summary
Constructors Constructor Description ContinuousPhysics2DEnvironment(Incarnation<T, Euclidean2DPosition> incarnation)
-
Method Summary
Modifier and Type Method Description Euclidean2DShapeFactory
getShapeFactory()
A factory of shapes compatible with this environment. List<Node<T>>
getNodesWithin(Shape<Euclidean2DPosition, Euclidean2DTransformation> shape)
Gets all nodes whose shape.intersect is true for the given shape. Euclidean2DPosition
getHeading(Node<T> node)
Gets the heading of a node as a direction vector. Unit
setHeading(Node<T> node, Euclidean2DPosition direction)
Sets the heading of a node. Shape<Euclidean2DPosition, Euclidean2DTransformation>
getShape(Node<T> node)
Gets the shape of a node relatively to its position and heading in the environment. Unit
moveNodeToPosition(Node<T> node, Euclidean2DPosition newPosition)
Moves the node to the farthestPositionReachable towards the desired newPosition. Euclidean2DPosition
makePosition(Number coordinates)
Creates an euclidean position from the given coordinates. Euclidean2DPosition
farthestPositionReachable(Node<T> node, Euclidean2DPosition desiredPosition, Double hitboxRadius)
Computes the farthest position reachable by a node towards a desiredPosition, avoiding node overlapping. -
Methods inherited from class it.unibo.alchemist.model.Environment
addGlobalReaction, addLayer, addNode, addTerminator, getDimensions, getDistanceBetweenNodes, getGlobalReactions, getIncarnation, getLayer, getLayers, getLinkingRule, getNeighborhood, getNodeByID, getNodeCount, getNodes, getNodesWithinRange, getNodesWithinRange, getOffset, getPosition, getSimulation, getSize, getSizeInDistanceUnits, isTerminated, removeGlobalReaction, removeNode, setLinkingRule, setSimulation
-
Methods inherited from class it.unibo.alchemist.model.environments.Euclidean2DEnvironment
getOrigin, makePosition, makePosition
-
Methods inherited from class kotlin.collections.MutableIterable
iterator
-
Methods inherited from class it.unibo.alchemist.model.EuclideanEnvironment
moveNode
-
Methods inherited from class kotlin.collections.Iterable
forEach, spliterator
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
ContinuousPhysics2DEnvironment
ContinuousPhysics2DEnvironment(Incarnation<T, Euclidean2DPosition> incarnation)
-
-
Method Detail
-
getShapeFactory
Euclidean2DShapeFactory getShapeFactory()
A factory of shapes compatible with this environment.
-
getNodesWithin
List<Node<T>> getNodesWithin(Shape<Euclidean2DPosition, Euclidean2DTransformation> shape)
Gets all nodes whose shape.intersect is true for the given shape.
- Parameters:
shape
- the shape- Returns:
the set of nodes colliding with the given shape
-
getHeading
Euclidean2DPosition getHeading(Node<T> node)
Gets the heading of a node as a direction vector.
- Parameters:
node
- The node- Returns:
The heading of the given node
-
setHeading
Unit setHeading(Node<T> node, Euclidean2DPosition direction)
Sets the heading of a node.
- Parameters:
node
- The nodedirection
- The direction vector.
-
getShape
Shape<Euclidean2DPosition, Euclidean2DTransformation> getShape(Node<T> node)
Gets the shape of a node relatively to its position and heading in the environment.
- Parameters:
node
- The node- Returns:
Its shape
-
moveNodeToPosition
Unit moveNodeToPosition(Node<T> node, Euclidean2DPosition newPosition)
Moves the node to the farthestPositionReachable towards the desired newPosition. If the node is shapeless, it is simply moved to newPosition.
-
makePosition
Euclidean2DPosition makePosition(Number coordinates)
Creates an euclidean position from the given coordinates.
- Parameters:
coordinates
- coordinates array- Returns:
Euclidean2DPosition
-
farthestPositionReachable
Euclidean2DPosition farthestPositionReachable(Node<T> node, Euclidean2DPosition desiredPosition, Double hitboxRadius)
Computes the farthest position reachable by a node towards a desiredPosition, avoiding node overlapping. If no node is located in between, desiredPosition is returned. Otherwise, the first position where the node collides with someone else is returned. For collision purposes, hitboxes are used: each node is given a circular hitbox of radius equal to its shape's radius (shapeless nodes can't cause overlapping). The client can specify a different radius for the hitbox of the moving node.
-
-
-
-