# comp.graphics.algorithms

## Subject: Re: How to get angle and speed to reach a movable point

hoffmann@fho-emden.de wrote:
> Object (A) should move with max. velocity.
> Even for the case, that the target (B) position is
> known and the velocity is constant and known,
> the task requires the solution of two nonlinear
> equations:

> http://www.fho-emden.de/~hoffmann/intersect.pdf

Hmm... you propose doing this using iterative numeric techniques. I
don't think that's necessary.

0) This is a 2D problem, even if it takes place in 3D. It takes place
in the plane spanned by A(0), B(0) and B'(0) (the velocity vector of
B).

So we're looking for variables A', t, such that

1) A hits B at time t:
A(0) + t * A' = B(0) + B'(0) * t, t >= 0

2) A's velocity is at its maximum --- running slowly to catch someone is
obviously silly:

|A'| = A'_max

[I'll drop the (0) from now on]

One way of solving this constructively is to split up A' into two
parts, one to match the speed of B, the rest to cover the distance.

A' = B' + C' where B'^2 + C'^2 = A'_max^2

Putting this in, you get

A + t*B' + t*C' = B + t*B'

--> C' = (B - A) / t
C'^2 = A'_max^2 - B'^2

--> (B - A)^2 / t^2 = C'^2 = A'_max^2 - B'^2

t^2 = (B - A)^2 / (A'_max^2 - B'^2)

If the right-hand side of this equation is negative, i.e. A is slower
than B, he can't catch him. Otherwise, this directly gives you t, and
substitution then yields C', and ultimately A'.

Similar maths would yield the results for the other basic hunting
strategies mentioned in this thread, i.e. "aim for the prey's current
location" and the "aim for half way between current and projected
location".

--
Hans-Bernhard Broeker (broeker@physik.rwth-aachen.de)
Even if all the snow were burnt, ashes would remain.