0
101 Sep 05, 2005 at 17:08

In 2D, using the sep. axis theorem, a collision leaves me with a vector that represents the distance I need to move to get out of collision. this works fine, but I’m not clear on how I apply surface friction and restitution. If I simply project out of collision I have a dead, but very slipperly surface.

Anyone have a code examples of what to do after you have the distance vector of the collision. This is in a Verlet system.

#### 6 Replies

0
165 Sep 06, 2005 at 05:16

Do you also have a normal vector for the surface of collision? If so, then you can do friction by dampening the objects’ velocities in the directions perpendicular to the normal (this is a little tricky to do in Verlet, since it doesn’t have explicit velocities, but just needs a bit of math).

For restitution, move the object out by twice the distance vector (fully elastic collision), or by somewhere between 1 and 2 times the distance vector for partially inelastic collisions.

0
101 Sep 07, 2005 at 00:24

Thanks, this is what I ended up with :

public function resolveParticleCollision(p:Particle, sysObj:ParticleSystem):Void {

if (isParticleColliding(p)) {

// the projection vector is also our normal for collision response
var normal:Vector = new Vector(p.mtd.x, p.mtd.y);
normal.normalize();

// get the velocity
var vel:Vector = p.curr.minusNew(p.prev);
var sDotV:Number = normal.dot(vel);

// is the particle moving towards the surface
if (sDotV < 0) {

// compute momentum of particle perpendicular to normal
var velProjection:Vector = vel.minusNew(normal.multNew(sDotV));
var perpMomentum:Vector = velProjection.multNew(sysObj.coeffFric);

// compute momentum of particle in direction of normal
var normMomentum:Vector = normal.multNew(sDotV * sysObj.coeffRest);
var totalMomentum:Vector = normMomentum.plusNew(perpMomentum);

// set new velocity w/ total momentum
var newVel:Vector = vel.minusNew(totalMomentum);

// project out of collision
p.curr.plus(p.mtd);

// apply new velocity
p.prev = p.curr.minusNew(newVel);
}
}
}

0
165 Sep 07, 2005 at 03:36

Just curious, but what language is that? It looks a little like a cross between Java and Delphi…

0
101 Sep 07, 2005 at 08:42

I think you will find this link usefull: http://www.d6.com/users/checker/dynamics.htm

0
101 Sep 07, 2005 at 09:58

@Reedbeta

Just curious, but what language is that? It looks a little like a cross between Java and Delphi… [snapback]20941[/snapback]

It seems more like JScript (a MS extension to JavaScript that has now been “.NETified” :D

0
101 Sep 09, 2005 at 19:40

@Reedbeta

Just curious, but what language is that? It looks a little like a cross between Java and Delphi… [snapback]20941[/snapback]

It’s Actionscript 2, used in Flash. I like to think of it as Java’s retarded little brother.