Spring

public struct Spring

A structure representing the characteristics of spring motion.

  • The mass of the object attached to the end of the spring. Must be greater than 0. Defaults to one.

    Declaration

    Swift

    public var mass: Double
  • The spring stiffness coefficient. Must be greater than 0. Defaults to 100.

    Declaration

    Swift

    public var stiffness: Double
  • The damping coefficient. Must be greater than or equal to 0. Defaults to 10.

    Declaration

    Swift

    public var damping: Double
  • The initial velocity of the object attached to the spring. Defaults to zero, which represents an unmoving object. Negative values represent the object moving away from the spring attachment point, positive values represent the object moving towards the spring attachment point.

    Declaration

    Swift

    public var initialVelocity: Double
  • Initializes a new Spring structure - parameter mass: The mass for the object - parameter stiffness: The stiffness of the spring - parameter damping: The damping coefficient used to calculate the motion of the object - parameter initialVelocity: The initial velocity for the object

    Declaration

    Swift

    public init(mass: Double = 1.0, stiffness: Double = 100.0, damping: Double = 10.0, initialVelocity: Double = 1.0)

    Parameters

    mass

    The mass for the object

    stiffness

    The stiffness of the spring

    damping

    The damping coefficient used to calculate the motion of the object

    initialVelocity

    The initial velocity for the object