Jump to content
  • Advertisement
Sign in to follow this  
johnnyk

friction too strong (2d)

This topic is 4770 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've implemented friction force in my 2d simulator (as friction that occurs only during a collision), but it's too strong, it will knock the object back in the opposite direction.. I need to cap it so that at MOST it will stop the velocity AT THAT COLLISION POINT. I'm having trouble figuring how to calculate the impulse I need to stop the object, though. I can't calculate it for the whole object, because I'm just dealing with the collision point. So how do I figure out what impulse I would apply to completely stop the velocity at that point? Once I have that, I can make sure my friction never exceeds it.

Share this post


Link to post
Share on other sites
Advertisement
Probably you are not simulating the friction properly! [smile]

It's so simple...

F = - K * v where v is your velocity and K is a coefficient

So when v tends to zero F tends to zero too.

You have to add this force to the sum you apply to the object (note that in physical simulations friction is used to stabilize the algorithms )

Another problem can be that you are using a time step too big for your integrator (I dont know your problem so I cannot suggest you a method)

Share this post


Link to post
Share on other sites
Quote:
Original post by blizzard999
Probably you are not simulating the friction properly! [smile]


he probably is.

it sounds more like a problem with your method of integration.

consider two boxes hitting eachother at some rather large speed. you calculate the friction force this yields at that moment, and then probably proceed to apply it all thoughout a timestep. however, in reality the friction force will quickly drop off during the timestep as the speed falls thoughout it aswell. therefore your friction will get highly exaggerated.

one way to solve this is implicit integration, which can take this sort of thing into account. your probably best off reducing your friction force or finding some sort of hack.

Share this post


Link to post
Share on other sites
Quote:
Original post by Eelco
one way to solve this is implicit integration, which can take this sort of thing into account. your probably best off reducing your friction force or finding some sort of hack.


