Creating a simple Friction model

In summary, the conversation is about a hobbyist programmer trying to design a physical simulation engine for their game. They are struggling with understanding and modeling friction in code, but are looking for a simple and effective solution. They discuss using roughness values and coefficients to calculate friction, as well as the idea of a speed-based model. They also consider looking at open-source programs for guidance. The conversation ends with a question about the accuracy of friction coefficients listed on Wikipedia.
  • #1
Nanako
39
0
Hello everyone ^^ I'm amateur programmer, making games for a hobby.

I'm trying to design a physical simulation engine here, and one thing I'm struggling with is modelling friction in code. I don't recall ever learning much about it in school, or perhaps i didn't pay enough attention, but regardless, I'm struggling somewhat to understand the concept.

My loose understanding of (dry) friction, is that it's created between moving objects, and acts to deplete their kinetic energy/momentum, gradually reducing velocity while they're in contact. As this is a game, it doesn't need to be 100% accurate, just "good enough". So i can afford to make plenty of assumptions such as uniform roughness, and not caring too much about how much surface area is in contact.

What I'm interested in is creating a simple model for dry kinetic friction. I want to be able to assign some arbitrary friction value to a game object, and calculate a coefficient from the two friction values of any relevant pair of objects. Presumably at the end up, i'd have some value to either subtract from, or multiply by, the two objects' velocities. (i'm not sure which, how proportional is this?)

my first thought with this problem was simply creating a multiplier value for each object (such as 0.3) and multiplying the other object's velocity by that value each second it's in contact with that object. I have a feeling that this is a bit TOO simple though, and I'm also worried about stopping. In conventional dry friction, objects generally DO come to a stop quite quickly, don't they? I'm thinking that just using a multiplier would result in the object getting perpetually slower and slower, but never fully coming to rest.

Is proper friction code going to bring objects fully to rest? or should i be using some cutoff velocity below which an object can be considered nonmoving, and set to 0?

If it helps any, I'm 23, i have mostly just a high school education, and some general familiarty with basic physics concepts. I'm a little bit more knowledgeable than the laywoman, but not too much.

Any advice, thoughts, and pointers in the right direction, are greatly appreciated ^_^
 
Physics news on Phys.org
  • #2
You can assign each object a roughness factor which add to make a coefficient of friction.
The friction force is the perpendicular contact force scaled by the coefficient.

If you want a speed-based model, then each roughness factor creates a drag coefficient - the (quick and dirty) energy loss due to drag should be the drag coefficient times speed-cubed, so you can get a terminal velocity.

Tweak the values of the roughness factors for the sensitivity you want.

For more detail, find an open-source program that handles friction and see how they do it. There are a lot of models of varying physicality.
 
  • #3
Reassign frequencies to all your particles. Then you can determine friction by simple addition/subtraction. That's what I had to do a couple months ago. It makes particle models smoother with less load on the server that you would get from complicated algorithms.
 
  • #4
You can assign each object a roughness factor which add to make a coefficient of friction.

simple addition ? what are rough ballpark figures for friction values. say substances like dirt, concrete, etc.
reading around a bit, it seems like coefficients of higher than 1 are quite rare, and wikipedia makes no mention of coefficients higher than 2. I'm perplexed as to what this means, though.]

The friction force is the perpendicular contact force scaled by the coefficient.

i'm not quite following you here. does this contact force have something to do with the object's weight? I'm guesing, when both are on top of each other, the contact force is the weight of the upper object? maybe I'm wrong there.

by scaled do you mean multiplied by, just to be clear ?

If you want a speed-based model, then each roughness factor creates a drag coefficient - the (quick and dirty) energy loss due to drag should be the drag coefficient times speed-cubed, so you can get a terminal velocity.

i'm not certain what you mean by a speed based model. what you're describing sounds like more of a way to model air/water friction? i guess it's all the same esentially. would that model be exclusive to the other one?

For more detail, find an open-source program that handles friction and see how they do it. There are a lot of models of varying physicality.

a good idea, certainly. I'm thinking of having look at Box2D. my coding language here is AS3 by the way (flash). i opted to write my own engine, rather than using Box2D, mainly for learning purposes. ^^

