I’m making a real-time recreation the place ships transfer via area utilizing primary legal guidelines of movement. The ships transfer by rotating (immediately for our functions) to an angle after which firing their engine to speed up.
I’ve coded up a primary ECS system whereby each tick velocity is added to place and acceleration is added to velocity.
So the issue is at any given second how can a ship decide the rotation to fireplace its engine (assume fixed acceleration) to intercept an arbitrary level elsewhere on this planet. Ideally within the shortest time doable, nonetheless I would accept ever.
I’ve the next variables:$v$ the present velocity vector of the ship at $t = 0$ , $P_0$ the present postition of the ship, $P_2$ the specified intercept level, and $||a||$ the utmost magnitude of the acceleration vector.
I want to seek out some rotation $theta$ to fireplace my engine in to comply with a curve to the given intercept level $P_2$.
I’ve tried fixing for the quadratic bezier curve management factors for such a path after which 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$ after which:
$P”(t) = 2(P_2 – 2P_1 + P_0)$
plugging within the three factors to get an acceleration vector, nonetheless if I perceive accurately bezier curves are from $t=0$ to $t=1$? So this can be a huge acceleration vector that will get my ship to the purpose in a single recreation tick. I’ve tried scaling this vector to the utmost magnitude of the engine’s acceleration, however that does not fairly work. I really feel like my method is shut however I can not fairly determine it out.
Cont.
I’ve thought of this extra and returned to this answer. I imagine I want to resolve for time $T$ to achieve the purpose by calculating the radius of the circle within the aforementioned reply. If I do this then I can calculate the second management level as $P_0 + Television$.
It appears to me that the minimal time mandatory to achieve a degree is when the vacation spot level $P_2$ is on the circumference of the circle described by it is middle $P_0 + Television$ and radius $frac{T^2}{2}a$ the place $a$ is the utmost acceleration.
Beforehand I used to be conflating the $t$ within the bezier curve polynomial (between 0 and 1) with a while $T$ it’ll take to finish the maneuver which is unbounded.