Hopefully someone with a bit more experience will provide some insight, but if it were me in that situation I would crash dive and make like a hole in the water once below the thermal layer: chances are if it's spotted you and decided to head straight for you at that kinda speed, it's probably a destroyer. You don't want to tango with those unless you've got no other choice, or you don't mind reloading a saved game. (I've recently taken to never reloading saved games when I get blown to bits. I've noticed it tends to make me a little more cautious and careful 'cause I don't want to start the whole career over again.)
If you've absolutely got to fire a torpedo, for a ship that's heading straight for you you don't really need to do any calculations 'cause the only thing that really matters in that case is the bearing.
Why risk it, though? Run away and live to fight another day.
nomad_delta