blob: 0a517897a8412d22e441900412af0f50aa58265a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
use particle_system::{Particle, ParticleSystem, Point, Vector};
use solver::Solver;
mod particle_system;
mod solver;
fn main() {
let dt = 0.01;
let mut system = ParticleSystem {
particles: vec![Particle::new(Point::origin(), 1.0)],
t: 0.0,
};
let gravity = -9.8 * Vector::y();
for i in 0..3 {
println!("Iteration #{i}");
for particle in &mut system.particles {
particle.reset_force();
}
for particle in &mut system.particles {
particle.apply_force(gravity);
}
system.step(dt);
println!("{:?}", system);
}
}
|