How to create an intercept course

Hi,

I would like to know how to create an intercept course on a 2 dimensional axis.

Example:
A ball moving at 80 m/s in the horizontal direction to the right, with a deceleration of 10 m/s^2. Another ball has a constant velocity of 50 m/s, and is at a 45 degree angle to the bottom right of the first ball, and at a current distance of 65 m to the first ball. How fast is the second ball able to intercept the first ball? (Or how far must the second ball travel to intercept the first ball while travelling in only a straight line?)

Notes:
The first ball can be at any speed travelling in any direction, but has a constant deceleration of 10 m/s^2.
The second ball has a constant speed of 50 m/s.

Thank you very much!!

Certainly you could do it with a system of equations that describe the X and Y coordinates as functions of time. Any solution that has identical X and Y values at a given T will describe an intercept course. If you want to intercept at a particular place, you only need to solve equations for your intercept ball that give it that X(t) and Y(t). Look up linear algebra to get an idea of the math.

Is this a homework problem?

Thanks for replying! But i am still confused… Why does X and Y have to be identical? If I’m trying to intercept the moving ball as soon as possible (hence as a function of time), X and Y could be not identical right?

@YamatoTwinkie

Sort of… Its a small part of a big project… I was trying to specify my problem…so I came up with the example as shown…I’m trying to create a ball interception algorithm for this 2d soccer game

And I was thinking it is easy to create an interception algorithm which was made up of just having a player stand in the way of the ball, but it gave me a headache trying to think up of an algorithm that could intercept a ball as efficiently as possible.

We don’t answer homework here, but since it’s only “sort of” homework, I’ll give you a “sort of” answer.

Any objects that collide with each other must necessarily be in the same place at the same time. So if you plot position with respect to time (or time with respect to position), you can find when and where the objects collide by finding (x, y, t) that works as a solution for both equations.

If, instead, you find that putting X and Y in one equation yields 10 seconds for one object and 5 seconds for another, that means that they hit the same spot 5 seconds apart. If you put in the same T and compute different Xs and Ys, then that means they’re existing in two different locations at the given time.

Finally, computing the course with require some rather simple trig once you get the numbers computed.

@Chessic Sense

Oh so that was what Napier meant by identical X and Y. No offense but I have thought about it before, so yes I have come before to the conclusion that ‘t’ has to be equal for both the interceptee and interceptor…thanks for replying though!!

So I thought of using s=ut + 0.5(a)(t^2)

ie. (using the example in my first post)

s1 = 80(t) + 0.5(-10)(t^2) ------- (1)
s2 = 50(t) --------------------------- (2)

so I sub (2) into (1) and get 2 unknowns: s1 and s2
So I try to look for a second equation from :

v = u + at
s = 0.5(v+u)(t)
v^2 = u^2 + 2as

but I find that I don’t have the final speed that the interceptee is at when intercepted, and that subbing the values for the interceptor into these equations give me useless things…

So I thought of turning it into x and y vectors using the above equations, then I realise that I do not have the final direction that the interceptor is going to use, so I can’t use any trigonometry to get an x or y vector for the interceptor’s speed…

So I am just looking for the correct equations to help me progress…from wikipedia, I have sought equations that eventually become those I have stated above, since the original equation of motions only have an added Si, which is the initial starting position and can be thus treated as 0…Anyhow, if I add in Si, I would require the x and y vectors of the interceptor, which is, as stated above, unknown…

So yes I have been thinking this over very thoroughly for more than 2 days and have been unable to arrive at an answer…

Any help would be much appreciated…Thank you very much!!

OK, we crossed in posting. Some of what I write below is already understood.

What you are asking for is very standard algebra. But you are clearly starting from a very early base in your understanding of mathematics. You should really do some reading as it isn’t something that can be instantly understood in the space of a few postings. But a few things that might help.

You have equations that describe the motion of things. You also have equations that describe desired conditions. There are rules that allow you to manipulate these equations, including combining them and breaking them up, and you can make use of these rules to create new equations that are your answer.

So, you have equations that describe the movement of the ball. In 2 dimensions you can have equations for its position written in a number of ways. A critical point is that all these equations are based upon time - as you change time the position changes.

You have equations that describe desired conditions. In this case you want to intercept the ball. This means you have an equation that says “at a given time, position of ball is the same as the position of the interceptor”.

So in very high level form:

Location_ball = location_function_ball(time)
Location_person = location_function_person(time)

So to intercept the ball with the person:

location_function_ball(time) = location_function_person(time)

That is the X = Y at time T Napier mentioned.

The basic form of any problem of this type is “solving the equation(s)”. Here we create set them all to the form: equation = 0. This is easy, since we just rearrange them to:

location_function_ball(time) - location_function_person(time) = 0

Where it gets harder is to create the equations that capture your particular problem. A common, and easiest version of the above is to ask “does the ball’s path meet the person.” This happens if you can solve the equation with a value of time that makes sense. If the location functions for the ball and the person are both fixed, you have a simple yes/no answer.

