SpringFunction
public struct SpringFunction<T> : SimulationFunction where T : VectorConvertible
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: Double
-
How damped the spring is.
Declaration
Swift
public var damping: Double
-
The minimum Double distance used for settling the spring simulation.
Declaration
Swift
public var threshold: Double
-
Creates a new
SpringFunction
instance.Declaration
Swift
public init(target: T, tension: Double = 120.0, damping: Double = 12.0, threshold: Double = 0.1)
Parameters
target
The target of the new instance.
-
Calculates acceleration for a given state of the simulation.
Declaration
Swift
public func acceleration(value: T.VectorType, velocity: T.VectorType) -> T.VectorType
-
Declaration
Swift
public func convergence(value: T.VectorType, velocity: T.VectorType) -> Convergence<T>