ball trajectories
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.
September 10, 2002 10:45 AM
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!
* 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!
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement