Flow Field3D
A precomputed distance-from-sources field over a VoxelGraph, exposed at point-level granularity for continuous-space 3D agents (drones, UAVs, AUVs). The 3D analog of FlowField.
Wraps three things that previously had to be carried in parallel: the graph, a set of goal voxels (sources), and the distanceField map. Adds point-level conversions (voxelOf / centerOf) so drones holding continuous 3D positions can query the field directly.
Construction runs one multi-source Dijkstra. Queries are O(1) for distanceAt / arrivedAt and O(|passable neighbors|) — up to 26 with Moore-26 — for directionAt. Reconstruct (with the same or different sources) to refresh; reconstruction is cheap, so building a fresh FlowField3D in initialize() of each replication is the standard pattern.
Typical use (drones routing to nearest charging volume):
class DroneDelivery(parent: ModelElement) : AgentModel(parent, "delivery") {
val graph: VoxelGraph = ...
val chargers: Set<Voxel> = setOf(Voxel(0, 0, 0), Voxel(10, 0, 0))
lateinit var field: FlowField3D
override fun initialize() {
super.initialize()
field = FlowField3D(graph, chargers)
}
}
// Per-drone: while (!field.arrivedAt(myPos)) {
// step in field.directionAt(myPos) * speed
// }Geometry model: voxels form a uniform 3D grid of side cellSize anchored at origin. Voxel (c, r, l) covers the half-open box [origin.x + c*cellSize, origin.x + (c+1)*cellSize) and similarly on y and z, with center at centerOf(Voxel(c, r, l)). For non- uniform or transformed layouts, subclass or compose; the simple uniform case covers every shipped example.
Parameters
the underlying 3D lattice
voxels treated as goals (distance = 0). Must not be empty.
side length of each voxel in continuous space. Must be positive.
continuous-space anchor of voxel (0, 0, 0)'s lower-left-bottom corner.
Constructors
Types
Mutable global defaults for FlowField3D construction. Mirrors FlowField.Defaults.
Functions
Distance from point's voxel to the nearest source. Returns Double.POSITIVE_INFINITY for points whose voxel is out of bounds, blocked, or unreachable from any source.