Complex Time, Distance & Speed

In summary: In that case, you may want to rethink your strategy.In summary, the problem is how to calculate the distance and time for a submarine to fire a torpedo at a moving ship from a distance. This involves considering the speed and bearing of both the submarine and the ship, as well as the initial distance between them. A possible solution involves solving a system of nonlinear equations using substitution and the atan2 function. However, if the ship's speed is greater than the torpedo's speed and the initial distance is too large, there may not be a solution.
  • #1
DNA1
1
0
Hi all,

I'm currently developing a game app, but I've hit a math problem, which I'm hoping someone here could help me with.

The problem:

This is a 2D board, which has cords (x,y).
I have a sub facing e.g. north, that firers a torpedo(moving e.g. 30) and the same direction as the sub. The target is a ship (moving at e.g. 7) moving left or right.

So the problem is how do I calculate a targeting calculation that measures the distance and time, as to when to fire a torp so that it will hit the ship from a distance.
Now keep this in mind, the ship will not always be at right angle. It is more likely that it will be at an odd angle...

I can safely say I had more hair before I hit this problem.

To round off what objects and values are used:

1) Sub (Location in x,y - Angle (0-360) facing);
2) Torpedo (speed);
3) Ship (Location in x,y - Angle traveling - Speed);

The angle, distance of the sub and the ship will always be different.

Have fun losing sleep, thanks to anyone and everyone that trys to help

DNA
 
Last edited by a moderator:
Mathematics news on Phys.org
  • #2
You've given us a 2D problem. Let's keep this abstract. Suppose the ship's speed is the constant $v$, its bearing is $\theta$, and its initial position is $\langle x_{s0}, y_{s0} \rangle$. Let $r= \sqrt{x_{s0}^{2}+y_{s0}^{2}}$ be the initial distance from the sub to the ship. In the navy, a "bearing" is a measure, in degrees, of the ship's direction, where North is zero, and positive angles are clockwise. This is in contrast to typical mathematics, where angles are positive counterclockwise, and are measured relative to the positive $x$ axis.

Suppose also that the torpedo has a constant speed $u$, at a bearing $\varphi$.

Now, the ship's trajectory is quite simple: $\mathbf{x}_{s}= \langle x_{s0}, y_{s0} \rangle + tv \langle \sin(\theta),\cos(\theta) \rangle$. The torpedo's trajectory is also quite simple: $\mathbf{x}_{t}=tu \langle \sin(\varphi), \cos( \varphi) \rangle$. Here I've set the origin at the submarine. What we want is a single time $t$ such that $\mathbf{x}_{s}= \mathbf{x}_{t}$, or
$$ \langle x_{s0}, y_{s0} \rangle +tv \langle \sin(\theta),\cos(\theta) \rangle=tu \langle \sin(\varphi), \cos( \varphi) \rangle.$$
This is system for $\varphi$ and $t$ in two equations:
\begin{align*}
x_{s0}+tv \sin( \theta)&= tu \sin(\varphi) \\
y_{s0}+tv \cos( \theta)&= tu \cos( \varphi).
\end{align*}
Since the equations are nonlinear, I would opt for a substitution method. I'd probably solve one of the equations for $t$, and plug that into the other:
\begin{align*}
x_{s0}&=t \left( u \sin( \varphi)-v \sin( \theta) \right) \\
t&= \frac{x_{s0}}{u \sin( \varphi)-v \sin( \theta)} \\
y_{s0}&=t \left( u \cos( \varphi)-v \cos( \theta) \right) \\
&= \frac{x_{s0} \left( u \cos( \varphi)-v \cos( \theta) \right)}{u \sin( \varphi)-v \sin( \theta)} \\
y_{s0} u \sin( \varphi)-y_{s0} v \sin( \theta)&= x_{s0} u \cos( \varphi)- x_{s0} v \cos( \theta) \\
y_{s0} u \sin( \varphi)-x_{s0}u \cos( \varphi)&=y_{s0} v \sin( \theta)-x_{s0}v \cos( \theta) \\
y_{s0} \sin( \varphi)-x_{s0}\cos( \varphi)&= \frac{y_{s0} v \sin( \theta)-x_{s0}v \cos( \theta)}{u} \\
r \sin( \varphi+ \text{atan2}(-x_{s0},y_{s0}))&=\frac{y_{s0} v \sin( \theta)-x_{s0}v \cos( \theta)}{u} \\
\sin( \varphi+ \text{atan2}(-x_{s0},y_{s0}))&=\frac{y_{s0} v \sin( \theta)-x_{s0}v \cos( \theta)}{ru} \\
\varphi+ \text{atan2}(-x_{s0},y_{s0})&= \arcsin \left( \frac{y_{s0} v \sin( \theta)-x_{s0}v \cos( \theta)}{ru} \right) \\
\varphi&= \arcsin \left( \frac{y_{s0} v \sin( \theta)-x_{s0}v \cos( \theta)}{ru} \right)
-\text{atan2}(-x_{s0},y_{s0}).
\end{align*}
The atan2 function is usually available in many programming languages. It's essentially the arctangent function, but without the usual ambiguity. That is, it'll return an angle in the correct quadrant.

If you find that these equations give you complex numbers as answers, that would be an indication that the system has no solution - entirely possible if the ship's speed is larger than the torpedo's speed and you're far away enough.
 
Last edited:

What is complex time, distance, and speed?

Complex time, distance, and speed refer to scenarios where time, distance, and speed are not constant or linear. This means that the rate of change of any of these variables is not consistent and can vary over time.

What are some real-life examples of complex time, distance, and speed?

Real-life examples of complex time, distance, and speed include traffic flow on roads, weather patterns, and the movement of objects in a non-uniform gravitational field. These scenarios involve varying rates of change, making them complex.

How is complex time, distance, and speed different from simple time, distance, and speed?

The main difference between complex and simple time, distance, and speed is that in simple scenarios, these variables are constant and can be easily calculated using basic formulas. In complex scenarios, these variables are not constant and require more advanced mathematical models to accurately calculate.

Why is it important to understand complex time, distance, and speed?

Understanding complex time, distance, and speed is crucial for accurately predicting and analyzing real-world phenomena. It allows scientists and engineers to develop more precise models and make more accurate predictions, leading to advancements in various fields such as transportation, weather forecasting, and space exploration.

What are some methods used to analyze complex time, distance, and speed?

Some methods used to analyze complex time, distance, and speed include calculus, differential equations, and computer simulations. These tools allow scientists to account for the non-linear and varying nature of these variables and accurately predict their behavior in complex scenarios.

Similar threads

  • Special and General Relativity
Replies
25
Views
2K
  • Special and General Relativity
Replies
14
Views
668
  • Introductory Physics Homework Help
Replies
2
Views
554
Replies
6
Views
2K
Replies
9
Views
2K
Replies
38
Views
3K
  • Sci-Fi Writing and World Building
Replies
4
Views
2K
  • Special and General Relativity
5
Replies
146
Views
7K
Replies
7
Views
862
  • Sci-Fi Writing and World Building
3
Replies
96
Views
6K
Back
Top