use nalgebra::{Point as PointBase, SVector}; pub const N: usize = 2; pub type Scalar = f32; pub type Vector = SVector; pub type Point = PointBase; #[derive(Debug)] pub struct Particle { pub mass: Scalar, pub position: Point, pub velocity: Vector, /// Force accumulator pub force: Vector, } impl Particle { pub fn new(position: Point, mass: Scalar) -> Self { Self { mass, position, velocity: Vector::zeros(), force: Vector::zeros(), } } pub fn apply_force(&mut self, force: Vector) { self.force += force; } pub fn reset_force(&mut self) { self.force = Vector::zeros() } } #[derive(Debug)] pub struct ParticleSystem { pub particles: Vec, /// Simulation clock pub t: Scalar, }