#### Archived

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.

## 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 on other sites
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 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.

1. 1
Rutin
32
2. 2
3. 3
4. 4
5. 5

• 11
• 9
• 13
• 92
• 11
• ### Forum Statistics

• Total Topics
632972
• Total Posts
3009626
• ### Who's Online (See full list)

There are no registered users currently online

×