pub struct SpringSimulation {
pub tolerance: Tolerance,
/* private fields */
}Expand description
A spring simulation.
Models a particle attached to a spring that follows Hooke’s law.
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 SpringSimulation
impl SpringSimulation
Sourcepub fn new(
spring: SpringDescription,
start: f64,
end: f64,
velocity: f64,
) -> SpringSimulation
pub fn new( spring: SpringDescription, start: f64, end: f64, velocity: f64, ) -> SpringSimulation
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 snap_to_end is true, x will be set to end and
dx to 0 when is_done
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.
Sourcepub fn with_options(
spring: SpringDescription,
start: f64,
end: f64,
velocity: f64,
snap_to_end: bool,
tolerance: Tolerance,
) -> SpringSimulation
pub fn with_options( spring: SpringDescription, start: f64, end: f64, velocity: f64, snap_to_end: bool, tolerance: Tolerance, ) -> SpringSimulation
Dart’s snapToEnd / tolerance named arguments.
Sourcepub fn spring_type(&self) -> SpringType
pub fn spring_type(&self) -> SpringType
The kind of spring being simulated, for debugging purposes.
This is derived from the SpringDescription provided to the
SpringSimulation::new constructor.