'Realistic' Physics Modelling/ Fudging it.

Started by
3 comments, last by JohnBolton 17 years, 11 months ago
I'm working on a more stable, advanced 2D Physics engine for my next project, and have hit a problem; hopefully there's a standard answer to this, but I was just wondering how people tend to get around it. If objects fall at the same rate, irrespective of their mass; should I 'fudge' the formula to take mass into account for each object, or should I somehow simulate air resistance. This second option is so insanely difficult it's not even possible, surely?! Any advice is much appreciated! Dan
Dan Marshallwww.gibbage.co.ukhttp://gibbage.blogspot.com
Advertisement
If you're doing a physics engine then presumably you calculate the force on a body and then integrate to find new velocity and new position. In which case for a falling body (well any body actually unless you're doing something zero-g) you simply apply a force mg where m is the mass, if you want air resistance then a simple way to do that is to apply a force -kv where k is an arbitrary constant (larger means more resistance) and v is the velocity. You don't have to use -kv for air resistance, the basic idea is that air resistance depends upon velocity so you need a function of velocity to determine the force it causes on a body.
If my basic high school physics memory isn't failing me, the formula for distance over time is:

d = 1/2 a t2

For falling objects, a (acceleration) is substituted by the g constant (9.81). Instead of faking it using the mass, you could simulate air resistance by subtracting the air resistance from this g constant. If I recall corretly this would even be physically correct, since the resistance can be compared to breaking, which also is just a negative acceleration.

To stick with physics, you could derive the 'breaking' due to resistance from the area of the bottom of your falling object. The amount of air that needs to be displaced depends on the bottom area of your object, so it might be best to approximate the resistance from this. I think this is about as far as you should go in you simulation, giving you the following formula:

d = 1/2 (g - a) t2

Where g = 9.81 and a = (some small value) * (area bottom surface).


Edited: On second though, Monder's approach seems to make more sense, so I'd go with that [wink]
Rim van Wersch [ MDXInfo ] [ XNAInfo ] [ YouTube ] - Do yourself a favor and bookmark this excellent free online D3D/shader book!
I think a slightly more correct resistance formula is kv², where k is some function of the cross-sectional area in the direction of travel. But if you're going to have air resistance then you probably need some way of rotating objects into their 'correct' orientations as they fall, too: low-density objects (which are the only ones for which air resistance matters at all) will typically fall with their lowest cross-section in the direction of travel. They can also fall in very hard to model ways (drop a sheet of paper ... now try to write a program to do that!) =|, so if realism is your aim it might be more difficult than you think.

Edit: beaten twice :P
The "simplified" equation for a falling body with air resistance is dv/dt = g - k*v2. You can plug this into your integrator, or you can solve the differential equation for v, and use that value in the integrator. If I didn't mess up the math too much,

v = sqrt(g*k)/k * tanh( sqrt(g*k)*t ).
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!

This topic is closed to new replies.

Advertisement