Sign in to follow this  
Aph3x

RK4 - absolute time value t

Recommended Posts

Aph3x    288
Hi all, I'm having problems understanding the fundamental restructuring of my code moving from Euler to RK4. Looking at Glenn Fielder's stuff he uses an absolute time value 't' which doesn't correspond to my simulation that works with time increments 'dt' only. Also, how do external forces get applied here? I'm thinking I accumulate the linear and torque forces as normal and apply them in the forces method too - but how/do I factor in the absolute 't' here as well?! /confused...

Share this post


Link to post
Share on other sites
Airo    197
You have an implicit absolute t in your simulator. it's good to keep track of t anyway: t += dt; each step.

call your current state time t
the next state will be t + dt

you only need the t when you have time dependent forces. i have not read that article. hope this helps a bit.

Share this post


Link to post
Share on other sites
Aph3x    288
Quote:
Original post by Airoyou only need the t when you have time dependent forces.


Ah that makes sense. I presume accumulated forces are applied in the normal way...

Share this post


Link to post
Share on other sites
Aph3x    288
...or maybe not.

Hmm: in my system a 1Kg object is falling at 9.8m/s after 1 second, which is ok.
A 2Kg object is falling at 5m/s after a second = bad.

I'm applying gravity as an external force - I have a feeling I'm applying the accumulated (external) forces incorrectly here - any pointers on how these are applied?

[Edited by - Aph3x on August 12, 2005 8:27:49 AM]

Share this post


Link to post
Share on other sites
taby    1265
This article was what I used as a reference for RK4... with a little help from Airo, et al. :)

The acceleration function in the accompanying source is where forces are applied. ie: return -9.81f; // gravity

Share this post


Link to post
Share on other sites
Aph3x    288
ah, did you mean this one?

That's what I've been using so far; the problem I have is how to apply external forces in the acceleration function (which in the tutorial only applies 'internal'/generated forces there).
By 'external' forces I mean those accumulated over the frame.

Share this post


Link to post
Share on other sites
Dmytry    1151
Quote:
Original post by Aph3x
...or maybe not.

Hmm: in my system a 1Kg object is falling at 9.8m/s after 1 second, which is ok.
A 2Kg object is falling at 5m/s after a second = bad.

I'm applying gravity as an external force - I have a feeling I'm applying the accumulated (external) forces incorrectly here - any pointers on how these are applied?

gravity force=g*mass
Most likely you just forgot multiply, and have 2kg mass thing that have weight force as on 1kg.

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