Force3D

fun interface Force3D<A : AgentLike>(source)

3D analog of Force. Given an agent and the Dynamics3D it belongs to, return the 3D force vector contributed by this rule at the current simulation step.

Force3D is fun interface so concrete instances can be created with SAM-lambda syntax — see the canonical force library in Forces3D.kt:

val gravity: Force3D<Drone> = Force3D { _, _, _ -> Point3D(0.0, 0.0, -9.8) }

Same semantics as Force: read positions via dynamics.space.positionOf(other), neighbors via dynamics.space.within(pos, radius), and other agents' velocities via dynamics.velocityOf(other). Forces shouldn't mutate any state — integration happens outside the force.

Functions

Link copied to clipboard
abstract fun compute(agent: A, dynamics: Dynamics3D<A>, dt: Double): Point3D