Reassign frequencies to all your particles. Then you can determine friction by simple addition/subtraction. That's what I had to do a couple months ago. It makes particle models smoother with less load on the server that you would get from complicated algorithms.

not certain what this is about. I'm not using particles at all yet, and i don't generally plan to involve them much with physics when i do. it's mostly a rigid body engine, and it's a client app, so i on't have any servers to worry about
 
  • #5
i've come across something else on the matter that's confusing me also. the wikipedia page has a table about halfway down, Approximate coefficients of friction. The values listed here just don't seem to add up.

for example, the coefficient of steel on steel is shown as 0.8, so if this should be calculated with addition, does that not mean the roughness value of steel would be 0.4 (half).

just underneath that though, the coefficient of steel and PTFE is 0.04. how can that be? unless ptfe has a negative roughness, and actually causes objects to accelerate ?

i can't seem to make sense of this.
 
  • #6
Friction is a complicated phenomenon and there's no simple way to model it, even in "real life". The best you can do is measure different coefficients and compute tables of them.
 
  • #7
Simply put, force of friction is the coefficient of friction x the normal force...or the force pushing the object into the ground (or whever it's rubing against). This can indeed be the object's weight (on flat ground), but if something is on top of it, then it's the two object's weights added together, as the second object is directly contributing in pressing the surfaces together. If something else is pushing it into the ground (such as aerodynamic pressure, centrifugal force, a human hand, etc.), that force needs to be added also.

If a 1 kg block of steel is sliding on steel, for example, and only the block's weight is pushing them togheter, then the force of friction is .8 x 9.81 N = 7.8 N

If the same block of steel is sliding on PTFE, then .04 x 9.81 N = .4 N

Theoretically, surface area doesn't matter.

Coefficient of friction is always given for two objects sliding against each other. That's why you have steeel/steel or steel/PTFE. It wouldn't make sense to just give the coefficient for one object, as the object needs to rub against something for there to be friction. Don't think of it as "roughness" as there are more complicating factors than that. Just take the given coefficient and go with it.

Once you can solve for the friction force using the simple formula, you can then figure out how fast that force will slow down an object. Force is mass x acceleration.

F=ma
or
a=F/m

So the 1kg block of steel rubbing against steel will slow down at 7.8 / 1 kg = 7.8 m/s^2
On PTFE, it will slow down at .4 / 7.8 = .05 m/s^2

For a simple computer program, this textbook simplification of friction should be sufficient.
 
  • #8
pergradus said:
Friction is a complicated phenomenon and there's no simple way to model it, even in "real life". The best you can do is measure different coefficients and compute tables of them.

I disagree !

I've been looking through the source code of Box2D. The formula used there is sqrt(friction1*friction2), where 1 and 2 are arbitrary user-assigned values for friction of a single object

with a range of sensible input values, i find that this gives sensible outputs. most notably it allows either input to drive the coefficient towards 0, and it means that the coefficient of x on x is always x. I'm sure it's not perfect, but it's "good enough" and it adequately fits the task of a simple model.

I'm going to use this formula for now, so that's my first part done.

The next part as far as i can see, is in two steps:

1. Calculate the kinetic energy lost from the friction (converted to heat or whatever)
2. Calculate the change in velocity from the lost kinetic energy.So, the first of those steps; wikipedia has this formula, which i need a little help deciphering:

When an object is pushed along a surface, the energy converted to heat is given by:

d231484d66aff48971fd3908498fe96b.png


where
Fn is the normal force,
3ad4fa5a7787192d8cbb5f69d33d05cc.png
is the coefficient of kinetic friction,
x is the coordinate along which the object transverses.

ok, i have the friction coefficient.
i'm not sure about d. is that distance in metres? it's not documented. i don't know exactly what X is either, I'm guessing a normalised directional vector ?

and what is that squiggly line in the middle ?
 
Last edited by a moderator:
  • #9
You mean the "d" in the integral?
But you know that's just the notation for an infinitesimal change ... in this case: "dx" ?
 
  • #10
Nanako said:
simple addition ?
If you like - as you've seen, some computer models multiply factors together. You asked for a simple model - this is one. There are many others.
what are rough ballpark figures for friction values. say substances like dirt, concrete, etc.
You don't care - you just want your simulation to "feel" right.


reading around a bit, it seems like coefficients of higher than 1 are quite rare, and wikipedia makes no mention of coefficients higher than 2. I'm perplexed as to what this means, though.
You need to read more on the physics of friction then.

Generally it just means that you won't expect the friction force to be bigger than how hard the two surfaces are pressing against each other. Friction models don't only cover fine-grained irregularites.

does this contact force have something to do with the object's weight? I'm guesing, when both are on top of each other, the contact force is the weight of the upper object? maybe I'm wrong there.

The contact force is whatever is pressing the two objects together in your simulation.

by scaled do you mean multiplied by, just to be clear ?
Yes

Generally, energy loss due to a contact is proportional to the roughness of the surfaces and the strength of the contact.

The harder you push two surfaces together, the more friction you get.
The rougher the surfaces, the more friction you get.

i'm not certain what you mean by a speed based model. what you're describing sounds like more of a way to model air/water friction? i guess it's all the same esentially. would that model be exclusive to the other one?
These are very simple models which exclude large amounts of the generality of physics.
How you track motion will be important to which model you choose.
If you keep track of energies, then you want to describe friction effects in terms of energy losses, if you track speed, then you'll be better having a "slowing effect" - drag. If you are modelling everything with forces and pressures, then the force model is used.

I'm sorry, I thought you already had a computer program you wanted to add friction effects to. This should be making sense in terms of your program. You are simulating a bunch of stuff moving around - each object has, say, a position and momentum vector, and some sort of geometric factor to handle collisions?

If you simulate aircraft, then you want a drag coefficient for when you fly through clouds or smoke or something (for a simple model - the drag of normal air would be included in the default dynamics.) If this is penguins sliding on ice, then you want some sort of roughness factor to cover snow, dirt, and rocks while the contact force will handle the effect of different slopes. See what I mean?


not certain what this is about. I'm not using particles at all yet, and i don't generally plan to involve them much with physics when i do. it's mostly a rigid body engine, and it's a client app, so i on't have any servers to worry about
Which means you only need a simple model that can be tweaked for verisimilitude.

You can drive yourself nuts trying to simulate everything that could possibly happen.
Isolate the bit you need and simulate that.
 
  • #11
If you like - as you've seen, some computer models multiply factors together. You asked for a simple model - this is one. There are many others.You don't care - you just want your simulation to "feel" right.

i think that simple addition was a bit too simple though, and wouldn't accomplish the goal of feeling right. for example it would have needed both objects to b extrmely smoooth in order to get a low friction coefficient, which doesn't make sense (as opposed to one)



These are very simple models which exclude large amounts of the generality of physics.
How you track motion will be important to which model you choose.
If you keep track of energies, then you want to describe friction effects in terms of energy losses, if you track speed, then you'll be better having a "slowing effect" - drag. If you are modelling everything with forces and pressures, then the force model is used.

I'm sorry, I thought you already had a computer program you wanted to add friction effects to. This should be making sense in terms of your program. You are simulating a bunch of stuff moving around - each object has, say, a position and momentum vector, and some sort of geometric factor to handle collisions?

If you simulate aircraft, then you want a drag coefficient for when you fly through clouds or smoke or something (for a simple model - the drag of normal air would be included in the default dynamics.) If this is penguins sliding on ice, then you want some sort of roughness factor to cover snow, dirt, and rocks while the contact force will handle the effect of different slopes. See what I mean?

i get what you mean. i am ccurrently usiong a velocity based model then. although i question if there's any purpose in tracking energy, as i can just calculate it on the fly (0.5*mass*velocity squared)


a friend is under the belief that the speed of the moving object affects the friction force imparted on it. or to put it another way, an object's rate of deceleration should fall as it becomes slower. is there any truth to this ?
 
  • #12
thanks for the help everyone, especially Lsos and Simon Bridge. I believe i now have all the information i need, and I'm beginning work on implementing friction ^^ For now I've decided not to support sloped surfaces, to make this simpler. but i will probably add them later.

I wouldn't consider this issue closed yet, i may still run into problems, and i'll come back and ask for additional help if so.
 
  • #13
Nanako said:
i think that simple addition was a bit too simple though, and wouldn't accomplish the goal of feeling right. for example it would have needed both objects to b extrmely smoooth in order to get a low friction coefficient, which doesn't make sense (as opposed to one)
You get the idea. Your simulation can be as complicated as you are prepared to work. Have fun :)

