There was a similar thread about a month ago that was about shooting a moving target, and knowing at what angle you must shoot. Look at the archives.
Here's my take on the problem:
First of all, the speed of the ship is not really useful, because all we really care about is the speed of the laser (btw, isn't setting the speed of the laser, ie.: a light beam, to speed of the ship + 2 in contradiction with relativity? whatever)
Speed of the laser: sL (vector)
We want to know the position where the laser and asteroid will collide, and when: (I'm using only vectors: sA is also a vector --- don't use your conventions/optimizations when posting here)
P = pS + sL * tP = pA + sA * tpS + sL * t = pA + sA * t (first equation)pS - pA = (sA - sL) * tt = pS - pA ------- sA - sL
You have to express sL's direction as a function of pS, pA and sA.
Hmm... I'm sorry, but I should be working now and I don't feel like finishing this problem (I didn't think it would be that long), although I can outline what I think is the solution. This may look like a 3D problem, but it really is 2D because you only have to solve a triangle. Its sides are pA - pS, P - pS and P - pA. You can find the angle between P - pA and pA - pS with the dot product. Using this angle and the law of cosines, you can find a second equation. Since you have two unknowns in sL' vector (remember, it's a 2D problem; you have to toy with the equations), then you should be able to solve your problem with these two equations.
If I have more time today, I'll finish it myself, but right now, I don't. Sorry.
Cédric
[edited by - cedricl on May 2, 2002 9:45:25 AM]