Gravity

Started by
16 comments, last by ARID 23 years, 2 months ago
smart_idiot is approximating. This is never accurate.

An example:
- Imagine an object falling from a building.
- The acceleration (==gravity) is constant.
- Speed is slowly increasing (not constant).
- The speed starts with 0, and hits the ground with lets say 100.

If you would use smart_idiot''s method, you''re assuming the starting speed is the same as the end speed - but it is not the case.

Physik is right with his formula''s!
"perfect" calculation - no approximation.

What the last AP exactly means - I don''t know?
Gravity is a constant acceleration!
Maybe the last AP is pointing out smart_idiot''s approximation?

Advertisement
I can understand the confusion though.
If you do a search on the internet, you will find out most tutorials & stuff use the wrong method, and only approximate!!!
Watch your back! Don''t trust anyone!

quote:Original post by baskuenen
smart_idiot is approximating. This is never accurate.

If you would use smart_idiot's method, you're assuming the starting speed is the same as the end speed - but it is not the case.


i'm not sure what you're talking about, i thought smart_idiot's idea is correct. i could be wrong tho.
      program_speed = (1/frames_rendered)*time_since_start_in_seconds;speed.y -= gravity*program_speed;object.y += speed.y;      
would have to be in a loop of course. so each time it loops through, you get a new velocity and a new position based on that new velocity.
say initial object.y = 100 and speed.y = 0, assumming it's 1fps, next frame would be: speed.y = -9.8, object.y =90.2
next would be -19.6,70.6
etc.

physik's method is s = 1/2 * a * t^2. yes that's the physics eqn to find of the position relative the to original point. works too, but smart_idiot's method would be better if the object already has a velocity




life is unfair, take advantage of it.
UNMB2 - if the link doesn't work, try clicking it

Edited by - thuned on February 7, 2001 1:35:42 AM

Edited by - thuned on February 7, 2001 1:40:30 AM
life is unfair, take advantage of it.UNMB2 - if the link doesn't work, try clicking it :)
thuned - sorry you''re also wrong.

Please read this tutorial and prove me wrong...


If you say, so, I guess I''m wrong.
Chess is played by three people. Two people play the game; the third provides moral support for the pawns. The object of the game is to kill your opponent by flinging captured pieces at his head. Since the only piece that can be killed is a pawn, the two armies agree to meet in a pawn-infested area (or even a pawn shop) and kill as many pawns as possible in the crossfire. If the game goes on for an hour, one player may legally attempt to gouge out the other player's eyes with his King.
smart_idiot: you're (nearly) right, but the time increment you use (program_speed) is maybe not the best....

try something like:
  loop{   fps = time1-TimerGetTime(); // from Nehe Tut #?   time1=TimerGetTime();   program_speed = time_scaler * 35.0/fps; // always runs as if 35fps   speed.y += program_speed * gravity; //  v=v + t*acc   object.y += program_speed * speed.y; // s=s + t*v}  

just make sure that gravity acts down (is negative)

alistair


Edited by - alistair b on February 8, 2001 8:47:32 PM
smart_idiot''s formula is right (but still approximation) when objects don''t get too far. since ARID is probably needing gravity between object (falling object?) and earth, where direction gravitation force is constant, there is no need to calculate exact forces between two objects.
btw. every time when position must be updated, the addition to position shouldn''t depend on frame rate, but elapsed time.

but if you need correct gravity, perhaps between planet''s or atoms(particles?) where the direction on gravitation force is not constant there is more complex formula to calculate this than
physik''s - who probalby knows it - and I can post it here if needed.
i think that the s += v*program_speed is right, i think you only need the total elapsed time if you''re calculating from the initial position s(time=0), i''m working out s(time)=s(time-1)+v*program_speed and i''m pretty sure thats ok ?

alistair

This topic is closed to new replies.

Advertisement