integrating forces and momentum

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

Recommended Posts

Here's my code so far:
P = P + force;
v = P * (1 / mass);
x = x + v;
force.erase();
Basically if you apply a force somewhere it instantly adds it to the momentum, calculates velocity and then the new position. Then it clears the current forces. So basically all forces are a one time thing.. not force over time. My first question is whether forces do dissipate instantly. Second question is how to calculate this over a set time interval dt. So if my dt = 1 / 16 second, how might I calculate the state change for that time jump? Edit: Forgot about the angular component.. Here's my code for that:
L = L + torque;
I = R * IBody * R.transpose();
IInv = I.inverse();
w = IInv * L;
Matrix deltaR = w.star() * R;
R = R + deltaR;
torque.erase();
Here's how torque is computed:
torque = torque + (f.target - x).cross(f.load);
How would I step that by a time step dt? Btw, I'm basing all the calculations off the papers by David Baraff. http://www.cs.cmu.edu/~baraff/pbm/pbm.html Thanks. [Edited by - tendifo on July 26, 2006 11:16:03 PM]

Share on other sites
Force is not an instant thing. If you applied a force to an object for an infinitesimal time period it would not move, no matter how strong a force you used. If you want to "apply" some instant alteration to your environment then use velocity or momentum as your base parameter. As it happens it appears that is precisely what you are doing, although you're using the wrong name.

Share on other sites
Replace 'force' with 'impulse', and 'torque' with 'angular impulse', and you have a reasonable (Euler integrated, which is bad if you want to do complex physics simulations but fine for most things) discrete-step physics system.

Share on other sites
Perhaps I should have impulse, force, angular impulse, and angular force be different variables. That way I can have impulse (i.e, during collisions) and forces (i.e, pushing a block across a table).

So impulse is instantly added and cleared every step. Forces are calculated like so:

P = P + impulse;impulse.erase();P = P + force * dt;v = P * (1 / mass);x = x + v * dt;

Is that more or less accurate?

How would I transfer that technique to the angular component? This is what I was thinking:

L = L + torqueimpulse;torqueimpulse.erase();L = L + torque * dt;I = R * IBody * R.transpose();IInv = I.inverse();w = IInv * L;WmMatrix deltaR = w.star() * R;R = R + deltaR * dt;

I tried that out using just the impulse factor and stepped one object by seconds and the other by 0.1 seconds 10 times and their orientations didn't line up.

Share on other sites
Yeah, that is a basic Euler system that should work. The thing about different time steps producing different results is one of the major drawbacks of an Euler integrator. The simplest thing to do if it matters is to have a fixed physics framerate, although as people will tell you that can be inefficient.

Share on other sites
I would expect the results to be different for each of the cases. The one being stepped with smaller time steps would be more accurate. But in my test case, the values should be exactly the same since the initial impulse get's it started, but then nothing else happens except constant motion. I would be content, however, if the number were off by hundedths or thousandths, but they're off by 200% and sometime negatives.

I'm using the code I posted in my last reply. Does that look correct? Maybe my matrix math in the underlying code is flawd?

• 10
• 17
• 9
• 14
• 41