How can I simulate a 3D space pursuit between two spaceships with laser weapons?

  • Thread starter jst
  • Start date
  • Tags
    3d Space
In summary: If you have any questions or just want to chat more about it feel free to reply. In summary, this problem involves transforming two spaceships' positions and orientations, and then determining if one ship is within range of the other for a laser attack.
  • #1
jst
28
0
"3D Space Pursuit Problem"

Homework Statement



This is actually a programming assignment, more than a physics problem. However the issue I'm having is more with the math/physics than with the programming. Anyway here it goes:

Write a simulation program and test it for a three dimensional space pursuit of two spaceships each equipped with a laser beam weapon that can destroy its target if it is within a cylindrical angles of ALPHA degrees and a distance of BETA. Do not assume a pure pursuit, but make any necessary assumptions for smart spaceship commanders. Some sort of graphic output is required in addition to a summary report discussing your results.


Homework Equations




Included with the problem was these "hints":

http://glomawr.com/hint.jpg


The Attempt at a Solution



After looking at the book that my professor referenced in his "hint", 2D is no problem, but I'm a little confused on 3D. I found the book on Google Book Search and copied the 3 pages if anyone wants to take a look: http://glomawr.com/problem.jpg

So looking online, I found:

http://glomawr.com/eq1.jpg

Do I just combine the above info with the "hint" where I replace the SIN THETA with the value of SIN from the "hint"?

Also, I assume that the distance equation would be similar, but with an additional z coordinates.

