Dynamics2DEnvironment

Any implementing Environment should take care of physical dynamics, in particular collision detection and response. This interface provides some hooks in order to be able to manage some of the node's physical state.

Inheritors

Properties

Link copied to clipboard

The current position of this node, see currentPositionOf.

Link copied to clipboard
abstract val dimensions: Int

The number of dimensions of this environment.

Link copied to clipboard

Return the Incarnation used to initialize the entities of this Environment, if it has been set.

Link copied to clipboard
abstract val isTerminated: Boolean

Whether any of the terminators is satisfied.

Link copied to clipboard

Return all the Layers in this Environment.

Link copied to clipboard

The observable neighborhood of this node, see neighborhoodOf.

Link copied to clipboard
abstract var networkModel: NetworkModel<T>

The current NetworkModel, which must be bound to this environment. Assigning a new model publishes the neighborhood it provides for every node in the environment.

Link copied to clipboard
abstract val nodeCount: Observable<Int>

Returns an Observable view of the number of Nodes currently in the Environment.

Link copied to clipboard
abstract val nodes: ObservableList<Node<T>>

An ordered Observable view of all the Nodes that exist in current Environment.

Link copied to clipboard
abstract val offset: DoubleArray

This method allows to know which are the smallest coordinates represented. Return an array of length dimensions containing the smallest coordinates for each dimension.

Link copied to clipboard

Create a position corresponding to the origin of this environment.

Link copied to clipboard

The observable position of this node, see positionOf.

Link copied to clipboard

The reactions registered with this host, in registration order; ObservableList.current is a snapshot.

Link copied to clipboard

A factory of shapes compatible with this environment.

Link copied to clipboard

Return the current Simulation, if present, or throws an IllegalStateException otherwise.

Link copied to clipboard

Return the current Simulation, if present, or null otherwise.

Link copied to clipboard
abstract val size: DoubleArray

The size of the environment as an array of length getDimensions(). This method must return distance measured with the same unit used by the positions. No non-euclidean distance metrics are allowed.

Link copied to clipboard

This method returns the size of the environment as an array of length .getDimensions. This method must return distance measured with the same unit used for measuring distances. It may or may not return the same result of .getSize.

Functions

Link copied to clipboard
abstract fun addLayer(molecule: Molecule, layer: Layer<T, Euclidean2DPosition>)

Associates layer with molecule. Layers are part of the environment setup: association fails once the environment is attached to a simulation, and a molecule cannot be associated with more than one layer.

Link copied to clipboard
abstract fun addNode(node: Node<T>, position: Euclidean2DPosition): Boolean

Adds a new node to this environment in a specific position. The environment is responsible for calling the right method of the simulation to ensure that the reaction is properly scheduled. The function returns true if the node is added to the environment.

Link copied to clipboard
abstract fun addReaction(reaction: Reaction<T>)

Registers reaction and notifies the running simulation when it was not already present. Fails if this is not the Reaction.host of reaction.

Link copied to clipboard

Add a terminator indicating whether the simulation should be considered finished. The simulation finishes as soon as any of the terminators is satisfied.

Link copied to clipboard
fun <T> Environment<T, *>.allShortestHopPaths(): SymmetricMatrix<Double>

Calculates the shortest paths using the Floyd-Warshall algorithm calculating the Hop Distance between nodes.

Link copied to clipboard
fun <T> Environment<T, *>.allSubNetworks(computeDistance: (Node<T>, Node<T>) -> Double = environmentMetricDistance()): Set<Network<T>>

Computes the diameter of all subnetworks in the environment. The diameter is the longest shortest path between any two nodes. Returns a Map containing the subnetwork related to each Node of the environment.

Link copied to clipboard
fun <T> Environment<T, *>.allSubNetworksByNode(computeDistance: (Node<T>, Node<T>) -> Double = environmentMetricDistance()): Map<Node<T>, Network<T>>

Computes the diameter of all subnetworks in the environment. The diameter is the longest shortest path between any two nodes. Returns a Map mapping each node to the subnetwork it belongs to.

Link copied to clipboard

Computes the diameter of all subnetworks in the environment. The diameter is the longest shortest path between any two nodes, evaluated using the allShortestHopPaths method. Returns a Set containing the subnetworks.

Link copied to clipboard

Computes the diameter of all subnetworks in the environment. The diameter is the longest shortest path between any two nodes, evaluated using the allShortestHopPaths method. Returns a Set containing the subnetworks.

Link copied to clipboard
open operator fun contains(node: Node<T>): Boolean

Whether node is part of this environment.

Link copied to clipboard

Retrieves node's current position.

Link copied to clipboard
abstract fun distanceBetween(n1: Node<T>, n2: Node<T>): Double

Measures the distance between two nodes (n1, n2) in the environment.

Link copied to clipboard
open fun Node<T>.distanceTo(other: Node<T>): Double

The distance between this node and other, see distanceBetween.

Link copied to clipboard

The farthest position that node reaches moving straight from its current position towards desired: desired itself, unless the constraints of this environment, such as its bounds, its obstacles, or the bodies of the other nodes, stop node earlier. moveNodeTo moves nodes to this position.

Link copied to clipboard
abstract fun getHeading(node: Node<T>): Euclidean2DPosition

Gets the heading of a node as a direction vector.

Link copied to clipboard

Gets all nodes whose shape.intersect is true for the given shape.

Link copied to clipboard

