Loading...
Logo
Processing Forum
Hi

I was wondering what the difference is between the methods 'addForce' and 'addVelocity' in the VerletParticle class? 

Seems to do the same, or?

Copy code
  1. import toxi.geom.*;
  2. import toxi.physics2d.*;

  3. VerletPhysics2D physics;
  4. VerletParticle2D pForce, pVelocity;

  5. void setup(){
  6.   size(600,600);  
  7.   noStroke();
  8.   fill(0);
  9.   smooth();
  10.   physics = new VerletPhysics2D(); 
  11.   physics.setDrag( 0.01f );
  12.   physics.setWorldBounds(new Rect(0,0, width, height));
  13.   pForce    = new VerletParticle2D(300,300); 
  14.   pVelocity = new VerletParticle2D(300,300);  
  15.   pForce.addForce(new Vec2D(1,1));
  16.   pVelocity.addVelocity(new Vec2D(-1,1));
  17.   physics.addParticle(pForce);
  18.   physics.addParticle(pVelocity);

  19. }

  20. void draw(){
  21.   background(255);  
  22.   physics.update();
  23.   ellipse(pForce.x, pForce.y, 5, 5);
  24.   ellipse(pVelocity.x, pVelocity.y, 5, 5);
  25. }

Replies(1)

Can't say exactly for toxiclibs, but: no, it shouldn't be the same.

In physics, force is proportional to the acceleration (the proportionality constant being the mass), which describes the change of the velocity with time, but not the velocity itself (in other words, acceleration is the first derivative of the velocity).

E.g. a particle moves at constant velocity as long as no force is exerted to it (v = some constant, f = 0; here you already see that v and f need not be the same, except when v also is 0). As soon as an external force is applied, the particle will change direction and velocity.