How to find the launch direction to intercept an object moving on a sphere?

95 Views Asked by At

For my game, I have a projectile moving around the surface of a sphere, along a great circle of the sphere. I want to be able to launch an other projectile from a different object such that the two projectiles will intersect. Both the instantaneous positions of the projectile and the object launching the intercepting projectile are known, as well as the velocities of the projectiles (which may be different). Nothing may deviate from the surface of the sphere. The radius of the sphere is known.

My attempt to solve this involved using spherical trig on a triangle defined by points (launch position, projectile position at t=0, intersection point of projectiles), but I was running into trouble figuring out how to construct that triangle given one known side, one known angle, and a relationship between the two remaining sides. Can anyone help me out on this problem?

2

There are 2 best solutions below

0
On

Suppose you are in control of launching the missile that will collide with the object on the sphere.

Let $t=0$ to be the time when you launch the missile.

Denote your position at time $t$ to be $r(t)=(x(t),y(t),z(t))$, the object's position on the sphere as $r_O(t)=(x_O(t),y_O(t),z_O(t))$, and the missile's position to be $r_m(t)=(x_m(t),y_m(t),z_m(t))$.

If we neglect air resistance, we know that $r_m(t)$ solves the DE $r_m''(t)=-g \hat{k}$. This means $$r_m(t)=\Big(at+x(0),bt+y(0),-\frac{1}{2}gt^2+ct+z(0)\Big)$$

Here, $r_m'(0)=(a,b,c)$ is your unknown initial velocity that we need to find.

If we want the missile to intercept the object $T$ units of time after being launched, then we must have $r_m(T)=r_O(T)$. This means $$r_m'(0)=(a,b,c)=\Big(\frac{x_O(T)-x(0)}{T},\frac{y_O(T)-y(0)}{T},\frac{z_O(T)-z(0)+gT^2/2}{T}\Big)$$

But $(a,b,c)$ is the resultant vector of $r'(0)$ and the velocity at which the missile is fired. So you must fire the missile at an initial velocity of $(a,b,c)-r'(0)$ to intercept the object after $T$ units of time.

0
On

You have an object $A$ moving with constant speed $|\vec{v_1}|$ on a great circle on the sphere. The sphere is assumed to be centered at $(0,0,0)$, and of a known radius $r$, such that at $t = 0$, it is at point $\vec{a}$ on the sphere, and its vector velocity at that point is given by $\vec{v_1}$.

And you have a launcher at point $\vec{b}$ from which you want to launch a "projectile" that moves with constant speed $| \vec{v_2} |$. We can assume that the projectile is launched with some delay $t_1 \ge 0$ such that its vector velocity at $t_1$ is equal to vector $\vec{v_2}$. The magnitude of this vector is known, but its direction is unknown. What we know is that it will be along the surface of the sphere, and therefore, suppose we find a unit vectors $\vec{u_1}$, such that $ \vec{b} \cdot \vec{u_1} = 0 $, then we'll define $\vec{u_2} = \dfrac{1}{r} \bigg( \vec{b} \times \vec{u_1} \bigg) $. If we define $\vec{u_3} = \dfrac{1}{r} \vec{ b } $, then the set $\{ u_1, u_2 , u_3 \} $ is an orthonormal set, i.e. the matrix

$ R_0 = [u_1, u_2, u_3] $

is a $3 \times 3$ rotation matrix.

Using $\vec{u_1}, \vec{u_2}$, we can parameterize the vector $\vec{v_2}$ as follows:

$\vec{v_2} = | \vec{v_2} | ( \cos \theta \vec{u_1} + \sin \theta \vec{u_2} ) $

The only unknown in this equation is $\theta$, all the other quantities are known.

Back to our object, it's path is spanned by vectors $\vec{a}$ and $\vec{v_1}$. It's trajectory on the sphere is given by

$ \vec{P_1}(t) = \vec{a} \cos( \omega_1 t ) + r \hat{v_1} \sin(\omega_1 t) $

where $\omega_1 = \dfrac{| \vec{v_1} |}{r} $, and $\hat{v_1} = \dfrac{\vec{v_1}}{| \vec{v_1} | } $

Similarly the trajectory of the projectile, for $ t \ge t_1 $ is given by

$ \vec{P_2}(t) = \vec{b} \cos (\omega_2 (t - t_1) ) + r \hat{v_2} \sin (\omega_2 (t - t_1) ) $

where $\omega_2 = \dfrac{| \vec{v_2} |}{r} $ is known, and $ \hat{v_2} = \dfrac{ \vec{v_2} }{| \vec{v_2} |} = \cos \theta \vec{u_1} + \sin \theta \vec{u_2} $

So that,

$ \vec{P_2}(t) = \vec{b} \cos (\omega_2 (t - t_1) ) + r ( \cos \theta \vec{u_1} + \sin \theta \vec{u_2} )\sin (\omega_2 (t - t_1) ) $

At time $t = t_2$ we want the two trajectories to intersect. That is,

$ \vec{P_1}(t_2) = \vec{P_2} (t_2) $

