Advertisement

Physics

Started by February 14, 2002 01:59 AM
11 comments, last by sandyshorts 23 years ago
I thought about this again...
and maybe you should get rid of the time-variable...
I don''t know how complex your program is, but with your current equations, you''ll have to remember a start-time or maintain a time-count for _each_ fired projectile.

maybe a better approach would be to save the current velocity of the projectile (using a vector) and update position (which is influenced by the velocity) and velocity (which is influenced by the current accelleration (ie: gravity).

updating position would, of course, be:
vec_pos += vec_v

updating the acceleration would be:
change of velocity = g * elapsed time

so, if g is represented as a vector (0, 0, -9.81)
vec_v += vec_g * (globaltime - lastupdate)


another advantage of this would be, that you could add dynamic influence, like changing wind... and you could easily add stuff like bouncing (simply said: if the projectile hits an horizontal floor, change the sign of the z-part of the current velocity)

nik
LeMatsch gave such a simpler and more effective example than me there!! well done!...=0)

that''s just the sort of thing I was getting at.

..I''m gunna have to start loggin in aren''t I!!!
Advertisement
oke you got me convinced that for more complex physics problems it''s better to work with vector''s nicely organised

This topic is closed to new replies.

Advertisement