Your approach will get to the right answer, but it is the hard way to do it. (There is one problem with your equations. The first equation for the intercept point should be x=x_start+Speed target.time.cos(course target) and similarly for y.)
The easy way is to draw a triangle. Draw a line from you to the ship's current position. This side has length R (the range to the target). From the ship, draw the second side of the triangle in the direction it is heading. It will be hit by the torpedo after 'time' seconds, so the length of this side is 'Speed target.time' (kind of like what you wrote). The angle from this side of the triangle to the first side of the triangle we drew is the angle on bow. The third side of the triangle is the line from the uboat to the intercept point, which has length 'Speed torp.time'. The angle between side 1 and side 3 is the angle offset (I call it theta) that the torp should take (measured from the current direction to the ship).
Now apply the Law of Sines, which states that sin(angle on bow)/(Speed torp.time)=sin(theta)/(Speed target.time). Solving for this gives sin(theta)=sin(angle on bow)*Speed target/Speed torp.
Notice that this solution does not depend upon the current range to the ship. (If you have heard of the term before, this is the 'proportional navigation' solution.) In SH3, the firing solution does depend a little on range, since it takes into account the fact that it takes some time and space for the torp to turn to the right heading. However, the solution doesn't change much with range for long range shots.
I hope this answers your question.
Or was this a geek test?
Sturgeon
|