Aside: if you have mainly smooth surfaces, you may prefer to define a "smoothness" (inverse roughness) for each instead.

i get what you mean. i am ccurrently usiong a velocity based model then. although i question if there's any purpose in tracking energy, as i can just calculate it on the fly (0.5*mass*velocity squared)
Depends on the exact form your simulation takes.
It is often computationally simpler to model energies than forces or velocities ... but it may not be. Use the one that makes the math easier - if it is easier for you, you make fewer mistakes but if it is easier for the computer, you get more efficient calculations ... the usual balancing act.

a friend is under the belief that the speed of the moving object affects the friction force imparted on it. or to put it another way, an object's rate of deceleration should fall as it becomes slower. is there any truth to this ?
Air resistance is speed dependent - usually modeled as a drag-coefficient times speed-cubed. This is what gets you your terminal velocity when falling.

Contact friction is proportional to the contact force - usually called a normal-force because it acts normal to the surface. Note: it does not depend on the contact area at all.

There are two contact frictions - static and kinetic. Friction removes more energy just to start the object moving than it does to keep the object moving.

All three come into play in a car: internal losses are mainly kinetic - moving parts - external losses are mostly drag, while static friction actually helps.

You get drag from air and the fact you have to keep deforming the tires.

Static friction (tires and road) drives the car forward.

