So, here's my problem:
I have a turret attached to a ship that moves at a variable speed through my game world, shooting at the centre of another ship travelling through the game world in a possibly different vector. Currently, I get the angle that I need to shoot at using atan2:
double targetAngle = Math.Atan2(ship.CurrentTarget.Position.Y - ship.Position.Y, ship.CurrentTarget.Position.X - ship.Position.X);
This works fine when both ships are stationary, or moving very slowly, but if moving faster, the aim lags behind. An additional fun part of the puzzle: the bullet's vector isn't static, they start at 0 and increase in speed. Their position is calculated as follows:
var direction = new Vector2((float)Math.Cos(currentRotation),
(float)Math.Sin(currentRotation));
if (direction.Length() > 0)
direction.Normalize();
var velocity = new Vector2(direction.X * MotionData.CurrentSpeed,
direction.Y * MotionData.CurrentSpeed) + additiveVector;
Where additiveVector is my ship's vector at the point the projectile was launched. CurrentSpeed will be added to every frame until it hits a static maxspeed.
So far, the problems I've encountered with other solutions for compensating my aim is that the formulas rely on a static velocity for the projectile, and mine isn't.