Substitute the expression for the two trajectories from above. This gives us,

$ \vec{a} \cos( \omega_1 t_2 ) + r \hat{v_1} \sin(\omega_1 t_2) = \vec{b} \cos (\omega_2 (t_2 - t_1) ) + r ( \cos \theta \vec{u_1} + \sin \theta \vec{u_2} )\sin (\omega_2 (t_2 - t_1) ) $

Divide through by $r$, giving

$ \hat{a} \cos( \omega_1 t_2 ) + \hat{v_1} \sin(\omega_1 t_2) = \hat{b} \cos (\omega_2 (t_2 - t_1) ) + ( \cos \theta \vec{u_1} + \sin \theta \vec{u_2} )\sin (\omega_2 (t_2 - t_1) ) $

where $\hat{a} = \dfrac{\vec{a}}{r} $ and $\hat{b} = \dfrac{\vec{b}}{r} $

Define $\theta_1 = \omega_1 t_2 $ and $\theta_2 = \omega_2 (t_2 - t_1) $, then we get,

$\hat{a} \cos( \theta_1 ) + \hat{v_1} \sin(\theta_1) = \hat{b} \cos (\theta_2 ) + ( \cos \theta \vec{u_1} + \sin \theta \vec{u_2} )\sin (\theta_2 ) $

Note that $\theta_2 = \left(\dfrac{\omega_2}{\omega_1}\right) \theta_1 - \omega_2 t_1 $

Define the unknown unit vector $v$ as follows,

$ \vec{v} = [ \sin(\theta_2) \cos(\theta) , \sin(\theta_2) \sin(\theta) , \cos(\theta_2) ]^T $

Switching to matrix-column vector notation, the intersection of the two trajectories equation becomes

$\hat{a} \cos( \theta_1 ) + \hat{v_1} \sin(\theta_1) = R_0 v $

Note that the $3 \times 3$ matrix $R_0$ is a rotation matrix and is known. Pre-multiplying both sides by $R_0^T$ gives

$ R_0^T \hat{a} \cos(\theta_1) + R_0^T \hat{v_1} \sin(\theta_1) = v $

Let $U = R_0^T \hat{a} $ and $ W = R_0^T \hat{v_1} $ , then we now have

$ U \cos(\theta_1) + W \sin(\theta_1) = v $

Take the $z$ component of this vector equation,

$ U_z \cos(\theta_1) + W_z \sin(\theta_1) = \cos(\theta_2) $

But, $\theta_2 = \left(\dfrac{\omega_2}{\omega_1}\right) \theta_1 - \omega_2 t_1 =: A \theta_1 + B $

So substituting this into the right hand side, gives

$ U_z \cos(\theta_1) + W_z \sin(\theta_1) = \cos(A \theta_1 + B ) $

For an arbitrary value of $A = \dfrac{\omega_2}{\omega_1}$, there is no closed-from solution for this equation, but it can be solved numerically using Newton's root finder method for example. And there could be more than one solution.

However if we assume that the projectile is moving at the same speed as the object, then $\omega_1 = \omega_2 $ , and this case, the above trigonometric equation becomes

$ U_z \cos(\theta_1) + W_z \sin(\theta_1) = \cos( \theta_1 + B ) $

where as defined above, $B = - \omega_2 t_1 $ ($t_1$ is known).

Expanding the right hand side,

$ U_z \cos(\theta_1) + W_z \sin(\theta_1) = \cos(\theta_1) \cos(B) - \sin(\theta_1) \sin(B) $

Dividing through by $\cos(\theta_1)$,

$ U_z + W_z \tan(\theta_1) = \cos(B) - \tan(\theta_1) \sin(B) $

So

$\tan(\theta_1) = \dfrac{ \cos(B) - U_z}{ W_z + \sin(B) } $

which gives two possible values for $\theta_1$ in the interval $[0, 2\pi)$.

Having obtained $\theta_1$ we can now compute the interception time $t_2$, because $\theta_1 = \omega_1 t_2 $.

Also, we can compute $ \theta_2 = \left( \dfrac{\omega_2}{\omega_1} \right) \theta_1 + B $, which is the angle swept by the projectile.

Recall that

$ U \cos(\theta_1) + W \sin(\theta_1) = v = [ \sin(\theta_2) \cos(\theta) , \sin(\theta_2) \sin(\theta) , \cos(\theta_2) ]^T$

Therefore, using the $x$ and $y$ components of this vector equation, we can compute the angle $\theta$ that determines the launch direction of the projectile, namely,

$ \theta = \text{ATAN2} ( U_x \cos(\theta_1) + W_x \sin(\theta_1) , U_y \cos(\theta_1) + W_y \sin(\theta_1) ) $

Here's an example of interception with $r = 10m$, $|\vec{v_1}| = 4m/s$, $t_1 = 5s$, and $\omega_2 = \omega_1$. The blue curve is the trajectory of the object, while the orange trajectory is that of the projectile.

enter image description here

And with $\omega_2 = 1.5 \ \omega_1 $

enter image description here