Question about deformable solid paper

Please don't post Bullet support questions here, use the above forums instead.
coderchris
Posts: 49
Joined: Fri Aug 18, 2006 11:50 pm

Question about deformable solid paper

Post by coderchris »

Im attempting to implement the deformable object alg. outlined in this paper:
http://graphics.ethz.ch/~brunoh/downloa ... _CGI04.pdf

I understand and can calculate the deformation energy for the three different cases (line, triangle, tetrahedron). What I dont understand is how these energys are converted to forces that I can apply to my verticies. They have two equations in the paper that calculate some forces, but I dont understand how they would be written in code. Also, the equations they have dont seem to give a directional force, just a magnitude. How do I calculate the direction of the forces to apply to each vertex?

Thanks,
Chris
Antonio Martini
Posts: 126
Joined: Wed Jul 27, 2005 10:28 am
Location: SCEE London

Re: Question about deformable solid paper

Post by Antonio Martini »

the Lagrangian approach is a popular way of deriving the equations of motion from the potential and kinetic energy:

http://scienceworld.wolfram.com/physics/Lagrangian.html
http://www.nyu.edu/classes/tuckerman/st ... node3.html

however i would leave that paper alone and would go for the much more robust position based dynamics approach:

http://www.continuousphysics.com/Bullet ... 77&start=0

cheers,
Antonio
Last edited by Antonio Martini on Thu Feb 22, 2007 10:00 pm, edited 1 time in total.
Dirk Gregorius
Posts: 861
Joined: Sun Jul 03, 2005 4:06 pm
Location: Kirkland, WA

Post by Dirk Gregorius »

The force is the gradient of Energies (Eq. 2 and Eq. 3). I think they don't give this formulas, but it should be not to difficult to derive them yourself. For the distance constraint you basically need to compute dE/dp1 and dE/dp2 and plug this into the equations 2 and 3 (depending whether you want damping or not). This way you get the forces. This is basically the same as the constraint gradients in the "Position Based Dynamics" paper.
coderchris
Posts: 49
Joined: Fri Aug 18, 2006 11:50 pm

Post by coderchris »

Thanks guys
however i would leave that paper alone and would go for the much more robust position based dynamics approach:
Iv looked into that paper aswell; looks like a very robust method, but will it also handle tetrahedral meshes and give convincing deformation without much fuss?

I already have a very robust collision solver, and I am currently using it to simulate springs in a spring mass type system, but the problem is that the triangle/tetrahedron's areas are not being conserved, which causes the mesh's to cave in on themselves.
The force is the gradient of Energies (Eq. 2 and Eq. 3). I think they don't give this formulas, but it should be not to difficult to derive them yourself. For the distance constraint you basically need to compute dE/dp1 and dE/dp2 and plug this into the equations 2 and 3 (depending whether you want damping or not). This way you get the forces. This is basically the same as the constraint gradients in the "Position Based Dynamics" paper.
Im still kindof confused.. It says that to get the direction, you take the negative gradient of E. What exactly does that mean? I havent had much experience with any math grater than calculus 1 :?
Antonio Martini
Posts: 126
Joined: Wed Jul 27, 2005 10:28 am
Location: SCEE London

Post by Antonio Martini »

coderchris wrote:Thanks guys
however i would leave that paper alone and would go for the much more robust position based dynamics approach:
Iv looked into that paper aswell; looks like a very robust method, but will it also handle tetrahedral meshes and give convincing deformation without much fuss?
yes you will need to add volume conservation constraints for tetrahedra.

cheers,
Antonio
Dirk Gregorius
Posts: 861
Joined: Sun Jul 03, 2005 4:06 pm
Location: Kirkland, WA

Post by Dirk Gregorius »

You can use the following constraint functions for area and volume preserving constraints.

Triangle area preserving constraint:
C(p1, p2, p3) = |(p2-p1) x (p3-p1)| / 2 - A0

Volume preserving constraint:
C(p1, p2, p3, p4) = |(p2-p1) * (p3-p1) x (p4-p1)| / 6 - V0

Note that they are quite similiar to the formulas in your original paper. Though I would not normalize (divide by the original area/volume) since your Lagrange multipliers will have the wrong dimension then. There is an answer by E. Catto on this topic somewhere on the forum...

PM me you mail adress and I send you my (incredible short) math reference where I derived some of the gradients for these constraints so you can use them.
coderchris
Posts: 49
Joined: Fri Aug 18, 2006 11:50 pm

