pub struct FrictionSimulation {
pub tolerance: Tolerance,
/* private fields */
}Expand description
A simulation that applies a drag to slow a particle down.
Models a particle affected by fluid drag, e.g. air resistance.
The simulation ends when the velocity of the particle drops to zero (within
the current velocity tolerance).
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 FrictionSimulation
impl FrictionSimulation
Sourcepub fn new(drag: f64, position: f64, velocity: f64) -> FrictionSimulation
pub fn new(drag: f64, position: f64, velocity: f64) -> FrictionSimulation
Creates a FrictionSimulation with the given arguments, namely: the
fluid drag coefficient cₓ, a unitless value; the initial position
x₀, in the same length units as used for x; and the
initial velocity dx₀, in the same velocity units as used for
dx.
Sourcepub fn with_options(
drag: f64,
position: f64,
velocity: f64,
tolerance: Tolerance,
constant_deceleration: f64,
) -> FrictionSimulation
pub fn with_options( drag: f64, position: f64, velocity: f64, tolerance: Tolerance, constant_deceleration: f64, ) -> FrictionSimulation
Dart’s tolerance / constantDeceleration named arguments.
Sourcepub fn through(
start_position: f64,
end_position: f64,
start_velocity: f64,
end_velocity: f64,
) -> FrictionSimulation
pub fn through( start_position: f64, end_position: f64, start_velocity: f64, end_velocity: f64, ) -> FrictionSimulation
Creates a new friction simulation with its fluid drag coefficient (cₓ) set so as to ensure that the simulation starts and ends at the specified positions and velocities.
The positions must use the same units as expected from x,
and the velocities must use the same units as expected from
dx.
The sign of the start and end velocities must be the same, the magnitude of the start velocity must be greater than the magnitude of the end velocity, and the velocities must be in the direction appropriate for the particle to start from the start position and reach the end position.