SimulationFunction
public protocol SimulationFunction
Conforming types implement a dynamic function that models changes to a vector over time.
-
The type of vector driven by the simulation
Declaration
Swift
associatedtype VectorType : Vector
-
The computed acceleration for a given simulation state.
Declaration
Swift
func acceleration(for state: SimulationState<VectorType>) -> VectorType
Parameters
value
The current value of the simulation.
velocity
The current velocity of the simulation.
Return Value
A vector containing the acceleration (in units per second) based on
value
andvelocity
. -
Determines whether the simulation can converge (come to rest) for the given state.
Declaration
Swift
func convergence(for state: SimulationState<VectorType>) -> Convergence<VectorType>
-
integrate(state:time:)
Extension methodIntegrates time into an existing simulation state, returning the resulting simulation state.
The integration is done via RK4.
Declaration
Swift
public func integrate(state: SimulationState<VectorType>, time: Double) -> SimulationState<VectorType>