1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//! Flutter counterpart: `physics/simulation.dart`.
use Debug;
use crateTolerance;
/// The base class for all simulations.
///
/// A simulation models an object, in a one-dimensional space, on which
/// particular forces are being applied, and exposes:
///
/// * The object's position, [`x`](Simulation::x)
/// * The object's velocity, [`dx`](Simulation::dx)
/// * Whether the simulation is "done", [`is_done`](Simulation::is_done)
///
/// A simulation is generally "done" if the object has, to a given
/// [`tolerance`](Simulation::tolerance), come to a complete rest.
///
/// The [`x`](Simulation::x), [`dx`](Simulation::dx), and
/// [`is_done`](Simulation::is_done) functions take a time argument which
/// specifies the time for which they are to be evaluated. In principle,
/// simulations can be stateless, and thus can be queried with arbitrary times.
/// In practice, however, some simulations are not, and calling any of these
/// functions will advance the simulation to the given time.
///
/// As a general rule, therefore, a simulation should only be queried using
/// times that are equal to or greater than all times previously used for that
/// simulation.
///
/// Simulations do not specify units for distance, velocity, and time. Client
/// should establish a convention and use that convention consistently with all
/// related objects.