MHB Complex Time, Distance & Speed

AI Thread Summary
The discussion centers on calculating the optimal firing time for a torpedo from a submarine to hit a moving ship in a 2D space. It outlines the need to account for the submarine's and ship's positions, speeds, and angles. The equations provided describe the trajectories of both the torpedo and the ship, leading to a system of nonlinear equations that can be solved using substitution methods. The use of the atan2 function is recommended for determining angles accurately. The conversation highlights the complexity of the problem, particularly when the ship's speed exceeds that of the torpedo.
DNA1
Messages
1
Reaction score
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
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:
Suppose ,instead of the usual x,y coordinate system with an I basis vector along the x -axis and a corresponding j basis vector along the y-axis we instead have a different pair of basis vectors ,call them e and f along their respective axes. I have seen that this is an important subject in maths My question is what physical applications does such a model apply to? I am asking here because I have devoted quite a lot of time in the past to understanding convectors and the dual...
Insights auto threads is broken atm, so I'm manually creating these for new Insight articles. In Dirac’s Principles of Quantum Mechanics published in 1930 he introduced a “convenient notation” he referred to as a “delta function” which he treated as a continuum analog to the discrete Kronecker delta. The Kronecker delta is simply the indexed components of the identity operator in matrix algebra Source: https://www.physicsforums.com/insights/what-exactly-is-diracs-delta-function/ by...
Back
Top