-
- All Implemented Interfaces:
-
it.unibo.alchemist.model.interfaces.Environment,it.unibo.alchemist.model.interfaces.EuclideanEnvironment,it.unibo.alchemist.model.interfaces.environments.Euclidean2DEnvironment,it.unibo.alchemist.model.interfaces.environments.Physics2DEnvironment,it.unibo.alchemist.model.interfaces.environments.PhysicsEnvironment,java.io.Serializable,kotlin.collections.Iterable,kotlin.collections.MutableIterable
public class Continuous2DEnvironment<T extends Object> extends Abstract2DEnvironment<T, Euclidean2DPosition> implements Euclidean2DEnvironment<T>, Physics2DEnvironment<T>
Implementation of Physics2DEnvironment.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classContinuous2DEnvironment.Companion
-
Field Summary
Fields Modifier and Type Field Description private final Euclidean2DShapeFactoryshapeFactoryprivate final Euclidean2DPositionorigin
-
Constructor Summary
Constructors Constructor Description Continuous2DEnvironment(Incarnation<T, Euclidean2DPosition> incarnation)
-
Method Summary
Modifier and Type Method Description Euclidean2DShapeFactorygetShapeFactory()A factory of shapes compatible with this environment. Euclidean2DPositiongetOrigin()List<Node<T>>getNodesWithin(GeometricShape<Euclidean2DPosition, Euclidean2DTransformation> shape)Gets all nodes whose shape.intersect is true for the given shape. Euclidean2DPositiongetHeading(Node<T> node)Gets the heading of a node as a direction vector. UnitsetHeading(Node<T> node, Euclidean2DPosition direction)Sets the heading of a node. GeometricShape<Euclidean2DPosition, Euclidean2DTransformation>getShape(Node<T> node)Gets the shape of a node relatively to its position and heading in the environment. UnitmoveNodeToPosition(Node<T> node, Euclidean2DPosition newPosition)Moves the node to the farthestPositionReachable towards the desired newPosition. Euclidean2DPositionmakePosition(Number coordinates)Creates an euclidean position from the given coordinates. Euclidean2DPositionfarthestPositionReachable(NodeWithShape<T, ?, ?> node, Euclidean2DPosition desiredPosition, Double hitboxRadius)node. -
Methods inherited from class it.unibo.alchemist.model.implementations.environments.Continuous2DEnvironment
computeActualInsertionPosition, includeObject, includeObject, makePosition, makePosition -
Methods inherited from class it.unibo.alchemist.model.interfaces.EuclideanEnvironment
addLayer, addNode, addTerminator, getDimensions, getDistanceBetweenNodes, getIncarnation, getLayer, getLayers, getLinkingRule, getNeighborhood, getNodeByID, getNodeCount, getNodes, getNodesWithinRange, getNodesWithinRange, getOffset, getPosition, getSimulation, getSize, getSizeInDistanceUnits, isTerminated, removeNode, setLinkingRule, setSimulation -
Methods inherited from class kotlin.collections.MutableIterable
forEach, spliterator -
Methods inherited from class it.unibo.alchemist.model.interfaces.Environment
iterator -
Methods inherited from class it.unibo.alchemist.model.interfaces.environments.Euclidean2DEnvironment
moveNode -
Methods inherited from class it.unibo.alchemist.model.implementations.environments.Abstract2DEnvironment
ifEngineAvailable, setPosition, updateNeighborhood -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
Continuous2DEnvironment
Continuous2DEnvironment(Incarnation<T, Euclidean2DPosition> incarnation)
-
-
Method Detail
-
getShapeFactory
Euclidean2DShapeFactory getShapeFactory()
A factory of shapes compatible with this environment.
-
getOrigin
Euclidean2DPosition getOrigin()
-
getNodesWithin
List<Node<T>> getNodesWithin(GeometricShape<Euclidean2DPosition, Euclidean2DTransformation> shape)
Gets all nodes whose shape.intersect is true for the given shape.
- Parameters:
shape- the shape
-
getHeading
Euclidean2DPosition getHeading(Node<T> node)
Gets the heading of a node as a direction vector.
- Parameters:
node- The node
-
setHeading
Unit setHeading(Node<T> node, Euclidean2DPosition direction)
Sets the heading of a node.
- Parameters:
node- The nodedirection- The direction vector.
-
getShape
GeometricShape<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
-
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
-
farthestPositionReachable
Euclidean2DPosition farthestPositionReachable(NodeWithShape<T, ?, ?> node, Euclidean2DPosition desiredPosition, Double hitboxRadius)
node.canFit must be true for the returned position. For a better understanding of how to compute collision points with circular hitboxes see this discussion.
-
-
-
-