Just more of an opinion thing...by: "Do not assume a pure pursuit, but make any necessary assumptions for smart spaceship commanders" I think he means not do it exactly like the book and give the second plane some weak AI where it moves a bit. What would you assume? (professor isn't really responding to emails :confused::smile:)


Thanks a lot. Any opinions, ideas, and info are appreciated.

-Jason
 
Last edited by a moderator:
Physics news on Phys.org
  • #2


Hi jst, Well this actually could become a rather very complex mathematical problem, depending on how far you want to take, so here's my take on it.

First ill assume that you have you have the positions of the cat and mouse ships (ill call ship1 and ship2 respectively) in some global Cartesian coordinate system (i.e x,y,z coordinates). You will also require the direction vector that ship1 is pointing in and also how much roll it has, that is the angle about the direction vector that ship1 is rotated. I would actually say the best way to implement "roll" is to have a direction vector located at the same position as that of the position of ship1 at right angles (orthogonal) to the direction vector, such that it points down one of the wings of ship1(ill call this the wind vector). Now the reason why you'll need roll will become apparent in a second.

What you will now need to do is transform the ships coordinates so that ship2 has position relative to ship1, and that ship1's direction vector is pointing down the positive x-axis, and that the wing vector is pointing down the y-axis (depending on which side you put the wind vector will depend which direction along the y-axis it points) such that the ship1 is horizontally aligned. After you have done this transformation you will have something similar to the diagram below, I will assume that you can work out how to do that transformation yourself, there is a lot online describing transformations, but obviously if you can't figure out what to do there give it you best shot then come back and well go from where you get stuck.

http://weald10k.fileave.com/PF003_1.png

Now given that Ship one is at the origin of our coordinate system and it is align horizontally wee can now see if ship2 is withing range to be shot :D.

So this is where those second equations you have come into play. So we can first decide if the ship is within the maximum shooting distance from us, so we can do that by this equation

[tex]d = \sqrt{x^2 + y^2 + z^2}[/tex]

where x,y,z represent the coordinates of ship2 in our transformed coordinate space.
If d is less than the maximum range on the laser then we can proceed to the next stage.
We now need to decided if ship 2 is within the angle of shooting for ship1. In the diagram you can see angle a, now this angle is the angle in which ship1 can shoot and is symetrical about the x axis, so it stretches around the z axis to +(a/2) and -(a/2) each way, and hopefully you can make out where they reach by the vertical gray bars on the diagram.

So now we need to calculate the horizontal angle between ship2 and ship1 (call the azimuth angle) which we do with one of you second set of equations:

[tex]\theta = tan^{-1}\left(\frac{y}{x}\right)[/tex]

from that we can get the azimuth angle of ship2 from ship1, if it satisfies the interval

[tex] -\frac{a}{2} < \theta < \frac{a}{2} [/tex]

then ship1 will be able to shoot ship2.
I hope that helps, it seems like quite a hard programing problem (but I don't know what level of eduction that's at so sorry for any assumption made there :D) good luck with you program
 
  • #3


Hey, thanks a lot for the info. However, the assignment was due (and turned in yesterday) :eek: Anyway, I think I did okay, but I was fortunate enough to get a couple of responses from my Professor (wasn't expecting that :wink: )

When I asked him a very close to the way I posted the question here, he stated: "I would stick with Cartesian and measure distances as I hinted."

So I wrote back, "As far as the coordinates goes, https://www.physicsforums.com/newreply.php?do=postreply&t=290376#1 the distance itself is not a problem; it's the same equation, but with z added. So would the only difference in the SIN and COS equations from the "hint" be that the distance in the denominator?"

His response: "Yes. You are correct."

So, that's what I did...much more simple than what I was making.

So if there wasn't a "hit", I did:

Catx = Catx + speed*(Mousex-Catx)/getDistance();
Caty = Caty + speed*(Mousey-Caty)/getDistance();
if (Math.Abs(Catz - Mousez) >= blowupDistance / 3)
{
Catz = Catz + MoveUp(1, System.Convert.ToInt32(speed));
}

I moved the mouse based on how close the the cat was, but we had a lot a freedom to do whatever for this.

Was I correct? Based on my Professor's emails, I would say I've very close.

Thanks again,

Jason
 
Last edited by a moderator:
  • #4


Hi Jason, ah sorry about that, a day late :D. Sure that I think looks fine, I don't quite understand where the "/3" comes from on line 3, but you know that only a small part of you program.
I think the way you did is far more sensible, after all it meant to be a programing problem not a math problem. And I think to be honest there won't be a "correct answer", its a simulation and how the simulation pans out will depend on the programmer :D, I am sure you'll do great with the program.
 
  • #5


Galadirith said:
Hi Jason, ah sorry about that, a day late :D. Sure that I think looks fine, I don't quite understand where the "/3" comes from on line 3, ...

No worries...my division by 3 is bullsh*t :eek: basically...I moved the Cat's z-position if the difference in z coordinates of the cat and mouse was greater than equal to a third of the distance in which the bomb can hit. Just something to move the z to a better position...hopefully.

Nothing groundbreaking going on here, but it was fun to run...because some of the movements are based on pseudo-random movements, so sometimes the cat wins, some time the mouse gets away.

Overall fun, except for getting started ;)
 

1. What is the "3D Space Pursuit Problem"?

The "3D Space Pursuit Problem" is a mathematical problem that involves two or more objects moving in 3D space with different velocities and directions in order to find the optimal path for one object to catch up to and intercept another object.

2. What real-world applications does the "3D Space Pursuit Problem" have?

The "3D Space Pursuit Problem" has applications in fields such as aerospace engineering, robotics, and game design. It can be used to optimize spacecraft trajectories, design autonomous navigation systems for robots, and create realistic pursuit scenarios in video games.

3. What are the main challenges in solving the "3D Space Pursuit Problem"?

One of the main challenges in solving the "3D Space Pursuit Problem" is dealing with the complex mathematics involved in calculating the optimal path and intercept point between two moving objects in 3D space. Another challenge is accounting for any external factors that may affect the movement of the objects, such as gravitational forces or obstacles in the path.

4. What are some popular algorithms used to solve the "3D Space Pursuit Problem"?

Some popular algorithms used to solve the "3D Space Pursuit Problem" include the Lambert's problem algorithm, the Clohessy-Wiltshire equations, and the Chaser-Target Relative Motion (CTRM) algorithm. These algorithms use various mathematical techniques and principles to calculate the optimal path and intercept point for the pursuing object.

5. How does the "3D Space Pursuit Problem" differ from the "2D Pursuit Problem"?

The "3D Space Pursuit Problem" differs from the "2D Pursuit Problem" in that it takes into account the third dimension, which adds a layer of complexity to the calculations. In 2D, the movement of objects can be represented on a flat surface, while in 3D, the objects are moving in a 3-dimensional space with multiple axes and directions. This requires the use of more advanced mathematical techniques to solve the problem.

Similar threads

Replies
3
Views
2K
Back
Top