3

I'm making a C program in which I simulate a Patriot missile system. In this simulation my Patriot missile has to catch an incoming enemy target missile. The information about the Patriot missile and the enemy target are stored in a structure like this:

typedef struct _stat {
float32_t x;
float32_t y;
float32_t v;        // speed magnitude
float32_t v_theta;  // speed angle in radians
float32_t a;        // acceleration magnitude
float32_t a_theta;  // acceleration angle in radians
} stat;

And I'm storing the informations in two globals variables like those:

stat t_stat;  // target stats
stat p_stat;  // patriot stats

Now, to simplify the problem the target is moving thanks to an initial speed and is affected only by gravity, so we can consider:

t_stat.x = TARGET_X0;
t_stat.y = TARGET_Y0;
t_stat.v = TARGET_V0;
t_stat.v_theta = TARGET_V_THETA0;
t_stat.a = G;   // gravity acceleration
t_stat.a_theta = -(PI / 2);

Again, to simplify I'm also considering to compute the collision point when the Patriot has reached its top speed, so its own acceleration is only used to balance the gravity acceleration. In particular we have:

p_stat.x = PATRIOT_X0;
p_stat.y = PATRIOT_Y0;
p_stat.v = 1701,45;     // Mach 5 speed in m/s
p_stat.v_theta = ????   // that's what I need to find
p_stat.a = G;           // gravity acceleration
p_stat.a_theta = PI / 2;

In this way we can consider the Patriot as moving at constant speed because the sum of the accelerations by which is affected is equal to 0.

float32_t patr_ax = p_stat.a * cos(p_stat.a_theta);       // = 0
float32_t patr_ay = p_stat.a * sin(p_stat.a_theta) - G;   // = 0

Now, here comes the problem. I want to write a function which computes the right p_stat.v_theta in order to hit the target (if a collision is possible).

For example the function that I need could have a prototype like this:

uint8_t computeIntercept(stat t, stat p, float32_t *theta);

And it can be used in this way:

if(computeIntercept(t_stat, p_stat, &p_stat.v_theta)) {
    printf("Target Hit with an angle of %.2f\n", p_stat.v_theta);
} else {
    printf("Target Missed!\n");
}

For making it even more clear, here is the image which I want enter image description here

Nigam Patro
  • 2,760
  • 1
  • 18
  • 33
PaulRox
  • 79
  • 1
  • 9
  • Mean, you need to check whether it hit the target, at which angle? – Nigam Patro Dec 19 '15 at 11:16
  • No, if possibile I want to find the angle at which it hit the target, if it exists. – PaulRox Dec 19 '15 at 11:42
  • It's the speed vector of the target, while `vp` is the speed vector of the Patriot. – PaulRox Dec 19 '15 at 11:47
  • Then the target is moving in which direction? – Nigam Patro Dec 19 '15 at 11:47
  • The `vt` vector shown in the picture is the initial speed vector of the target, then when the simulation starts it will change in direction and magnitude because of gravity acceleration. While the `vp` vector, once computed the `theta` angle, should remain constant in direction and magnitude. I hope I had clarified the problem. – PaulRox Dec 19 '15 at 12:01
  • Sorry bro, I am not that much of expert in Physics. – Nigam Patro Dec 19 '15 at 12:17

3 Answers3

3

Your target projectile is moving with constant acceleration hence the velocity can be described as

enter image description here

Now integrating this equation gives us the equation of the position.

enter image description here

Now by knowing the initial position and we can determine this constant vector is the initial position

enter image description here

Now the position of the target projectile is finally

enter image description here

This are two equations (for x and y coordinate). The equation for y is quadratic and the equation for x is linear since the acceleration (gravitational) is in the vertical direction.

You have

enter image description here

enter image description here

In general you should do something like this :

enter image description here

You can use https://en.wikipedia.org/wiki/Newton%27s_method in order to solve the last equation for theta that you get.

Abstraction
  • 511
  • 2
  • 9
  • Thanks for your answer. I think there's a typing error in the quadratic equation, the last term should be multiplied by t^2, no? Anyway, what do you mean with "the time the Patriot reaches its highest position"? And how can I find the time "t" if also `vx` and `vy` of the patriot are unknown?? – PaulRox Dec 19 '15 at 14:27
  • I edited my answer gave you an example how you should get the equation of the angle that you need. The " time the Patriot reaches its highest position" was misunderstanding of your question I thought that the patriot was accelerating downward due to gravity as well and you wanted the collision to occur at that point. However you said that you want to calculate the collision when the Patriot has reached his top speed which I don't quite understand what you mean by since you assumed that the total acceleration on him was 0 which means his speed will be constant. – Abstraction Dec 19 '15 at 15:24
  • In any case my answer should work as long as the accelerations of both projectiles are constant. – Abstraction Dec 19 '15 at 15:27
  • Ok, thank you, It's a bit confusing what I wrote before. Anyway you can see the Patriot motion as divided in two different stages, initially it has its own acceleration vector which is able to increase its speed, then when it reaches its top speed, the acceleration is reduced at the point that it just maintain the speed constant. My problem is computed at the end of the first stage, in this way I can consider the Patriot as moving at constant speed. – PaulRox Dec 19 '15 at 16:00
1

In order to have a collision you need the coordinates of both objects to be identical at the same instant of time.

You could decompose the problem into two simpler ones, considering each axis, x and y, separately:

You need to calculate the equations of motion for the both objects, once for their horizontal components and once for their vertical components.

enter image description here

enter image description here

Check whether the solutions of both objects contain equal coordinates and if this happens at the same instant of time.

Target coordinates: T (xt, yt)

Patriot coordinates: P (xp, yp)

You could solve this numerically by varying the time, t, and observing whether: T == P.

In your case, one of the equations should contain a parameter accounting for the angle theta.

Ziezi
  • 6,375
  • 3
  • 39
  • 49
  • Thanks for your response, I think this solution should theoretically work but I also think that it's impossible to apply. I mean, I should compute these equations a lot of times varying the parameters `t` and `p.v_theta` and of course I'm not able to explore all the possible solutions because i can only increment those parameters of a fixed amount and possibly I will never get the exact value to observe `T == P`. – PaulRox Dec 19 '15 at 14:35
  • That is correct, you will run a loop for an interval of interest and compare the result within a given error, `delta` (accuracy of the result) – Ziezi Dec 19 '15 at 14:37
  • I tried, it seems to work fine, the problem is that this project is for an university exam, so i think the professor could prefer a more precise method, while this is kinda a "brute force" method. But I don't even know if there exist a finer method to solve this! – PaulRox Dec 19 '15 at 15:53
  • @PaulRox This is how it's done in science generally. Every solution is correct with: +/- error. :) – Ziezi Dec 19 '15 at 16:02
0

Simulate the event and find the time the 2 objects are closest.


The missile can only fly so long after launch (negating it going into orbit), let that be tf.

Using struct _stat for each object, write a function that report the x,y for a given t and object.

Simulate, at reasonable intervals (1s?), 0.0 to tf, the square of the distance between the two objects.

From the time t of the closest approach, use it 2 neighbors t-dt and t+dt to do the simulation over again. Could use time from t-dt to t+dt with 10x smaller dt or other methods.

Repeat the above until the distance is close enough or dt is sufficiently small.

If this distance is sufficiently small, evaluate struct _stat for the needed data now that the time is determined.

Note: the details of the complexity of pt2 compute_position(struct _stat st, time t) only need consideration for the the initial dt estimate.

chux - Reinstate Monica
  • 143,097
  • 13
  • 135
  • 256