TAOC Discussion

Ive been working with Tom (Lazy Chestnut) to nut some stuff out, but the big problem i have is that the ball a) bounces and b) decelerates. I dont believe there is any 'formula' for intercepting a decelerating object!

This is an interesting point. I would have thought bouncing could be fairly easily solved, depending on the sort of tools you are using. If you make vertical and horizontal velocities independant, make horizontal constant (well, you might want to add a small deceleration to account for air resistance, and a much larger deceleration if the ball is rolling along the ground). For the vertical velocity, it gets interesting. If I can assume that the sort of motion you are attemtping to achieve is similar to the modulus of a sine curve (I dont know how much maths you know, and it may well be more than me, working on a project like this, but in case you don't, a sine curve looks like this. For the modulus, take all the bits below the x axis and reflect them so they are above, creating, if you like, the motion of a perfectly bouncy ball).

This is where it gets tricky. If you are able to program position (displacement) then a sin t curve (t = time) if fine, although you'd want some way to make it bounce lower each time. If you define x as the period of time between one bounce and the next (which would have to be calculated based on the power and trajectory of each individual shot) then you could say

If t <= x, put the time (t) into sint.
If x < t <= 2x [ie between the first bounce and the second] put t into 0.9sint
If 2x < t <= 3x, put t into 0.8sint.

And so on. x will be easy to calculate (unless I'm overlooking something) using a vertically applied UVATS equation. The 0.9s, 0.8s etc are just examples, and you would have to test for realism, but this would produce a fairly good bouncing motion.

If you can't define position, only velocity, you would need a cos t graph since velocity can be defined as the differential of displacement (dv/dt) and cos is the first differential of sine.

You problem with intercepting a decelerating object is trickier. I can't think of a way to tackle it off the top of my head, it all depends on how the programming works and I'm afraid I have no experience with it. My first thought that possibly a differential equation may be of use but it all depends how how it needs to be programmed.

Don't know of this is of any help to you, but it kept me interested and thinking so it's not a waste if you've already found a better way :p
 
Good idea above although the curve created by a projectile given an initial velocity (impact from a bat or the ground) is always a parabola not a sine wave.

If the ball has a constant deceleration, then it is definitely possible to calculate an "equation" of its motion that has the coordinates x and y (or vectors u and v) for motion in a 2D plane that is dependent only on time.

Disregarding bouncing for now, imagine a ball rolling on a surface with friction, set bythe user. Simple F=ma would give a constant negative acceleration and if you know the initial velocity of the ball off the bat (I don't know if the physics engine gives this information, but I would have thought so) you can resolve in x and y to get an equation in both these directions that are dependent on time.

Parabolic motion of a projectile and the calculation of the path of a bouncing ball are covered in any A-level mechanics maths text book. (impact of elastic bodies with a given coefficient of restitution, and motion of projectiles)

Once air resistance comes into the picture it gets more difficult as the drag force on a sphere depends a given drag coefficient, surface area, air density (all constant knowns) and then VELOCITY which is of course constantly changing via the formulas calculated above.

THis would then point to a numerical solution, not a discrete one, ie. one where the computer has to calculate the position of the ball in very small intervals and output it in real time (as it would be difficult to combine all the equations to do with drag, rolling friction, bouncing etc into a set of three equations, x, y, z in terms of t)

I don't know how the game engine works, but I feel there must be a way of it outputing the position of the ball (x,y,z) in the playing area at any given time. These could be fed into the fielding equations to get the player to run to that point...constantly updating every 0.0000001 secs (for example) and getting him to run to that point.

Probabaly sounds like BS I know, but I think this would be the best way and spare you some fairly complex equations.

Keep going LM, you've come a long way already!

YUsuf
 
Post above is bang on the money. I should have thought about restitution - only met it fairly recently and so haven't used it much.

It also occured to me that relative velocities might prove useful. It is certainly possible to determine whether or not two objects can intercept (ie whether a fielder can reach a ball as it is speeding towards the boundary) and I suspect it's probably possible to minimise the time to intercept for a decelerating object, although I'd have to think about that one.
 

Users who are viewing this thread

Top