pub struct SimState { /* private fields */ }Expand description
Simulation state.
Contains all state variables needed to reproduce the simulation.
Implementations§
Source§impl SimState
impl SimState
Sourcepub fn num_bodies(&self) -> usize
pub fn num_bodies(&self) -> usize
Get number of bodies.
Sourcepub fn add_body(&mut self, mass: f64, position: Vec3, velocity: Vec3)
pub fn add_body(&mut self, mass: f64, position: Vec3, velocity: Vec3)
Add a body to the simulation.
Sourcepub fn positions_mut(&mut self) -> &mut [Vec3]
pub fn positions_mut(&mut self) -> &mut [Vec3]
Get mutable body positions.
Sourcepub fn velocities(&self) -> &[Vec3]
pub fn velocities(&self) -> &[Vec3]
Get body velocities.
Sourcepub fn velocities_mut(&mut self) -> &mut [Vec3]
pub fn velocities_mut(&mut self) -> &mut [Vec3]
Get mutable body velocities.
Sourcepub fn forces_mut(&mut self) -> &mut [Vec3]
pub fn forces_mut(&mut self) -> &mut [Vec3]
Get mutable body forces.
Sourcepub fn set_position(&mut self, index: usize, position: Vec3)
pub fn set_position(&mut self, index: usize, position: Vec3)
Sourcepub fn set_velocity(&mut self, index: usize, velocity: Vec3)
pub fn set_velocity(&mut self, index: usize, velocity: Vec3)
Sourcepub fn apply_force(&mut self, index: usize, force: Vec3)
pub fn apply_force(&mut self, index: usize, force: Vec3)
Sourcepub fn clear_forces(&mut self)
pub fn clear_forces(&mut self)
Clear all forces (called at start of each step).
Sourcepub fn set_potential_energy(&mut self, energy: f64)
pub fn set_potential_energy(&mut self, energy: f64)
Set potential energy (called by domain engine).
Sourcepub fn kinetic_energy(&self) -> f64
pub fn kinetic_energy(&self) -> f64
Get total kinetic energy.
Sourcepub const fn potential_energy(&self) -> f64
pub const fn potential_energy(&self) -> f64
Get potential energy.
Sourcepub fn total_energy(&self) -> f64
pub fn total_energy(&self) -> f64
Get total energy (kinetic + potential).
Sourcepub fn add_constraint(&mut self, name: impl Into<String>, violation: f64)
pub fn add_constraint(&mut self, name: impl Into<String>, violation: f64)
Add a constraint violation.
Sourcepub fn clear_constraints(&mut self)
pub fn clear_constraints(&mut self)
Clear all constraints.
Sourcepub fn constraint_violations(&self) -> impl Iterator<Item = (String, f64)> + '_
pub fn constraint_violations(&self) -> impl Iterator<Item = (String, f64)> + '_
Get constraint violations.
Sourcepub fn all_finite(&self) -> bool
pub fn all_finite(&self) -> bool
Check if all state values are finite.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for SimState
impl<'de> Deserialize<'de> for SimState
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for SimState
impl RefUnwindSafe for SimState
impl Send for SimState
impl Sync for SimState
impl Unpin for SimState
impl UnsafeUnpin for SimState
impl UnwindSafe for SimState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more