I am creating a real-time game where ships move through space using basic laws of motion. The ships move by rotating (instantly for our purposes) to an angle and then firing their engine to accelerate.
I have coded up a basic ECS system wherein every tick velocity is added to position and acceleration is added to velocity.
So the problem is at any given moment how can a ship determine the rotation to fire its engine (assume constant acceleration) to intercept an arbitrary point elsewhere in the world. Ideally in the shortest time possible, however I'd settle for ever.
I have the following variables:\$v\$ the current velocity vector of the ship at \$t = 0\$ , \$P_0\$ the current postition of the ship, \$P_2\$ the desired intercept point, and \$||a||\$ the maximum magnitude of the acceleration vector.
I need to find some rotation \$\theta\$ to fire my engine in to follow a curve to the given intercept point \$P_2\$.
I have tried solving for the quadratic bezier curve control points for such a path and then deriving its acceleration. Like so:
\$P'(t) = 2(1-t)(P_1 - P_0)+2t(P_2 - P_1)\$
\$P'(0) = v = 2P_1 - 2P_0\$
\$P_1 = \frac{v}{2} + P_0\$
To derive \$P_1\$ and then:
\$P''(t) = 2(P_2 - 2P_1 + P_0)\$
plugging in the three points to get an acceleration vector, however if I understand correctly bezier curves are from \$t=0\$ to \$t=1\$? So this is a massive acceleration vector that would get my ship to the point in one game tick. I have tried scaling this vector to the maximum magnitude of the engine's acceleration, but that doesn't quite work. I feel like my approach is close but I can't quite figure it out.
Cont.
I have thought about this more and returned to this solution. I believe I need to solve for time \$T\$ to reach the point by calculating the radius of the circle in the aforementioned answer. If I do that then I can calculate the second control point as \$P_0 + Tv\$.
It seems to me that the minimum time necessary to reach a point is when the destination point \$P_2\$ is on the circumference of the circle described by it's center \$P_0 + Tv\$ and radius \$\frac{T^2}{2}a\$ where \$a\$ is the maximum acceleration.
Previously I was conflating the \$t\$ in the bezier curve polynomial (between 0 and 1) with some time \$T\$ it will take to complete the maneuver which is unbounded.