summaryrefslogtreecommitdiff
path: root/src/force/drag.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/force/drag.rs')
-rw-r--r--src/force/drag.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/force/drag.rs b/src/force/drag.rs
new file mode 100644
index 0000000..ef859a0
--- /dev/null
+++ b/src/force/drag.rs
@@ -0,0 +1,15 @@
+use crate::particle_system::Scalar;
+
+use super::Force;
+
+pub struct Drag {
+ pub coefficient: Scalar,
+}
+
+impl Force for Drag {
+ fn apply(&self, particles: &mut Vec<crate::particle_system::Particle>) {
+ for particle in particles {
+ particle.apply_force(-self.coefficient * particle.velocity);
+ }
+ }
+}