Sign in to follow this  

Integrating for position, including air resistance

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 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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this