I Interception problem with curve (computer simulation)

  • I
  • Thread starter Thread starter babbink
  • Start date Start date
AI Thread Summary
The discussion revolves around solving an interception problem where a player must catch a moving target from a fixed point, using a constant heading angle without course corrections. The player needs to calculate their required velocity and steering angle over a specified timeframe, considering the target's known speed and position. Key calculations involve determining the distance to the target, the time to intercept, and the necessary adjustments in angle. The challenge includes accounting for the player's trajectory, which may not follow a straight line due to the need for a curved path to intercept the target effectively. Suggestions for optimization and collision detection methods are also provided to enhance the simulation's accuracy.
babbink
Messages
3
Reaction score
0
TL;DR Summary
I’m working on a simulation and trying to solve an interception problem where an object moves with a constant speed and the speed and angle of the interceptor should be calculated
Hi all,

I am working on a simulation where I am trying to solve an interception problem, but with a twist:
I want to calculate how to intercept a moving target from a fixed starting point, using a constant heading angle (i.e., no course correction during travel). I also need to calculate the time it takes and distance traveled to intercept the object to determine the velocity.

In the image I gave the player an angle of 45 degrees. The change in angle needed for the player to hit the end of slit 2 is 8.13 degrees in my calculations where the object moves at a speed of 1 meter per second horizontally on the x axis.

output.webp
 
Last edited by a moderator:
Physics news on Phys.org
babbink said:
I am working on a simulation where I am trying to solve an interception problem, but with a twist:
What is the twist? That you don't know the position or velocity of the target, just some timed azimuth changes? What exactly is known? What parameters can be freely chosen?
 
babbink said:
Interception problem with curve
What is the "curve" you refer to in the title?
It appears all the lines are straight, which makes it "deflection shooting".
https://en.wikipedia.org/wiki/Deflection_(ballistics)

babbink said:
I also need to calculate the time it takes and distance traveled to intercept the object to determine the velocity.
Is it the velocity of the player you must determine?

babbink said:
I am working on a simulation where I am trying to solve an interception problem, but with a twist:
What is the "twist"?
Is it that the interception must occur through an open slit?

Given the object velocity, u ; and offset, y ;
If you decide the point of interception, ( x, y ) ;
Then time of interception, t = x / u ;
Player range, r = √( x2 + y2 ) ;
Player velocity required, v = r / t .
The plot of x, or t, against v, will be a curve.
 
[Mentor Note: Two thread starts merged. OP started a second thread to try to clarify their questions]

I am working on a simulation where a player has to catch/intercept a moving object.

I can explain my problem better with an example.
Both the player and the object have a starting point, let's say the object has a starting point of x=0, y=10 and the player has a starting point of x=0, y=0. The object has a horizontal velocity of 1 m/s. I have to determine the players' velocity (m/s) and rate of change (steering angle per second) for every second in a timeframe. Let's say the timeframe is 5 seconds, so the object moves from (0; 10) to (5; 10), in order for the player to intercept the object in time, the velocity has to be sqrt(delta x)^2 - (delta y)^2) where delta x = 0 - 5 and delta y = 0 - 10, so the linear distance from the player to the object = 11.18... meters. The velocity the player needs to intercept the object is distance / time = 2.24... . If the players' starting angle is 0 degrees he has to steer atan2(delta_y, delta_x) = 1.107... radians, converting radians to degrees = 1.107... * 180 / π = 63.4... degrees. The player rate of change is set to the needed degrees / time = 63.4... / 5 = 12,7... degrees per second. If the players' starting angle was for example 45 degrees, the players' rate of change should be (63.4... - 45) / 5 = 3,7... degrees per second.

Are my calculations correct?

The problem right now is that the distance calculated (and thus the players' velocity) is not representing the curve the player has to make in order to catch the object (unless the players' starting angle was already correct).

The other factor I have is that both the player and the object are squares and have a hitbox/margin of error. The player can hit the object at the front but also at the back. I wanted to solve this by doing the following:

time_start = 0
time_end = 5
time_step = 0.1
time = np.arange(time_start, time_end + time_step, time_step)
(Time has steps incrementing by 0.1 starting from 0 to 5)

object_width = 1 meter
object_velocity = 1 m/s

time_margin_of_error = object_width / object_velocity
time_upper = time - time_margin_of_error
time_lower = time + time_margin_of_error

This makes sure the time isn't negative and also not more than the end time.
time_upper = np.clip(time_upper, time_start, None)
time_lower = np.clip(time_lower, None, time_end)
 
Last edited by a moderator:
Is this a different problem to the one in your previous thread?

If you are computing a fixed rate of change of azimuth, that has a circular arc to an intersection, then the path is not a pursuit curve, nor is it deflection shooting, it is the equation of a circle, tangent to the initial player velocity, then passing through the final interception position.
 
Baluncore said:
Is this a different problem to the one in your previous thread?
Yeah sorry I’m new to this platform and tried to update the previous post and later tried to delete it. But this is the same problem as the previous thread but hopefully better explained.

How do I solve this problem for the unknowns velocity and azimuth? I do know the object start position and speed and I also know the player start position and initial angle.
 
babbink said:
I have to determine the players' velocity (m/s) and rate of change (steering angle per second) for every second in a timeframe.
If velocity and angular velocity can vary during the run, you will have a large space of possible solutions. You will need to define an optimization goal, like minimize the time to intercept. You will possibly not find an analytical solution, and need to solve it numerically via iteration.

You could try a search for the optimum between two extremes:
- Turn in place as fast as possible, and then start to run in a straight line at max. speed
- Start running immediately at max. speed while turning as fast as possible
 
As an example: the solution for a circular arc.
If both the player and the object depart the y-axis at the same time, both initially travelling parallel to the x-axis, then the circular path followed by the player to interception with the object can be found as follows.
1. Decide on the time to interception, and so the interception point, (x2,y2).
2. Find the mid-point of the line that passes through the initial player position, (x1,y1), and the interception point. That is the average of the two x-coordinates and the two y-coordinates. [(x1+x2)/2, (y1+y2)/2] .
3. Also, notice that the slope of that line is, m1 = dy/dx.
4. Now find the equation for the perpendicular line that passes through the mid-point. It will have a negative reciprocal slope, m2=-1/m1=-dx/dy. You need to find the y-intercept, c.
5. The intercept of that normal with the y-axis, is the centre of the circular path that will be travelled by the player. The radius is the distance between the initial player and c.
6. Find the segment angle of the circle, work out the circumference travelled.
7. You know the time and the circumferential distance that must be travelled, so you can calculate the player velocity required along the arc.

In general, Google the geometric problem you have.
You might start circle geometry here.
https://en.wikipedia.org/wiki/Tangent_lines_to_circles
 
  • #10
babbink said:
The other factor I have is that both the player and the object are squares and have a hitbox/margin of error. The player can hit the object at the front but also at the back. I wanted to solve this by doing the following:
There is a quicker, and less messy way, of detecting a hit or collision.
Define the tolerance distance that counts as a hit, call it say, tad = 0.6
Evaluate the distance between the object, (xo,yo); and the player, (xp,yp);
dx = xo - xp ;
dy = yo - yp ;
If Sqrt( dx2 + dy2 ) < tad ; then collision_hit .

Note; You can avoid the slow square root every time if you square the constant tad when you first define it. The sum of the squares will always be positive.
 
Back
Top