Physics Simulation Forum

 

All times are UTC




Post new topic Reply to topic  [ 21 posts ]  Go to page Previous  1, 2
Author Message
PostPosted: Sun Mar 09, 2008 7:24 pm 
Offline

Joined: Tue Mar 04, 2008 3:57 pm
Posts: 21
hi, you're right, jellophysics seems to use springs which do not have endless stiffness. (easy to implement, because it only affects the length constraints of the polygon)
The problem is that I don't know what to do next, how to add friction, elasticity and collision response.


Top
 Profile  
 
PostPosted: Sun Mar 09, 2008 10:15 pm 
Offline

Joined: Fri Dec 21, 2007 9:10 am
Posts: 6
Seth wrote:
hi, you're right, jellophysics seems to use springs which do not have endless stiffness. (easy to implement, because it only affects the length constraints of the polygon)
The problem is that I don't know what to do next, how to add friction, elasticity and collision response.


As I said, collision response is made by simply moving the mass points so there is no overlap. You don't need to care about velocity, because it is changed implicitly.

If you want to add some bouncing then move last_pos of the mass point along -normal*CoR where "last_pos" is a last position of the mass point (you need to store this if you work with velocity less Verlet), "normal" is a collision normal (along which you moved the mass point in order to solve the overlap) and "CoR" is a coefficient of restitution between 0 and 1.

If you collide with static objects then you can simulate the friction by simply decreasing "velocity", so make last_pos+=(pos-last_pos)*CoF where "CoF" is a coefficient of friction. It seems strange but works nicely for me :) Perhaps it would be more accurate as if I did it the same way as with dynamic objects.

Friction of collision with a dynamic body is a little more tricky. You need to calculate relative velocity of colliding points. Let's assume your mass point I collided with and edge (defined by mass points J and K) of the other object (1 point vs 1 point is just a simpler scenario). Then the relative velocity is relVel = I.pos - I.last_pos - (J.pos + K.pos - J.last_pos - K.last_pos)/2. Then you compute tangent from the collision normal and project the relative velocity onto it:
relTanVel = tagent*dot(relVel, tangent)
Then you add/subtract (depending on how you computed tangent) some fraction of relTanVel to/from last_pos of I,J,K. What fraction it will be is determined by I,J,K masses and "hit coefficient" (because I is somewhere between J and K...you get the hit coefficient by projecting I onto the edge JK).

Again, this is probably not very accurate, but works fine for me and it looks good in the cases I needed. If you need something more accurate then mass-spring system for simulating bodies is maybe not a good idea, but as I remember you wanted something simple.


Top
 Profile  
 
PostPosted: Mon Mar 10, 2008 11:53 am 
Offline

Joined: Tue Mar 04, 2008 3:57 pm
Posts: 21
hi,
thank you very much, this seems to be very helpful for me ;)
(does normal in your case mean that it has a length of 1 ?)
I also don't have to deal with masses ?

This is my try to deal with masses:
Code:
  suminvmasses := A.invmass + B.invmass;
  mf := A.invmass * suminvmasses;
  for i := 0 to high(Bc) do
    B.vertices[Bc[i]].position := v2f_add(B.vertices[Bc[i]].position, v2f_scale(mtd, -1-mf));
  for i := 0 to high(Ac) do
    A.vertices[Ac[i]].position := v2f_add(A.vertices[Ac[i]].position, v2f_scale(mtd, mf));

instead of using 1/2 for scaling the collision normal, I use a relationship of the two inverse masses.
I think I also will need masses for friction, because heavy objects don't slide that much as they do now.

Could you post some of your friction code ? especially the part for moving objects ^^ because it's not very clear to me yet.
You said:
Quote:
What fraction it will be is determined by I,J,K masses and "hit coefficient" (because I is somewhere between J and K...you get the hit coefficient by projecting I onto the edge JK).

How exactly does this work ? is this necessary if all masspoints of one polygon have the same mass ? As I said I think that heavy objects should slide less.

Current Version (with restitution and masses):
http://www.exec-dev.de/verlet.zip
The restitution seems to add energy to the system which is not good ^^


Top
 Profile  
 
PostPosted: Mon Mar 10, 2008 10:43 pm 
Offline

Joined: Tue Mar 04, 2008 3:57 pm
Posts: 21
Now I finally managed to handle friction, this is what it looks like now:

http://www.exec-dev.de/verlet.zip

I think that heavy objects have to have much more friction, because they slide to easily. I used the normalvector scaled by the penetration depth for restitution, because otherwise the objects won't stop bouncing, is this correct ? (for friction I used the normal with length 1)

Here I have a Demo with a bridge (inlcuding the two constraint types rope and spring): http://www.exec-dev.de/Bridge.zip
I think it would be good, to add something like air friction because constructions like this bridge (or pendulums) don't stop moving. (I think just reduce the velocity like for normal friction)
But one really big problem is, that even if the "ball" is very heavy, the bridge doesn't "bend" more, the springs have to get much longer, but they dont. How can I solve this problem ?

I am now trying to fix this by calculating FG:
FG = m * g
because now I only take care of FN, like you can see here: http://de.wikipedia.org/wiki/Bild:Schiefe-Ebene.png
maybe this will solve my problem :P

EDIT: even if some approaches looked good, something weird always happens after some time.

Any ideas ?

thank you


Top
 Profile  
 
PostPosted: Fri Mar 28, 2008 3:05 pm 
Offline

Joined: Tue Aug 21, 2007 12:13 am
Posts: 24
Hey Seth
I've actually tried implementing a similar system not too long ago, and was somewhat stuck when it came to friction...
You can see my latest build at: http://www.physicsdev.com/files/fisix/demo1/demo1.html
I'm using the tetrahedron approach from jakobsen's paper, which actually works very well when it comes to constraints and contacts... that demo is very limited, but any polygon, and any type of constraint can be simulated there.

Now Raigan ('raigan2' on these forums) Implemented a similar system, and used 'motorized constraints' for friction, which he says works quite well...

Right now I'm looking at impulse based methods though... maybe there's a way to mix both


Top
 Profile  
 
PostPosted: Sun Mar 30, 2008 11:59 am 
Offline

Joined: Tue Mar 04, 2008 3:57 pm
Posts: 21
hm, I managed to implement friction very easily, using the above mentioned method.
But I have another problem which doesn't seem to exist in your engine, maybe you can help ?

The problem is described here: viewtopic.php?f=4&t=1974

thank you


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 21 posts ]  Go to page Previous  1, 2

All times are UTC


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group