From 1c2acd3320963884821d52530b24637abd88354f Mon Sep 17 00:00:00 2001 From: Nat Lasseter Date: Wed, 28 Jun 2017 19:55:45 +0100 Subject: Causally air resistance. --- particle.js | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'particle.js') 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); -- cgit v1.2.1