pub struct ClampedSimulation {
pub simulation: Box<dyn Simulation>,
pub x_min: f64,
pub x_max: f64,
pub dx_min: f64,
pub dx_max: f64,
pub tolerance: Tolerance,
}Expand description
A simulation that applies limits to another simulation.
The limits are only applied to the other simulation’s outputs. For example, if a maximum position was applied to a gravity simulation with the particle’s initial velocity being up, and the acceleration being down, and the maximum position being between the initial position and the curve’s apogee, then the particle would return to its initial position in the same amount of time as it would have if the maximum had not been applied; the difference would just be that the position would be reported as pinned to the maximum value for the times that it would otherwise have been reported as higher.
Similarly, this means that the x value will change at a
rate that does not match the reported dx value while
one or the other is being clamped.
The is_done logic is unaffected by the clamping;
it reflects the logic of the underlying simulation.
Fields§
§simulation: Box<dyn Simulation>§x_min: f64The minimum to apply to x.
x_max: f64The maximum to apply to x.
dx_min: f64The minimum to apply to dx.
dx_max: f64The maximum to apply to dx.
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 ClampedSimulation
impl ClampedSimulation
Sourcepub fn new(
simulation: Box<dyn Simulation>,
x_min: f64,
x_max: f64,
dx_min: f64,
dx_max: f64,
) -> ClampedSimulation
pub fn new( simulation: Box<dyn Simulation>, x_min: f64, x_max: f64, dx_min: f64, dx_max: f64, ) -> ClampedSimulation
Creates a ClampedSimulation that clamps the given simulation.
The named arguments specify the ranges for the clamping behavior, as
applied to x and dx.