GravityFunction

public struct GravityFunction : SimulationFunction

Implements a two-dimensional gravity simulation function.

  • The point that the value will be pulled toward.

    Declaration

    Swift

    public var target: Vector2
  • The minimum distance from target for which acceleration will be calculated. Larger values avoid dramatic slingshot effects when the value makes a pass near the target value.

    Declaration

    Swift

    public var minRadius: Scalar
  • The minimum distance from the target that the value must be in order for the simulation to converge.

    Declaration

    Swift

    public var threshold: Scalar
  • Initializes a new gravity function with the given target.

    Declaration

    Swift

    public init(target: Vector2)
  • Declaration

    Swift

    public func acceleration(for state: SimulationState<Vector2>) -> Vector2
  • Declaration

    Swift

    public func convergence(for state: SimulationState<Vector2>) -> Convergence<Vector2>