If the problem is not stiff (ie "strong springs") I dont see the need of an implicit method (although it can be always usefull...but it's difficult!!!).
Note that the friction is also introduced to prevent integration instabilities.

Try to reduce the time step.
You have to use some thresholds to limit the movement on each pass; if the movement is greater than this threshold repeat the pass with half of the time step.

Share this post


Link to post
Share on other sites
Quote:
Original post by blizzard999
Quote:
Original post by Eelco
one way to solve this is implicit integration, which can take this sort of thing into account. your probably best off reducing your friction force or finding some sort of hack.


If the problem is not stiff (ie "strong springs") I dont see the need of an implicit method (although it can be always usefull...but it's difficult!!!).
Note that the friction is also introduced to prevent integration instabilities.


yes, i do note that. however, you should note that too much damping is equally capable of producing instabilities as too stiff springs. implicit integration solves this problem the same way as it solves instabilities introduced by springs.

Share this post


Link to post
Share on other sites
Quote:
Original post by blizzard999
If the problem is not stiff (ie "strong springs") I dont see the need of an implicit method (although it can be always usefull...but it's difficult!!!).
Note that the friction is also introduced to prevent integration instabilities.


stiff springs do not necessarily produce stiff equations, please do not confuse the two. The classic example of stiffness involves competing time-scales where a high frequency component drives down the stepsize even though it's contribution to the result is tiny.

As an example (shamelessly stolen from Numerical Recipes...)

u' = 998u + 1998v
v' = -999u - 1999v

with ICs u(0)=1 and v(0)=0. The analytic solution is

u(t) = 2e-x + e-1000x
v(t) = -e-x + e-1000x

The numerical problems arise from the second term in each equation, even thought the final contribution is obviously trivial.

However, the definition of "stiffness" is problematic and the most pragmatic definition (although not very helpful) is system that is difficult to solve using explicit schemes but easy to solve using implicit schemes (see "Solving Ordinary Differential Equations II : Stiff and Differential-Algebraic Problems" by Ernst Hairer & Gerhard Wanner).

Instability, however, is not synonymous with stiffness and one way to deal with it is, as Eelco mentioned, to use an implicit scheme. Alternatively, it is also possible (sometimes) to avoid instability through an appropriate non-dimensionalisation of the problem.


-Josh

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
You can try to derive the equations that represent the velocity of the point at the next timestep after the unknown force F is applied to it. Then solve for F.

Share this post


Link to post
Share on other sites
Quote:
Original post by jjd
Quote:
Original post by blizzard999
If the problem is not stiff (ie "strong springs") I dont see the need of an implicit method (although it can be always usefull...but it's difficult!!!).
Note that the friction is also introduced to prevent integration instabilities.


stiff springs do not necessarily produce stiff equations, please do not confuse the two. The classic example of stiffness involves competing time-scales where a high frequency component drives down the stepsize even though it's contribution to the result is tiny.

As an example (shamelessly stolen from Numerical Recipes...)

u' = 998u + 1998v
v' = -999u - 1999v

with ICs u(0)=1 and v(0)=0. The analytic solution is

u(t) = 2e-x + e-1000x
v(t) = -e-x + e-1000x

The numerical problems arise from the second term in each equation, even thought the final contribution is obviously trivial.

However, the definition of "stiffness" is problematic and the most pragmatic definition (although not very helpful) is system that is difficult to solve using explicit schemes but easy to solve using implicit schemes (see "Solving Ordinary Differential Equations II : Stiff and Differential-Algebraic Problems" by Ernst Hairer & Gerhard Wanner).

Instability, however, is not synonymous with stiffness and one way to deal with it is, as Eelco mentioned, to use an implicit scheme. Alternatively, it is also possible (sometimes) to avoid instability through an appropriate non-dimensionalisation of the problem.
-Josh


If you read papers concerning cloth simulation you will note that stiff springs produce stiff problems (and it's also intuitive) and that friction is usually used to reduce numerical instabilities (you can use a greater time-step with a reasonable damp coefficient).
I tell you this fact because I know something about cloth simulation and the methods used to solve these problems. And cloth simulation (physical accurate not "fake") is one of the most stiff problem!

I never wrote you can have stiffness only with spring models and I agree that stiffness is related with high frequency components (again...intuitively think about a guitar string :) !!!)
However I'm not interested in math theory but in its application so I think it's not very helpfull copy and past our math books [lol] and probably johnnyk wants a simple solution to a simple problem...or not?

Take it easy !!! [smile]

Share this post


Link to post
Share on other sites
Quote:
Original post by blizzard999
If you read papers concerning cloth simulation you will note that stiff springs produce stiff problems (and it's also intuitive) and that friction is usually used to reduce numerical instabilities (you can use a greater time-step with a reasonable damp coefficient).
I tell you this fact because I know something about cloth simulation and the methods used to solve these problems. And cloth simulation (physical accurate not "fake") is one of the most stiff problem!

I never wrote you can have stiffness only with spring models and I agree that stiffness is related with high frequency components (again...intuitively think about a guitar string :) !!!)
However I'm not interested in math theory but in its application so I think it's not very helpfull copy and past our math books [lol] and probably johnnyk wants a simple solution to a simple problem...or not?

Take it easy !!! [smile]


Well, you did say

Quote:
If the problem is not stiff (ie "strong springs")...


and above

Quote:
...that stiff springs produce stiff problems...


This is untrue and misleading. Stiff strings may lead to stiff problems, but only due to interactions with other terms in the equations. Furthermore, stiffness is not always related to high frequency terms, so your guitar analogy is also misleading.

I'm sorry that you are not interested in the theory that justifies the techniques you use. However, I am not just posting to you: this is a forum and anyone can read it. I want to make sure that anyone else reading it was not misled by your comments.

I'm also sorry that you do not think that my example was helpful. However, perhaps others will; Including johnnyk who can, I'm sure, speak for himself.

Finally, it is not "stiff springs" that lead to stiff equations in cloth simulation, it is the difference in the modes of deformation, i.e. bending and stretch, that produces stiff equations. I tell you this fact because I know something about numerical analysis, which probably comes from doing a Ph.D. on the topic with an emphasis on stiff equations.


-Josh

Share this post


Link to post
Share on other sites
Yes I wrote ie because I dont speak english very well and used it in the worst manner (I used imroperly id est and think I'm italian but we dont use it! [smile]) (I was meaning "for example").

I told you I'm not a math teacher...but I know cloth simuation and you can read a lot of papers in which: stiffness is caused by the strong springs used to simulate the stretching in finite elements model.
Why? Because a cloth is very resistant to elongations but not resistant to bending or shear. We cannot elongate a cloth too much but we can bend it without any problem.
Now...we can have stiffness problem also without any other force than stretch.

You say that a stiff system is ~ system that is difficult to solve using explicit schemes but easy to solve using implicit schemes. I can accept this definition although I dont understand the term easy (probably it refers to a larger time step...)

I say that if you use a real stretch model with very strong springs (try to elongate your shirt!) I have a system difficult to integrate; this is caused explicitly by the strong spring and implicitly by the iterations with other particles.

Where do you think the term "stiff" come from ??? :)

Intuitively I like also to think that stiffness is related to high frequency components and in fact we need a shorter time step to follow the system (something like an higher "sampling frequency" to simplify).
The same problems are well known in high frequency circuit simulations: in this case we have not (physical) springs.

I dont say that this is rigorous from a mathematical point of view but in practice we can accept these facts (I can accept however you prefer more precision).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!