Does toxiclibs have inherent dampening? [toxiclibs] [VerletSpring]
in
Contributed Library Questions
•
3 months ago
I'm running a very basic test of the toxiclibs physics library. I have two particles attached to each other by a spring. There are no other fields or forces. I expected them to oscillate infinitely at the same amplitude (effectively conservation of energy). However, their amplitudes decrease with time implying that energy is lost in the system.
Does anyone know if toxiclibs physics environment has default friction or dampening? Can this be removed? Could this instead be the effect of a differential equation solver that doesn't conserve energy?
Here's my code in case there's a mistake in it. It run completely fine other than the unknown source of dampening.
import toxi.physics2d.*;
import toxi.physics2d.behaviors.*;
import toxi.geom.*;
VerletPhysics2D physics;
Particle p1;
Particle p2;
void setup(){
size(640,360);
background(255);
physics = new VerletPhysics2D();
physics.setWorldBounds(new Rect(0,0,width,height));
p1 = new Particle(new Vec2D(width/2,height/2 - 90));
p2 = new Particle(new Vec2D(width/2,height/2 + 90));
physics.addParticle(p1);
physics.addParticle(p2);
VerletSpring2D spring = new VerletSpring2D(p1,p2,100,0.00001);
physics.addSpring(spring);
}
class Particle extends VerletParticle2D{
Particle(Vec2D loc){
super(loc);
}
void display(){
fill(175);
stroke(0);
ellipse(x,y,15,15);
}
}
void draw(){
background(255);
physics.update();
line(p1.x,p1.y,p2.x,p2.y);
p1.display();
p2.display();
ellipse(width/2,height/2-90,15,15);
}
I can't find anything in the documentation mentioning dampening, so any thoughts would be helpful.
Thanks,
Mserlin
1