Hi there,

I'm currently implementing a version of the Position Based Dynamics paper by Mueller. However, I'm having some problems with the collision constraint they're using ( C = q*n - h ), mainly that I'm apparently somewhat mixed up in my hand and just can't manage to find the correct gradients for the function.

For the single vertex it's pretty obvious that the gradient is the normal of the triangles, however the gradients of the triangle vertices are not so clear. I tried calculating them but somehow I always mess up somewhere (i.e. it doesn't match numerically calculated gradients I'm using for testing).

It would be great if someone could help me out on this.

## Position based dynamics collisions

### Re: Position based dynamics collisions

You could try to express the position in triangle as barycentric coordinate let say: P0*u+P1*v+P2*(1-u-v)

then your triangle gradients simply become :

[ -N*u , -N*v , -N*(1-u-v) ]

(based on C=(q-(P0 u + P1 v + P2 (1-u-v))).N )

Hope its work and help,

Nathanael.

then your triangle gradients simply become :

[ -N*u , -N*v , -N*(1-u-v) ]

(based on C=(q-(P0 u + P1 v + P2 (1-u-v))).N )

Hope its work and help,

Nathanael.

### Re: Position based dynamics collisions

D'oh, I knew this would end up being something absolutely easy. Thank you so much, works just like it's supposed to

### Re: Position based dynamics collisions

Is thi paper of Muller (position based dynamics) implemented somewhere in the bullet source code ?