diff options
author | Nat Lasseter <Nat Lasseter nathan@bytemark.co.uk> | 2017-06-28 19:55:45 +0100 |
---|---|---|
committer | Nat Lasseter <Nat Lasseter nathan@bytemark.co.uk> | 2017-06-28 19:55:45 +0100 |
commit | 1c2acd3320963884821d52530b24637abd88354f (patch) | |
tree | 1a864fdb635b507c639270943c31b01f172c1d18 /particle.js | |
parent | 993442813dbee7805ef18146113872cae5892e99 (diff) |
Causally air resistance.
Diffstat (limited to 'particle.js')
-rw-r--r-- | particle.js | 6 |
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); |