pub struct Newtonian {
pub speed_limit: [f32; 2],
pub acceleration: [f32; 2],
pub deceleration: [f32; 2],
pub goal: f32,
pub value: f32,
pub time: u64,
pub enabled: bool,
/* private fields */
}Expand description
A modulator that uses classical mechanics to move to its goal - it guarantees smooth
acceleration, deceleration and speed limiting regardless of settings.
The goal calculation computes an analytical solution to the motion equation. When
a new goal is set, speed_limit, acceleration and deceleration values are
picked from their respective ranges, then movement begins with the value starting
from current value with 0 velocity, accelerating at the selected rate up to the speed
limit, then decelerating at the selected rate of deceleration so that it is guaranteed
to come to a stop at the goal.
The analytical solution to the motion equation ensures that, regardless of input, the
value always accelerates and decelerates at the picked rates, and never exceeds the
speed max. If there is not enough time to reach peak speed, the value accelerates as
much as it it can while ensuring that it will decelerate and come to a stop (0 speed)
exactly at goal.
Fields§
§speed_limit: [f32; 2]Max speed range, selected on new goal
acceleration: [f32; 2]range of acceleration values selected on new goal
deceleration: [f32; 2]range of deceleration values selected on new goal
goal: f32§value: f32§time: u64Accumulated microseconds since the most recent goal was set
enabled: boolEnabling toggle