desired Velocity3D
fun <A : AgentLike> desiredVelocity3D(speed: Double, tau: Double, direction: (agent: A, dynamics: Dynamics3D<A>) -> Point3D): Force3D<A>(source)
Helbing-style desired-velocity relaxation force in 3D: F = mass * (v_desired - v_current) / tau. Pulls the agent's velocity toward direction * speed over a timescale of tau.
The direction function should return a unit vector — typically flow.directionAt(pos) from a FlowField3D. Zero direction yields zero force.
dynamics.addForce(desiredVelocity3D(speed = 5.0, tau = 0.5) { agent, dyn ->
val pos = dyn.space.positionOf(agent) ?: return@desiredVelocity3D Point3D.ORIGIN
flow.directionAt(pos)
})Content copied to clipboard