pub struct State {
pub position: f32,
pub velocity: f32,
pub acceleration: f32,
}Expand description
A one-dimensional motion state with position, velocity, and acceleration.
Fields§
§position: f32Where you are. This should be in millimeters.
velocity: f32How fast you’re going. This should be in millimeters per second.
acceleration: f32How fast how fast you’re going’s changing. This should be in millimeters per second squared.
Implementations§
Source§impl State
impl State
Sourcepub fn update(&mut self, delta_time: Time)
pub fn update(&mut self, delta_time: Time)
Calculate the future state assuming a constant acceleration.
Sourcepub const fn set_constant_acceleration(
&mut self,
acceleration: Quantity,
) -> Result<(), ()>
pub const fn set_constant_acceleration( &mut self, acceleration: Quantity, ) -> Result<(), ()>
Set the acceleration with a Quantity. With dimension checking enabled, sets the
acceleration and returns Ok if the argument’s Unit is correct, otherwise leaves it
unchanged and returns Err. With dimension checking disabled, always sets the acceleration
to the Quantity’s value and returns Ok, ignoring the Unit.
Sourcepub const fn set_constant_acceleration_raw(&mut self, acceleration: f32)
pub const fn set_constant_acceleration_raw(&mut self, acceleration: f32)
Set the acceleration with an f32 of millimeters per second squared.
Sourcepub const fn set_constant_velocity(
&mut self,
velocity: Quantity,
) -> Result<(), ()>
pub const fn set_constant_velocity( &mut self, velocity: Quantity, ) -> Result<(), ()>
Set the velocity to a given value with a Quantity, and set acceleration to zero. With
dimension checking enabled, sets the velocity and acceleration and returns Ok if the
argument’s Unit is correct, otherwise leaves them unchanged and returns Err. With
dimension checking disabled, ignores the Unit and always sets velocity and acceleration
and returns Ok.
Sourcepub const fn set_constant_velocity_raw(&mut self, velocity: f32)
pub const fn set_constant_velocity_raw(&mut self, velocity: f32)
Set the velocity to a given value with an f32 of millimeters per second, and set acceleration to zero.
Sourcepub const fn set_constant_position(
&mut self,
position: Quantity,
) -> Result<(), ()>
pub const fn set_constant_position( &mut self, position: Quantity, ) -> Result<(), ()>
Set the position to a given value with a Quantity, and set velocity and acceleration to
zero. With dimension checking enabled, sets the position, velocity, and acceleration and
returns Ok if the argument’s Unit is correct, otherwise leaves them unchanged and
returns Err. With dimension checking disabled, always sets the position, velocity, and
acceleration and returns Ok, ignoring the Unit.
Sourcepub const fn set_constant_position_raw(&mut self, position: f32)
pub const fn set_constant_position_raw(&mut self, position: f32)
Set the position to a given value with an f32 of millimeters, and set velocity and acceleration to zero.
Sourcepub const fn get_position(&self) -> Quantity
pub const fn get_position(&self) -> Quantity
Get the position as a Quantity.
Sourcepub const fn get_velocity(&self) -> Quantity
pub const fn get_velocity(&self) -> Quantity
Get the velocity as a Quantity.
Sourcepub const fn get_acceleration(&self) -> Quantity
pub const fn get_acceleration(&self) -> Quantity
Get the acceleration as a Quantity.
Sourcepub fn get_value(&self, position_derivative: PositionDerivative) -> Quantity
pub fn get_value(&self, position_derivative: PositionDerivative) -> Quantity
State contains a position, velocity, and acceleration. This gets the respective field of a given position derivative.
Trait Implementations§
Source§impl AddAssign for State
impl AddAssign for State
Source§fn add_assign(&mut self, other: State)
fn add_assign(&mut self, other: State)
+= operation. Read moreSource§impl DivAssign<f32> for State
impl DivAssign<f32> for State
Source§fn div_assign(&mut self, dvsr: f32)
fn div_assign(&mut self, dvsr: f32)
/= operation. Read moreSource§impl<G: Getter<Quantity, E> + ?Sized, E: Copy + Debug> Getter<State, E> for AccelerationToState<G, E>
impl<G: Getter<Quantity, E> + ?Sized, E: Copy + Debug> Getter<State, E> for AccelerationToState<G, E>
Source§impl<G: Getter<Quantity, E> + ?Sized, E: Copy + Debug> Getter<State, E> for PositionToState<G, E>
impl<G: Getter<Quantity, E> + ?Sized, E: Copy + Debug> Getter<State, E> for PositionToState<G, E>
Source§impl<G: Getter<Quantity, E> + ?Sized, E: Copy + Debug> Getter<State, E> for VelocityToState<G, E>
impl<G: Getter<Quantity, E> + ?Sized, E: Copy + Debug> Getter<State, E> for VelocityToState<G, E>
Source§impl MulAssign<f32> for State
impl MulAssign<f32> for State
Source§fn mul_assign(&mut self, coef: f32)
fn mul_assign(&mut self, coef: f32)
*= operation. Read moreSource§impl SubAssign for State
impl SubAssign for State
Source§fn sub_assign(&mut self, other: State)
fn sub_assign(&mut self, other: State)
-= operation. Read more