PhysicsSolving

public protocol PhysicsSolving

This protocol represents physics solving systems that calculate the positions of values over time, and is used in PhysicsMotion and PathPhysicsMotion to update property values.

  • The velocity value to use in physics calculations.

    Declaration

    Swift

    var velocity: Double { get set }
  • The friction value between 0.0 and 1.0, to be applied in physics calculations. Provided values outside of that range should be clamped to the closest minimum or maximum value by classes conforming to this protocol.

    Declaration

    Swift

    var friction: Double { get set }
  • The restitution value from 0.0 to 1.0 which represents the elasticity of the object and used in collision calculations, with 0.0 representing a perfectly inelastic collision (in which the object does not rebound at all during a collision), and 1.0 representing a perfectly elastic collision (in which the object rebounds with no loss of velocity). Provided values outside of that range should be clamped to the closest minimum or maximum value by classes conforming to this protocol.

    Declaration

    Swift

    var restitution: Double { get set }
  • This Boolean represents whether collision detections are active in the physics simulation. If true, collisions will be checked using the start and end properties of each PropertyData object passed in to the solve(forPositions:timestamp:) method.

    Declaration

    Swift

    var useCollisionDetection: Bool { get set }
  • This method updates 1D positions using physics calculations.

    Declaration

    Swift

    func solve(forPositions properties: [PropertyData], timestamp: TimeInterval) -> [Double]

    Parameters

    properties

    An array of PropertyData objects representing the current property values are being modified by the physics calculations. Their current property represents the current value being modified. The start and end properties are unused, except if this object’s areCollisionsActive property is true, in which case they represent collision boundaries for each property.

    timestamp

    The current timestamp.

    Return Value

    An array of updated positions in the same order as the array passed in.

  • This method should reset the physics system to its initial velocity and clear the timestamp used to calculate the current step.

    Declaration

    Swift

    func reset()
  • This method should pause the physics system, preventing any new calculations.

    Declaration

    Swift

    func pause()
  • This method should resume the physics system.

    Declaration

    Swift

    func resume()
  • This method should reverse the current direction of the velocity.

    Declaration

    Swift

    func reverseDirection()