Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


ball trajectories

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Okay, I was on my way making a 3d tennis game but the trajectories of the ball have really got me stumped..... I.e. I cannot make the balls flight path look legitimate. So can anyone help me out with some "basic" formulas. (if possible) I am not trying to make the all time great simulator. Just a loose translation. An explanation of the formulas would be greatly appreciated. Thanks in advance.

Share this post

Link to post
Share on other sites
Guest Anonymous Poster
Well... You have to make an object: ABall which has:
* Coordinate r(x,y,z)
* Velocity v(vx,vy,vz)
* Acceleration a(ax,ay,az)

Acceleration is basicly directed downwards, and it''s value depends on Your world parameters (it''d be GREAT if you make all figures real, eg. acceleration of free fall g=9.8 m/s*s)...
Now You just have to manage a timer, and when the particular period of time is out, you: r=r+v*dt, v=v+a*dt (-these are vectors, and dt - (scalar) period of time - the shorter it is - the smoother will the motion be)
That''s all! When You coolide a rocket with a ball, you have to use this collision formula: v = -v + 2*vRocket; (- this is also geometrical sum!) to determine the further ball motion...

NOTE: geometrical sum of two vectors a(a1,a2,a3) + b(b1,b2,b3) = c(a1+b1,a2+b2,a3+b3) = vector c; The product of scalar multiplied on a vector is a vector, each coordinates of which are multiplied on that scalar!

Good luck!

Share this post

Link to post
Share on other sites
If you want to minimize any accumulated error you might want to use this form for the position and velocity functions instead:

r(t) = r0 + v*t, where r0 is the position at t=0
v(t) = v0 + a*t, where v0 is the velocity at t=0

It''s the same effect as the formulas AP gave, but if you have any error in your calculations in the r = r+... formulas it will add up with time, whereas with this method the error will remain constant with time since the position is calculated from scratch for each unique time.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!