SpringSimulation constructor

SpringSimulation(
  1. SpringDescription spring,
  2. double start,
  3. double end,
  4. double velocity, {
  5. bool snapToEnd = false,
  6. Tolerance tolerance = Tolerance.defaultTolerance,
})

Creates a spring simulation from the provided spring description, start distance, end distance, and initial velocity.

The units for the start and end distance arguments are arbitrary, but must be consistent with the units used for other lengths in the system.

The units for the velocity are L/T, where L is the aforementioned arbitrary unit of length, and T is the time unit used for driving the SpringSimulation.

If snapToEnd is true, x will be set to end and dx to 0 when isDone returns true. This is useful for transitions that require the simulation to stop exactly at the end value, since the spring may not naturally reach the target precisely. Defaults to false.

Implementation

SpringSimulation(
  SpringDescription spring,
  double start,
  double end,
  double velocity, {
  bool snapToEnd = false,
  super.tolerance,
}) : _endPosition = end,
     _solution = _SpringSolution(spring, start - end, velocity),
     _snapToEnd = snapToEnd;