Your problem is more involved. You want to be able to vary the location function for the person in such a way that you guarantee that the interception occurs. For this you need to identify what parameters of the person’s location function you can vary. These become new unknowns in the equations. So, you have equations that have a number of variables, whereas in the simple case only time varied.

What you probably want to do is manipulate the equations so that you eliminate time. Ideally you then end up with something that is an equation involving your other free variable, and some constant expression. This is the answer. Set this free variable in the person location function to that value, and your person will intercept the ball.

This isn’t always possible. But for the simple system you describe it will be, unless you apply constraints such as maximum acceleration or maximum speed to the person intercepting the ball.

You may also discover that you have more than one solution. For instance if the ball takes a curved path you can intersect it at more than one place.

That was for one free variable in the person location function. However you have more than one. At least direction and speed, so two So you will find that you have a result where you have possibly an infinite number of solutions, you can intercept the ball at any place along it’s path by running in the appropriate direction and at the right speed. Clearly you probably want to run the shortest distance, so this becomes another constraint, and another equation.

You can imagine all of this graphically. For a 1D problem this is easy. One axis is time, the other the one dimension. Draw the path of the ball and the path of the person. Do they intersect? For a 2D game you need 3D graph paper, which is a bit hard to find. But the idea is there.

This is where you need to do some reading and spend some effort. I’ve slid over the mechanics of what is done to solve the system. Nothing is especially difficult, mostly involving the application of a set of rules as if they were a set of tools in a toolbox. If you can solve a Sokoku puzzle, you can do linear algebra. Where you could get more advanced is to explicitly look at the area of linear algebra. What you get here is a set of tools that simplify how you represent and manipulate the equations. Rather than longhand equations, you can represent a useful subset of possible systems as a matrix of numbers, and manipulation of the rows and columns of the matrix is identical to manipulating the longhand equations. This turns out to be astoundingly powerful. In computer based systems this is probably the single most common and powerful way of representing and solving problems. (I used to estimate that about half of all numeric scientific problems were linear algebra.) Any book on writing computer games will cover this material. What I’ve written above is really to encourage you to look into the question, and to have some idea of what you will meet.

I worked out the general solution in Mathematica and it is crazy fricken complicated.

You may need to settle for a less than optimal intercept course if you want something that is actually workable.

The answer to the specific example in the OP is that ball 2 should head in the direction 13.4737 degrees north of east for 3.94523 seconds to meet ball 1 traveling due east at (237.794, 0).

To expand on the above.

Ball 1 starts at the origin and travels in the positive x direction with initial velocity v and acceleration a.

Ball 2 starts at (x,y) and travels with velocity u in a yet to be determined.

The time we’re interested in is when the distance from Ball 1 to (x,y) is equal to the distance Ball 2 has traveled.

So we have:

(v t - 1/2 a t^2 - x)^2 + y^2 = (u t)^2

or

((a/2)^2) t^4 - (a v) t^3 + (a x + v^2 - u^2) t^2 - (2 v x) t + (x^2 + y^2) = 0.

This is a 4th degree polynomial in t, and we want its smallest, positive, real root. This might be a difficult to compute. Also, this will give the wrong answer if t > v/a, but that case is simpler to solve as it just involves Ball 2 heading directly for the spot where Ball 1 will come to rest.

However, if we can compute t from the above it is easy to then find the direction of travel, a, to be when

y + u t Sin(a) = 0

or

a = -ArcSin(y/ (u t)).

Hope this helps.

Hi,
Thank you everyone! Most especially Francis Vaughan and even more so Lance Turbo.

@Francis Vaughan
Although it did not really solve my question, I do appreciate all the effort u took to write that post, even though it still amazes me how fast you think and type (you replied in a span of 5 minutes after my post). I will look into matrices again, even though it is one of my most hated topics, since you say it is widely used in one of my favourite subjects–game making.

@Lance Turbo
Thank you for taking time to actually try and solve it. I actually asked another friend of mine and he gave me some new insight into the problem that led me to the first equation you posted, though I think you might have misread my OP and changed a static variable to a dynamic variable in the equation, which makes it more advanced than what I had. Yeah I reached the quartic equation, then I thought it would be a pain in the ass to code and that trying to make a processor compute something of that magnitude would slow down my other processes considerably, so I will most probably settle for a cruder method.

EDIT: the cruder method is equally a pain in the ass to code :smiley:

Thank you for your help once again! I think this thread will be a lifesaver to many noobs like me who might one day need it. I remember I couldn’t solve this like 7 years ago…which was when I first came across motion equations.

I just wanted to point out that the constant acceleration condition stated for the ball is (a) pretty unrealistic and (b) might make the math much more complicated. After eight seconds, that ball will come to a stop and then start accelerating back in the other direction.

David Beckham would be proud. :smiley: