Tennis Ball Movement Algorithm: Get Help Here

AI Thread Summary
A user is seeking assistance in developing an algorithm for simulating tennis ball movement in a 3D game, focusing on calculating parabolic trajectories. Key parameters include the ball's starting and ending points, with gravity and air resistance being the primary forces at play. The discussion includes detailed formulas for calculating acceleration and velocity, accounting for air resistance and gravity. However, there is debate over the relevance of air resistance, with some arguing it is negligible. The conversation highlights the complexity of incorporating spin into the simulation, which remains unresolved.
Gigs_
Messages
3
Reaction score
0
Hi all!

Im working on a small 3d tennis game, but I am not good with math.
Can anyone make me algorithm for tennis ball movement (simulation).

I have this parameters: ball starting point (x=left/right,y=up/down, z=is forward/backward), ball ending/bounce point which y is always 0. y at (z=0) should be 40, spin parameter which is basically here just to make ball goes over net in different situations. So basically i need to calculate parabola.thanks!
 
Last edited:
Physics news on Phys.org
someone, please


just few guidelines if not all
 
Treat every axis as being completely independent of the others and that will make you life so much easier. It means that you only need worry about air resistance, and in the case of the vertical axis, gravity.

To get a realistic movement due to air resistance, you'll need to use the drag equation:
F_{d} = -0.5 \rho v^{2}AC_{d}
And also this formula:
F = ma
And this one:
v = u + at

Now, this part isn't mathematically correct, but if you consider only small steps forward in time, (1/1000 of a second for example) you can consider the drag force as constant over that time period, which allows you to do something like this:
ma = -0.5 \rho v^{2}AC_{d}
a = (-0.5 \rho v^{2}AC_{d})/m
a = -(\rho v^{2}AC_{d})/2m

This equation is getting to be a bit much, so to make it simpler, we can ditch lots of terms that don't change and replace them with a single constant. Specifically the frontal area of the ball (does actually change, but not very much), the coefficient of drag, the density of the air, and the mass of the ball. I'll use m = 0.06 Kg, diameter = 0.0635 m, air density = 1.2 Kg/m^3, coefficient of drag = 0.3 and t = 0.001 s. This leaves us with:
A = 0.03175^{2} * \pi = 0.003167

a = (1.2 * v^{2} * 0.003167 * 0.3 * 0.001)/(2*0.06)
a = - 0.0000095v^{2}

This will give the acceleration of the tennis ball in the opposite direction to it's direction of travel (if you consider the tennis balls direction to be positive). Or in other words, it's deceleration.

For this next bit, we need to come up with two equations, one for if the ball is traveling in the positive direction (ie: v>=0) one for traveling in the negative (v<0). First up is the positive:
v = u - 0.0000095u^{2}

And now the negative:
v = u + 0.0000095u^{2}

Notice I changed the v to u, because u is initial velocity and v is final velocity.

So there you have a simple way to calculate the new velocity after 1/1000 of a second. You simply plug in the old velocity as u and out pops the new velocity v. Oh, and the velocity is in meters per second.

Well those formulas can be used as-is for the horizontal plane, but what about vertically? There's also gravity to worry about. Well as luck would have it, this is way simpler to work out than the air resistance formula, because the acceleration due to gravity is always 9.8 m/s^2 down.

Just like before we need two different formulas due to the air resistance factor, firstly if the ball is going up (v>=0). In this one gravity and drag are working against the direction of travel:
a = -g - F_{d}/m
v = u - gt - F_{d}t/m
v = u - 9.8*0.001 - 0.0000095u^{2}
v = u - 0.0098 - 0.0000095u^{2}

And now if the ball is going down (v<0):
a = -g + F_{d}/m
v = u - gt + F_{d}t/m
v = u - 9.8*0.001 + 0.0000095u^{2}
v = u - 0.0098 + 0.0000095u^{2}

None of these equations take account of spin, which would alter the acceleration in mid air slightly, and especially so when the ball bounces. I'm afraid I wouldn't know where to begin to take account of spin.
 
thx for replay. air resistance is irrelevant.
 
If air resistance is irrelevant what's the problem? The only issue would be gravity.

Also, why is air resistance irrelevant?
 
Thread 'Collision of a bullet on a rod-string system: query'
In this question, I have a question. I am NOT trying to solve it, but it is just a conceptual question. Consider the point on the rod, which connects the string and the rod. My question: just before and after the collision, is ANGULAR momentum CONSERVED about this point? Lets call the point which connects the string and rod as P. Why am I asking this? : it is clear from the scenario that the point of concern, which connects the string and the rod, moves in a circular path due to the string...
Thread 'A cylinder connected to a hanged mass'
Let's declare that for the cylinder, mass = M = 10 kg Radius = R = 4 m For the wall and the floor, Friction coeff = ##\mu## = 0.5 For the hanging mass, mass = m = 11 kg First, we divide the force according to their respective plane (x and y thing, correct me if I'm wrong) and according to which, cylinder or the hanging mass, they're working on. Force on the hanging mass $$mg - T = ma$$ Force(Cylinder) on y $$N_f + f_w - Mg = 0$$ Force(Cylinder) on x $$T + f_f - N_w = Ma$$ There's also...
Back
Top