#### Archived

This topic is now archived and is closed to further replies.

# Drag in a predictive physics model. I am crying!

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

## Recommended Posts

Hi, I know it''s a bit naughty to ask for help on my first post, but I''m in a spot of trouble and I don''t know where else to go! I''m currently working on a little game that requires simple particle fissics (i.e. it''s pseudo fakey arcadey physics). For some stupid reason, I decided to try to get the physics working in a sort of "predictive" manner. For example, the player would press "thrust", then the time at which "thrust" was pressed would be logged, then a delta time would be available every rendered frame to predict the position of the little air craft thingy from the position it was at when "thrust" was pressed. Basically, everything''s forward predicted from the last change in control states. So far, it works pretty well. You can chuck different forces (gravity, thrust, lift, drag) onto a stack of physics agents quite arbitrarily, and they''ll add the displacement (and change in velocity) due to themselves to an accumulator. This accumulator then adds its value to the base values (those recorded at the time when controls were changed). You have the initial velocity ("u") and position of the craft. Then you have several forces on this craft. So there''s heavy use of "v=u + at" and "s=ut + 1/2at^2". You grab the "u" and "ut" components easily from the initial values of the craft. Then you get the "at" and "1/2 at^2" components from each of the forces, add them all together, and get your final position for that rendered frame. I''m sure you''ve probably heard of this kind of approach before. It makes recording demos nice and easy, since only control changes need to be recorded, and the results of those changes are deterministic. My problem is this: so far, I''ve been dealing with constant forces. Gravity, and acceleration due to thrust are fixed. Drag and incedentally, lift, are proportional to velocity, and velocity, ofcourse, is NOT constant. (it''s roughly something like drag = 1/2v^2 for a given moment in time). Thus, I can''t take these factors as constants during the calculation of displacement and velocity change due to drag (or lift). I can''t for the life of me figure out how to integrate the drag equation so that it takes into account the delta time component. i.e. what''s the displacement due to the CHANGE in drag force (in turn, a result of the change in velocity, which you can take as a linear increase for the sake of simplicity). I''m thinking, for displacement, I have to add "s=ut + 1/2at^2" with another part, "1/3dt^3". ("a", in this case, represents the initial acceleration due to drag, and "d" represents the rate of change of "a"). Is this correct, or am I crap? I''m not even sure how to figure out the change in velocity due to changing drag! I don''t suppose anyone could give me a clue? I''ve been wracking my brains, and feel a bit stupid not being able to figure it out.

##### Share on other sites
you''re running into a differential equation.

##### Share on other sites
I am about to runinto this problem myself. All the equations of motion I have done so far have dealt with constant acceleration.
There is a bit of calculus here that may be simple, but just I have never seen it.

Hopefully someone here will know something about "projectile motion with non constant acceleration". Google has failed me so far (I need to look harder), when I get around to it I will get an advanced physics book to see how these problems are solved. Mabe someone will give us a head start in the mean time.

pongv0.1.8.6

[edited by - try_catch_this on March 19, 2004 2:25:09 PM]

##### Share on other sites
well... that depends on wheather the drag is velocity depndant, but the equation for the for of drag over time is:

http://scienceworld.wolfram.com/physics/DragForce.html

that should get you on your way.

you can divid by mass and integrate twice and that would give you postion.

[edited by - duekiller on March 19, 2004 4:47:09 PM]

##### Share on other sites
I tried to resolve it...

finally I came up with

v = F0/k - m(v0 + F0/k)exp(-k/m*t)

(for more than one dimension, you should apply the formula for each component) where k is the friction coefficient (drag = -kv) F0 is the constant force applied to th body and v0 is the initial velocity

for position i got

pos = 1/k * (F0*t + m * (v0 + F0/k)*exp(-k/m*t))

I don''t guarantee it''s correct but it doesn''t seem unlogical: when time -> infinity, v -> F0/k, the speed where no forces act on the body.

##### Share on other sites
typo error, velocity formula should be:

v = F0/k -(v0 + F0/k) * exp(-k/m * t)

##### Share on other sites
Thanks very much for the help! I''ll try putting it to use, Monday.

##### Share on other sites
let us know about the results

##### Share on other sites
Not yet implemented the kind anon's solution, but I found this, which try_catch_this might also find interesting. It solves displacement due to drag, but not velocity delta due to drag. The great part is, it explains it as if to a child! Woo!

http://math.kennesaw.edu/~sellerme/sfehtml/classes/math2202/fallingbodies.pdf

[edited by - Bezzy on March 22, 2004 4:53:07 AM]

##### Share on other sites
Important note from that pdf - there's several different drag models, which I didn't realize.

For smallish, spherical objects, you can take drag as roughly proportional to velocity. More complex shapes are, naturally, more complicated to model, but the drag becomes proportional to the SQUARE of velocity.

The pdf only solves displacement and velocity change due to drag for linear ("Viscous") drag rather than squared ("Newtonian") drag. That's fine for me, personally - my craft are modelled as marbles (thank god for the arbitrary nature of modelling arcade physics ).

It looks like the anonymous poster's equation is right, also. There's a few little tweaks you can make to it to make it look just like the PDF's version, so you get a slap on the back for that, kind mister! Well done!

edit: I've also found a nice slide with typical drag coefficient values for regular shapes that you might use for modelling airflow in your game: http://wright.nasa.gov/airplane/shaped.html
Thanks for all the help. I've learnt a lot.

[edited by - Bezzy on March 22, 2004 7:08:58 AM]

1. 1
2. 2
Rutin
24
3. 3
4. 4
JoeJ
18
5. 5

• 14
• 23
• 11
• 11
• 9
• ### Forum Statistics

• Total Topics
631768
• Total Posts
3002242
×