Ok. Again ignoring air resistance for now, you've got a moving ball with a velocity. That velocity, V, has three components for the three axes - X, Y and Z. You know where the ball is, it has its own current 3D coordinates, we'll notify them in lower case.
I'll assume that x and y are the 2D coordinates of the pitch, and z is height.
First, you want to find out how long it takes for the ball to hit the ground, so you need to get the vertical component of the velocity. If you only have one velocity value, you'll need to work out the angle between the ground and the path of the ball at this exact moment and then use Z = sin(angle) * V.
With Z, and also z (the height of the ball above the ground) we can work out the time taken using the above function. The equation we're interested in is:
z = (Z * time) + (0.5 * -9.81 * (time ^2))
-9.81 being the acceleration due gravity. The convention here is usually that a positive velocity indicates the ball is going up, so this would be negative.
We rearrange this equation to form the quadratic equation that equals zero in order to plug values into the function. This gives:
-4.905 * (time ^ 2) + Z * time - z = 0
The form of a quadratic equation is ax^2 + bx + c = 0, where x is the unknown value you want to find out (time in this case), and a, b and c are constants. Taken from our reworked equation, a = -4.905, b = Z and c = -z, and we know what Z and z are.
When you plug those three values into the function you'll get an array of floats in return, with two elements. Both of these are correct values - if you substituted them for the time value in the earlier equation, the result would be zero, as expected. One of these is the answer that you want. If one is negative which it almost certainly will be, then obviously you've got a negative time result, telling you when the ball last hit the ground. A positive value will be the time it will next hit. If you get zero, the ball's already on the ground. I'm pretty sure you'll never get two negatives or two positives, a ball falling with constant acceleration can never reach a coordinate twice unless it started underground. If you want though, you can always check both and take the lowest non-negative.
Now we have time, t. We can use this to find out the coordinates the ball will hit the ground, which is what we wanted in the first place. Because we've not got air resistance yes, the ball is moving with constant velocity throughout. We need to calculate X and Y, the components of the velocity along the x and y axes.
Just as we calculated Z earlier using the angle of the ball from the ground, we now use a similar equation to calculate the horizontal component, using the same angle.
horizontal component = cos(angle) * velocity
This in itself can't be used, but that can be broken up into the X and Y components using the angle the ball's travelling on that 2D plane.
X = cos(angle) * horizontal component
Y = sin(angle) * vertical component
With these velocities, it's a simple matter of multiplying them by the time value we have, and then adding them to the current coordinates of the ball. That's where it will bounce.
Getting the angles in 3D space can be iffy, I've not much experience of it. What I'm doing at the moment is storing the angles whenever I apply any force to the ball, that way I don't need to try and calculate them. I know what direction a player is trying to kick it and at what angle he's trying to lift it off the ground. Every time you apply the force, be it a bounce, a shot, a rebound or whatnot, you can then calculate where it will bounce, store that, and just refer to that every time you need it until the ball is affected again.
Bringing air resistance into play is a tricky one and depends on how you want to model it. If it's just a constant force, then the ball will be affected by acceleration on every axis. Genuine resistance would, by definition, exert a stronger force the faster the ball travels. And then you might also have the spin of the ball to worry about...
Of course, if any of the above is wrong, sorry about that and hopefully some kind soul will correct me. And some of it you probably know already but I figured it's best not to leave anything out.
I'll assume that x and y are the 2D coordinates of the pitch, and z is height.
First, you want to find out how long it takes for the ball to hit the ground, so you need to get the vertical component of the velocity. If you only have one velocity value, you'll need to work out the angle between the ground and the path of the ball at this exact moment and then use Z = sin(angle) * V.
With Z, and also z (the height of the ball above the ground) we can work out the time taken using the above function. The equation we're interested in is:
z = (Z * time) + (0.5 * -9.81 * (time ^2))
-9.81 being the acceleration due gravity. The convention here is usually that a positive velocity indicates the ball is going up, so this would be negative.
We rearrange this equation to form the quadratic equation that equals zero in order to plug values into the function. This gives:
-4.905 * (time ^ 2) + Z * time - z = 0
The form of a quadratic equation is ax^2 + bx + c = 0, where x is the unknown value you want to find out (time in this case), and a, b and c are constants. Taken from our reworked equation, a = -4.905, b = Z and c = -z, and we know what Z and z are.
When you plug those three values into the function you'll get an array of floats in return, with two elements. Both of these are correct values - if you substituted them for the time value in the earlier equation, the result would be zero, as expected. One of these is the answer that you want. If one is negative which it almost certainly will be, then obviously you've got a negative time result, telling you when the ball last hit the ground. A positive value will be the time it will next hit. If you get zero, the ball's already on the ground. I'm pretty sure you'll never get two negatives or two positives, a ball falling with constant acceleration can never reach a coordinate twice unless it started underground. If you want though, you can always check both and take the lowest non-negative.
Now we have time, t. We can use this to find out the coordinates the ball will hit the ground, which is what we wanted in the first place. Because we've not got air resistance yes, the ball is moving with constant velocity throughout. We need to calculate X and Y, the components of the velocity along the x and y axes.
Just as we calculated Z earlier using the angle of the ball from the ground, we now use a similar equation to calculate the horizontal component, using the same angle.
horizontal component = cos(angle) * velocity
This in itself can't be used, but that can be broken up into the X and Y components using the angle the ball's travelling on that 2D plane.
X = cos(angle) * horizontal component
Y = sin(angle) * vertical component
With these velocities, it's a simple matter of multiplying them by the time value we have, and then adding them to the current coordinates of the ball. That's where it will bounce.
Getting the angles in 3D space can be iffy, I've not much experience of it. What I'm doing at the moment is storing the angles whenever I apply any force to the ball, that way I don't need to try and calculate them. I know what direction a player is trying to kick it and at what angle he's trying to lift it off the ground. Every time you apply the force, be it a bounce, a shot, a rebound or whatnot, you can then calculate where it will bounce, store that, and just refer to that every time you need it until the ball is affected again.
Bringing air resistance into play is a tricky one and depends on how you want to model it. If it's just a constant force, then the ball will be affected by acceleration on every axis. Genuine resistance would, by definition, exert a stronger force the faster the ball travels. And then you might also have the spin of the ball to worry about...
Of course, if any of the above is wrong, sorry about that and hopefully some kind soul will correct me. And some of it you probably know already but I figured it's best not to leave anything out.