Correct equation for contact friction and elasticity?

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Correct equation for contact friction and elasticity?

Postby JoshKlint » Wed Jun 24, 2020 8:46 am

I am looking for the "right" way to set contact friction, elasticity, and softness.

Let's say object A has values for static friction, kinetic friction, softness, and elasticity.

Object B also has its own set of these values.

When object A and B collide, how should these values be combined? Are they added together? Multiplied? Averaged?

What is the most scientifically accurate way I can calculate the values to give to NewtonMaterialSetContactFrictionCoef, NewtonMaterialSetContactElasticity, and NewtonMaterialSetContactSoftness?
JoshKlint
 
Posts: 163
Joined: Sun Dec 10, 2017 8:03 pm

Re: Correct equation for contact friction and elasticity?

Postby Julio Jerez » Fri Jun 26, 2020 12:43 pm

of these three NewtonMaterialSetContactFrictionCoef, NewtonMaterialSetContactElasticity,
NewtonMaterialSetContactSoftness?

NewtonMaterialSetContactSoftness is a hack that physics engine use to force object to recover from penetration. I would not change the default value unless you are making something very special. I was trying play with it for the animation but later I learned that count on hack to get something going almost certainly fail.

regard the other two, as far as I know there not scientifically correct way to calculate those values from formulas, they are measured experimentally from trials with different material pairs.
there are many chart over the internet that you can look at. In general the pair at that Mamie's you can ha for examp 6 to 10 materials which for a table of 50 pairs (for 10 materials) that you can fetch using a hash algorithm in a call back.

some engines provide heuristic formulas to do some calculation automatically, newton does not do that.
Instead with Newton, you can use the contact callback and using collision ID, you can find the value from some hash table. or you can use heuristic like the higher, the smaller, the average or whatever you like from a pair of value stored in the two collision shaped associated wit the contact.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Correct equation for contact friction and elasticity?

Postby JoshKlint » Sat Jun 27, 2020 3:15 pm

So something like this? (See "Friction Coefficients for some Common Materials and Materials Combinations"):
https://www.engineeringtoolbox.com/fric ... d_778.html
JoshKlint
 
Posts: 163
Joined: Sun Dec 10, 2017 8:03 pm

Re: Correct equation for contact friction and elasticity?

Postby Julio Jerez » Sun Jun 28, 2020 12:33 pm

yes, that's a good explanation of how it work is good enough and fix with what is tought at any good high school physics curriculum.

in newton there are two function you can use to store application data, with a collision shape that you can them later get from each contact in the call back

Code: Select all
   typedef union
   {
      void* m_ptr;
      dLong m_int;
      dFloat m_float;
   } NewtonMaterialData;

   typedef struct NewtonCollisionMaterial
   {
      dLong m_userId;
      NewtonMaterialData m_userData;
      NewtonMaterialData m_userParam[6];
   } NewtonCollisionMaterial;
void NewtonCollisionGetMaterial (const NewtonCollision* const collision, NewtonCollisionMaterial* const userData);
void NewtonCollisionSetMaterial (const NewtonCollision* const collision, const NewtonCollisionMaterial* const userData);

where NewtonCollisionMaterial has two data values with this own interface functions, some of these are used by some of the classes in the dJoint library , but there are 6 extra user data that you can use to store data for your logic.

In theh early days of newton, this was at the NewtonBody level, but I realized that is was too high granulation and inflexible, so I added this new layer for more flexibility without adding the handling of internal graph manipulation. It is better to let the end application do that with hash or maps.

This was one for the aspect of Newton that was criticized a great deal from the Internet physics experts like ODE, GameDevNet and places like that bringing the slippery slope argumentation that having two ids lead to a full graphs, when the reality is that this is the correct way of doing it, and in practice the number of material is quite small, so the graph is not large.
plus even when there are a large number of materials, an application can always limit the number and use defaults for not existing entries.

what bothered me at the time was that the people making these claims where the leaders and moderators and they must knows they were lying to their users to protect the way people like Novodex and ODE where doing this. It was all dishonesty.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Correct equation for contact friction and elasticity?

Postby JernejL » Mon Jun 29, 2020 7:25 am

I believe i already used this combined with trimesh & faceid and compound collisions, to use multiple materials on single body - and it worked well - no problems there.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1578
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Correct equation for contact friction and elasticity?

Postby JoshKlint » Wed Jul 01, 2020 11:49 am

Okay, I think the sensible thing for me to do is allow the user to specify collision materials, allow them to specify material coefficients, but have a system that automatically calculates a value if they don't explicitly specify one.
JoshKlint
 
Posts: 163
Joined: Sun Dec 10, 2017 8:03 pm

Re: Correct equation for contact friction and elasticity?

Postby JernejL » Fri Jul 03, 2020 3:10 am

Ok, i used the info in this thread and some of my knowledge of this to write an article for wiki regarding this:

http://www.newtondynamics.com/wiki/inde ... al_Section

Please give me any kind of corrections if i made some mistakes there.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1578
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Correct equation for contact friction and elasticity?

