Dynamics

  • DynamicSolver simulates changes to a value over time, based on a function that calculates acceleration after each time step.

    The RK4 method is used to integrate the acceleration function.

    Constant time steps are not guarenteed elsewhere in the framework. Due to the nature of dynamic functions, however, it is desirable to maintain a constant update interval for a dynamic simulation. DynamicSolver instances maintain their own internal time state. When `advance(elapsed:) is called on an instance, it may run an arbitrary number of time steps internally (and call the underlying function as needed) in order to catch up to the outside time. It then uses linear interpolation to match the internal state to the required external time in order to return the most precise calculations.

    See more

    Declaration

    Swift

    public struct DynamicSolver<F: DynamicFunctionType> : Advanceable
  • Animates changes to a value using spring physics.

    Instances of Spring should be used in situations where spring physics are the only animation type required, or when convenient access to the properties of a running spring simulation is needed.

    The focused API of this class makes it more convenient in such cases than using an Animatable instance, where a new spring animation would have to be added each time the spring needed to be modified.

    let s = Spring(value: CGPoint.zero)
    
    s.changed.observe { (value) in
      // do something with the value when it changes
    }
    
    s.target = CGPoint(x: 100.0, y: 200.0)
    // Off it goes!
    
    See more

    Declaration

    Swift

    public final class Spring<T: VectorConvertible>