# RK4 - absolute time value t

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

## Recommended Posts

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 on other sites
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 on other sites
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 on other sites
...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 on other sites
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 on other sites
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 on other sites
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 on other sites
rofl - sometimes you concentrate so hard on new details you forget the basic stuff.
:o
thanks Dmytry

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 15
• 9
• 11
• 9
• 9
• ### Forum Statistics

• Total Topics
634135
• Total Posts
3015752
×