Post by coderchris »

Thanks for the derived gradients dirk, they seem to be working for me :)
Dirk Gregorius
Posts: 861
Joined: Sun Jul 03, 2005 4:06 pm
Location: Kirkland, WA

Post by Dirk Gregorius »

Nice to hear! So do you use the volume constraint? I never tested it, but only derived it since I was just doing this kind of math and thought that it might become useful some day and I awfully quick forget how I did this kind of derivations :-)
coderchris
Posts: 49
Joined: Fri Aug 18, 2006 11:50 pm

Post by coderchris »

Actually, i implemented a 2d version for now to test the contraints, and the distance and area preserving ones are working. Ill let you know if the volume works as soon as I get it implemented :)
stbuzer
Posts: 23
Joined: Fri Dec 08, 2006 10:16 am

Post by stbuzer »

I tryed to derive volume constraint gradients by myself and got following:

constraint C(p1,p2,p3,p4) = 1/6 * dot(p2 - p1, (p3 - p1) x (p4 - p1)) - V0

gradients:
p1: 1/6 * ((p4 - p3) x (p2 - p1) - (p3 - p1) x (p4 - p1))
p2: 1/6 * (p3 - p1) x (p4 - p1)
p3: -1/6 * (p4 - p1) x (p2 - p1)
p4 1/6 * (p3 - p1) x (p2 - p1)
but it seems that they are wrong :(
(I've already implemented it)
raigan2
Posts: 197
Joined: Sat Aug 19, 2006 11:52 pm

Post by raigan2 »

Again, I must recommend LiveMath Maker: you just write your constraint function in scalar form and it calculates the partial derivatives wrt each scalar: http://www.livemath.com/download/
coderchris
Posts: 49
Joined: Fri Aug 18, 2006 11:50 pm

Post by coderchris »

I took a look at the livemath maker; i cant seem to get it to derive anything, but I probably just havent spent enough time with it :?

Anyway I have a math related question concerning the formulas in the paper; Does anyone think they could show me the steps for deriving the distance constraint outlined in the paper?

I took a look at partial derivatives and I understand them now, but im unsure where to go with them...
Dirk Gregorius
Posts: 861
Joined: Sun Jul 03, 2005 4:06 pm
Location: Kirkland, WA

Post by Dirk Gregorius »

The constraint is C(x1, x2) = |x1 - x2| - L0

Since both x1 and x2 are functions of the time I recommend building the time derivative and then find the Jacobian by inspection. You use

dC/dt = dC/dx * dx/dt = J * v

This is the same as the chain rule (e.g. f'( h(x) ) = f' ( h(x) ) * h'(x) )

We use the this identity |x|' = x/|x| (Try to prove this yourself for practise. Hint |x| = Sqrt( x^2 + y^2 + z^2 )

dC/dt = (x1 - x2) / |x1 - x2| * ( v1 - v2 )

Now we sort this and define for readability n = (x1 - x2) / |x1 - x2|

dC/dt = n * v1 - n * v2

We can bring this in matrix form

dC/dt = ( n -n ) * Transpose( v1 v2 )

dC/dt = J * v


Does this make any sense to you?
Last edited by Dirk Gregorius on Thu Mar 01, 2007 9:38 pm, edited 1 time in total.
coderchris
Posts: 49
Joined: Fri Aug 18, 2006 11:50 pm

Post by coderchris »

It almost makes sense now;

Why do we find derive it with respect to time?
Shouldnt dC/dx be enough to solve the constraints?

I also noticed that L0 gets lost in the derivation. If L0 has no effect on the end result, how is the constraint able to get back to rest length?

Also, does dC/dt represent the force?
or do I have to multiply dC/dt by -kC

Thanks for the help
Last edited by coderchris on Thu Mar 01, 2007 10:08 pm, edited 3 times in total.
raigan2
Posts: 197
Joined: Sat Aug 19, 2006 11:52 pm

Post by raigan2 »

coderchris wrote:I took a look at the livemath maker; i cant seem to get it to derive anything, but I probably just havent spent enough time with it :?
I wouldn't have figured it out, except that there are help files/videos:

video: http://support.livemath.com/lmhelp/main ... =954790820

you can download a livemath workbook from the bottom of this page that has working partial derivative calculation:
http://support.livemath.com/lmhelp/main ... =953485362