aboutsummaryrefslogtreecommitdiff
path: root/particle.js
diff options
context:
space:
mode:
Diffstat (limited to 'particle.js')
-rw-r--r--particle.js6
1 files changed, 6 insertions, 0 deletions
diff --git a/particle.js b/particle.js
index 66f4f6e..c62dd47 100644
--- a/particle.js
+++ b/particle.js
@@ -9,6 +9,12 @@ function Particle(x, y, m, c) {
this.acc.add(p5.Vector.div(force, this.mass));
}
+ this.applyDrag = function(drag_coeff) {
+ var rev_vel = createVector().sub(this.vel);
+ var drag = rev_vel.mult(drag_coeff);
+ this.applyForce(drag);
+ }
+
this.update = function() {
this.vel.add(this.acc);
this.pos.add(this.vel);