pub struct GravitySimulation {
pub tolerance: Tolerance,
/* private fields */
}Expand description
A simulation that applies a constant accelerating force.
Models a particle that follows Newton’s second law of motion. The simulation ends when the position exceeds a defined threshold.
Fields§
§tolerance: ToleranceHow close to the actual end of the simulation a value at a particular
time must be before is_done considers the
simulation to be “done”.
Implementations§
Source§impl GravitySimulation
impl GravitySimulation
Sourcepub fn new(
acceleration: f64,
distance: f64,
end_distance: f64,
velocity: f64,
) -> GravitySimulation
pub fn new( acceleration: f64, distance: f64, end_distance: f64, velocity: f64, ) -> GravitySimulation
Creates a GravitySimulation using the given arguments, which are,
respectively: an acceleration that is to be applied continually over
time; an initial position relative to an origin; the magnitude of the
distance from that origin beyond which (in either direction) to consider
the simulation to be “done”, which must be positive; and an initial
velocity.
The initial position and maximum distance are measured in arbitrary
length units L from an arbitrary origin. The units will match those used
for x.
The time unit T used for the arguments to x,
dx, and is_done, combined
with the aforementioned length unit, together determine the units that
must be used for the velocity and acceleration arguments: L/T and L/T²
respectively. The same units of velocity are used for the velocity
obtained from dx.