calculating velocity

How would I calculate the initial velocity needed for a ball to hit a target.

Given that the initial position of the ball and target, radius of the ball, gravity and flight time are all constant how would I find the initial velocity needed to to be given the ball to hit the centre of the target every time.

any help appreciated

Velocity = distance / time

That’s just physics.

Your answer is on this page (http://en.wikipedia.org/wiki/Trajectory_of_a_projectile) and depends on a range of factors you haven’t mentioned or perhaps don’t want to consider. For example

If you assume gravity acts on the projectile, and that the gun & target are at the same elevation, you will need to apply an upwards angle to counteract the force of gravity as it travels towards the target. You can choose an angle and each one will have a different velocity.

Take particularly close attention to the sections on Angle of reach and Velocity at x

AngleOfReach = 0.5 * arcsin(gravity * distance / velocity * velocity); // you choose your velocity

or

Speed = sqrt((velocity * velocity) - (2 * Gravity * distance) + (Gravity * distance / 2 Cosine(AngleOfReach))); // you choose the angle to fire at