Gets the shape of a node relatively to its position and heading in the environment.

Link copied to clipboard
abstract fun getVelocity(node: Node<T>): Euclidean2DPosition

Get node's current linear velocity.

Link copied to clipboard

Returns true the network is segmented, false otherwise.

Link copied to clipboard
abstract fun layerFor(molecule: Molecule): Layer<T, Euclidean2DPosition>?

Get the Layer associate to the given molecule. If no Layer is associated with the given molecule, return null.

Link copied to clipboard
open fun makePosition(coordinates: List<Number>): Euclidean2DPosition
open fun makePosition(vararg coordinates: Number): Euclidean2DPosition

Given the coordinates of the point, returns a Position compatible with this environment.

Creates a new Euclidean2DPosition.

Link copied to clipboard
open fun Node<T>.moveBy(displacement: Euclidean2DPosition)

Moves this node by displacement, relative to its current position, see moveNodeBy.

Link copied to clipboard
open fun moveNodeBy(node: Node<T>, displacement: Euclidean2DPosition)

Moves node by displacement, relative to its current position, through moveNodeTo. Environments constraining movements should override moveNodeTo rather than this function, so that their constraints apply to absolute movements as well.

Link copied to clipboard
abstract fun moveNodeTo(node: Node<T>, position: Euclidean2DPosition)

Moves node to position. If node movement is unsupported, it does nothing.

Link copied to clipboard
open fun Node<T>.moveTo(position: Euclidean2DPosition)

Moves this node to position, see moveNodeTo.

Link copied to clipboard
abstract fun neighborhoodOf(node: Node<T>): Observable<Neighborhood<T>>

Given a node, this method returns an observable view of its neighborhood.

Link copied to clipboard

Returns the diameter of the network in environment units if it is not segmented, and NaN otherwise.

Link copied to clipboard

Returns the hop-distance diameter of the network if it is not segmented, and NaN otherwise.

Computes the network diameter of the segment containing node.

Link copied to clipboard
abstract fun nodesAround(position: Euclidean2DPosition, range: Double): List<Node<T>>

Given a position this method returns a list of all the surrounding nodes within the given range. Note that this method (depending on the implementation) might be not optimized.

abstract fun nodesAround(node: Node<T>, range: Double): List<Node<T>>

Given a node this method returns a list of all the surrounding nodes within the given range. Note that this method (depending on the implementation) might be not optimized, and it's consequently much better to use Environment.neighborhoodOf and filter the neighborhood if you are sure that all the nodes within the range are connected to the center.

Link copied to clipboard

The nodes within range of this position, see nodesAround.

open fun Node<T>.nodesInRange(range: Double): List<Node<T>>

The nodes within range of this node, see nodesAround.

Link copied to clipboard
abstract fun nodeWithId(id: Int): Node<T>

Allows accessing a Node in this Environment known its id. Depending on the implementation, this method may or may not be optimized (namely, id could run in constant or linear time with the number of nodes).

Link copied to clipboard
abstract fun observeLayerValue(molecule: Molecule, node: Node<T>): Observable<T?>

Observes the value of the Layer associated with molecule at the position of node. The observable emits when node moves to a position where the value differs, and when the layer changes the value at the current position of node. Its value is null while no layer is associated with molecule, and it emits when one is: observables created during setup follow layers associated later.

Link copied to clipboard
abstract fun observeNodesAround(node: Node<T>, range: Double): ObservableSet<Node<T>>

An Observable alternative to nodesAround.

Link copied to clipboard

Observes the nodes within range of this position, see observeNodesAround.

Observes the nodes within range of this node, see observeNodesAround.

Link copied to clipboard

Observe the position of a node.

Link copied to clipboard
open fun Node<T>.remove()

Removes this node, see removeNode.

open fun Reaction<T>.remove()

Unregisters this reaction from its host, see removeReaction.

Link copied to clipboard
abstract fun removeNode(node: Node<T>)

Removes node. If node removal is unsupported, it does nothing.

Link copied to clipboard
abstract fun removeReaction(reaction: Reaction<T>)

Unregisters reaction and notifies the running simulation when it was actually present.

Link copied to clipboard
abstract fun setHeading(node: Node<T>, direction: Euclidean2DPosition)

Sets the heading of a node.

Link copied to clipboard
abstract fun setVelocity(node: Node<T>, velocity: Euclidean2DPosition)

Set node's current linear velocity.

Link copied to clipboard
infix fun <T, P : Position<P>> Environment<T, P>.shouldEqual(other: Environment<T, P>)
Link copied to clipboard
fun <T, P : Position<out P>, TS : Any> Environment<T, P>.toEnvironmentSurrogate(toConcentrationSurrogate: (T) -> TS): EnvironmentSurrogate<TS, PositionSurrogate>

A function that maps an Environment to its surrogate class (EnvironmentSurrogate). Use the toSuitablePositionSurrogate strategy for PositionSurrogate mapping.

fun <T, P : Position<out P>, TS : Any, PS : PositionSurrogate> Environment<T, P>.toEnvironmentSurrogate(toConcentrationSurrogate: (T) -> TS, toPositionSurrogate: (P) -> PS): EnvironmentSurrogate<TS, PS>

A function that maps an Environment to its surrogate class (EnvironmentSurrogate).

Link copied to clipboard

A position with these coordinates, see makePosition.

Link copied to clipboard
abstract fun updatePhysics(elapsedTime: Double)

Compute any collision response and update node positions.