Postby Leadwerks » Mon Dec 14, 2020 10:15 am

What I found is that for games you really want to use the minimum of the two values, for all these values. If you have an object with zero elasticity, you want it to really have zero elasticity, no matter what. Same goes for friction. So that means multiplying the two values, or taking the minima. And two materials with 0.5 elasticity resulting in a collision with 0.25 elasticity makes no sense to me, so I took the minima.
User avatar
Leadwerks
 
Posts: 569
Joined: Fri Oct 27, 2006 2:54 pm

Re: Correct equation for contact friction and elasticity?

Postby Leadwerks » Mon Dec 14, 2020 10:23 am

Here are the default values for the material contact, FYI:
staticfriction = 0.9
kineticfriction = 0.5
elasticity = 0.4
softness = 0.1
skinthickness = 0.0
User avatar
Leadwerks
 
Posts: 569
Joined: Fri Oct 27, 2006 2:54 pm

Re: Correct equation for contact friction and elasticity?

Postby Julio Jerez » Mon Dec 14, 2020 12:35 pm

we have been through this many time already.

As far as I know there is not correct mathematical equation for calculating coefficients of friction and restitution for two materials. Those coefficients are measured experimentally in labs, you can find tables in various place in teh internet.
Game physics engine implement policies where they apply different heuristic, like the minimum, the average, the product and some other weird that I do not know the rationale for them.

I do not do that, I leave it to the user to implement their own methods. because in my experience most games use methods were those values are read from the material on the background mesh and the other object is usually and small modifier of those dominant value.

People get scare when you tell then that the materials are a table of two pair.
but I also found that for most application the number of material is not usually that bad.
for example a table of 16 materials is a lot of materials, but that produces a look up table of
16 x 16 = 256 entries.
it is not difficult to find the coefficient for 16 materials combination, and anything outsize that you can special case with some heuristic.

The clamping between 0 and 2 is because in the literature the friction is a value from 0 to 1 but there are some materials like plastics and rubber that do have larger than one values. plus since this is video game physics, in some cases some user want to give some objects unrealistic values. so I let it go as high as 2. anything larger that that generate too strange behavior like objects been able to stop on inclines say 70 degrees or higher.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Correct equation for contact friction and elasticity?

Postby Leadwerks » Mon Dec 14, 2020 9:24 pm

Do you know where I can find a complete table? Every table I find online only has a few sample values and is missing a lot of combinations.
User avatar
Leadwerks
 
Posts: 569
Joined: Fri Oct 27, 2006 2:54 pm

Re: Correct equation for contact friction and elasticity?

Postby Julio Jerez » Mon Dec 14, 2020 10:19 pm

I have never seen a long table, but a google search show this
https://www.bing.com/images/search?q=fr ... BasicHover

you can get some material from there, and just make the one you are interested in up.
you will never going to get people to agree that those value are the only one.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Correct equation for contact friction and elasticity?

Postby Leadwerks » Tue Dec 15, 2020 12:36 am

Okay, so we need one of these:
https://www.banggood.com/New-Push-Pull- ... ID=6291565

And a block of aluminum, ice, steel, asphalt, concrete, grass, dirt, plastic, and granite. :lol:
User avatar
Leadwerks
 
Posts: 569
Joined: Fri Oct 27, 2006 2:54 pm

Re: Correct equation for contact friction and elasticity?

Postby Leadwerks » Tue Dec 15, 2020 2:08 am

This was one for the aspect of Newton that was criticized a great deal from the Internet physics experts like ODE, GameDevNet and places like that bringing the slippery slope argumentation that having two ids lead to a full graphs

That does not make any sense. Were they running on a 486? :lol:
User avatar
Leadwerks
 
Posts: 569
Joined: Fri Oct 27, 2006 2:54 pm

Re: Correct equation for contact friction and elasticity?

Postby JoeJ » Mon Aug 08, 2022 5:18 am

I was thinking about this yesterday, at least regarding friction.
I think it should work well if we represent our material surface as a summation of waves, like Fourier Series.

Imagine two gear wheels.
The friction between them is high only if the tooths have the same frequency. Otherwise they do not match and will slide instead syncing rotation.

Following this model, we could store amplitudes of e.g. 4 frequencies representing the scales of 1mm, 2mm, 4mm, 8mm for each material.
This describes the surface structure, or roughness like a gfx dev would say.

To get friction coefficient of two materials, we loop over the 4 frequencies, accumulating high values if both amplitudes at a frequencies are high.
No real idea about math yet, but something like this:

Code: Select all
float cof = 0;
cof += min(a.amp[0], b.amp[0]) * 1; // 1mm
cof += min(a.amp[1], b.amp[1]) * 2;
cof += min(a.amp[2], b.amp[2]) * 4;
cof += min(a.amp[3], b.amp[3]) * 8; // 8mm
return cof;


No LUTs needed, and we can come up with new materials without caring about other materials we have.

I'll try this. But i wonder if there isn't any research about such ideas.
User avatar
JoeJ
 
Posts: 1453
Joined: Tue Dec 21, 2010 6:18 pm


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 44 guests