I have to question chrisf's solution based on dimensional analysis. Looking at his denominator (x * y - z * y), we have ft * ft/s - ft/s * ft/s. That I have problems with subtracting unlike units. One of the items this problem is missing is how far away is the train at time zero.

_W_|
\ |
\ | X
\ |
\|_________Wo___________

So we have (y*t)^2 = W^2 + X^2
and W + Wo = z*t

This can be viewed as maximizing W, or t or the angle.

I'll leave this to the calculus experts to do the rest.

Enjoy life,

Parke