More simply:

A block sliding at constant speed has: F=kmg (motive force equals friction - friction=k times weight. In your case k=bs: b=block roughness and s is for the surface. Alternatively: smoothness, q =1/k for F = mg/q.)

Work done by the motive force over distance dx is dW=F.dx=kmg.dx
If the block is pushed by an energy source supplying power P = dW/dt - that would be P=kmgv

If some speed u < P/kmg then the block speeds up until u = v.

Happy hacking :)
 
  • #14
hi everyone. I got distracted over the xmas holidays, but i did eventually get around to implementing friction. I've decided to implement it as a Newton force (dynamically converted into an acceleration depending on mass) and this is working great. All bugs now more or less ironed out, and I'm happy! thanks a lot everyone!
 

1. What is friction and why is it important?

Friction is the force that resists motion between two surfaces in contact. It is important because it affects the movement and stability of objects in our everyday lives, and is essential for many mechanical processes to function properly.

2. How is friction created?

Friction is created when two surfaces in contact move against each other or when one surface moves against a stationary object. The roughness and texture of the surfaces, as well as the force pushing them together, all contribute to the amount of friction generated.

3. What are the factors that affect friction?

The factors that affect friction include the types of surfaces in contact, the force pushing them together, the speed and direction of motion, and the presence of any lubricants or contaminants on the surfaces.

4. How can a simple friction model be created?

A simple friction model can be created by identifying the surfaces in contact, determining their roughness and coefficients of friction, and applying the appropriate equations and calculations to estimate the amount of friction generated.

5. What are some real-world applications of friction models?

Friction models are used in a variety of real-world applications, such as designing efficient tires for vehicles, creating safer brakes for cars, and developing better sports equipment. They are also crucial in understanding and improving the performance of machines and mechanisms in industries such as manufacturing and engineering.

Similar threads

  • Mechanics
Replies
11
Views
2K
Replies
112
Views
6K
Replies
22
Views
2K
Replies
5
Views
829
Replies
5
Views
2K
Replies
4
Views
10K
  • Mechanics
Replies
2
Views
1K
  • Introductory Physics Homework Help
Replies
3
Views
635
Replies
9
Views
1K
Back
Top