SpringFunction
public struct SpringFunction<T> : SimulationFunction where T : Vector
Implements a simple spring acceleration function.
-
The target of the spring.
Declaration
Swift
public var target: T
-
Strength of the spring.
Declaration
Swift
public var tension: Scalar
-
How damped the spring is.
Declaration
Swift
public var damping: Scalar
-
The minimum scalar distance used for settling the spring simulation.
Declaration
Swift
public var threshold: Scalar
-
Creates a new
SpringFunction
instance.Declaration
Swift
public init(target: T = T.zero)
Parameters
target
The target of the new instance.
-
Calculates acceleration for a given state of the simulation.
Declaration
Swift
public func acceleration(for state: SimulationState<T>) -> T
-
Declaration
Swift
public func convergence(for state: SimulationState<T>) -> Convergence<T>