• Advertisement
Sign in to follow this  

Integrating for position, including air resistance

This topic is 4159 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

Hi, I want to add air resistance to my game, to effect a terminal velocity on my players (who are represented by otherwise frictionless spheres). I use a form of dead reckoning to cut down on bandwidth used for updating clients: on the server, I predict where the clients think an object will be and compare the prediction with the actual location. If the two are too disparate, I send an update to the client. This was easy to implement without air resistance. Now, though, I want to add air resistance, as a force proportional to velocity squared (e.g. Fr = -k*v^2). To make my prediction, I want to integrate the force to find velocity and then position. I have succesfully integrated the force to find the velocity. You can see my work at http://starshadow.com/~riley/airresistance.mht. I find that if t = time, T = terminal velocity, k = air resistance coefficient, and I = initial velocity, then velocity v(t) = T * tanh((T * k * t / m) + (I / 2)). I'm fairly confident in that solution. This is where I'm stuck, though. I want to integrate again to find displacement, but I have not had any luck trying to integrate tanh(mt + b) with respect to t. At this point, I'm guessing that whatever the solution is, calculating this every frame is going to be more trouble than it's worth, and I'll either keep a running euler integration going or just use resistance LINEARLY proportional to v. In fact, euler integration will be closer to what the client is doing anyway, so that would probably be more accurate. Lol, I just smacked myself in the forehead for the last hour of working on this. But anyway, my mathematical curiosity still has me interested in the answer to this question. Any ideas?

Share this post


Link to post
Share on other sites
Advertisement
ok i just threw it at maple (a computer algebra system) and it spat this out so im going to say that to do it by hand youd have to be pretty much insane...


/ / /2 T k t + I m\ \ / /2 T k t + I m\ \ m |ln|tanh|-------------| - 1| + ln|tanh|-------------| + 1||
\ \ \ 2 m / / \ \ 2 m / //
- -------------------------------------------------------------
2 k


Or if thats to hard to read


-m * (ln(tanh((2*T*k*t + I * m) / (2 * m)) - 1)
+ ln(tanh((2 * T * k * t + I * m) / (2 * m)) + 1)) / (2 * k)


Edit: tried to fix the formating but couldnt sorry

Share this post


Link to post
Share on other sites
tanh x = sinh x / cosh x

(cosh x)' = sinh x

We have a u'/u form, which integrates to ln(u) + C

∫ tanh x dx = ln (cosh x) + C

Share this post


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

  • Advertisement