This can be handled like the similar case for linear acceleration.
First fact to note: Because the ship starts off with an angular velocity of zero, an you want it to end up with an angular velocity of zero, this means that the total change in velocity must equal zero.
From this we can see that the integral of the acceleration over time must equal zero -- there must be exactly as "much" positive acceleration as there is negative acceleration.
Therefore, your solution, whatever it is, must be constrained to this property: Equal "total" acceleration forwards and backwards.
Here is what the shape of your acceleration over time graph should follow:
Looking at this, there are so many possible forms and shapes your acceleration could be in! Let us make some assumptions for the shape of acceleration that you want, in order to give an easy/concise answer.
For the sake of a simple answer, I will have acceleration be in one of three states: forwards, backwards, or zero. Forwards and backwards will be at equal magnitude, and the states can be switched instantaneously. (there is no gradual ramping up of acceleration)
You can find the change in distance for a given acceleration over a given period of time with this equation:
s = 0.5*a*t^2
The simplest solution here would be to accelerate until you reach the halfway point, then decelerate the rest of the way.
We will take P
as the total distance you want to move:
s = P/2
P/2 = 0.5*a*t^2
P = a*t^2
t^2 = P/a
t = sqrt(P/a)
So basically:
- Accelerate at
a
for sqrt(P/a)
units of time (units based off your units for acceleration)
- Decelerate at the same magnitude for the same amount of time
This is not the only solution. It will get you there in the fastest amount of time (2*sqrt(P/a)
). But what if you want a more relaxed version?
In this case, you can accelerate 1/3rd of the way, coast for the 1/3rd, and decelerate the rest of the third. Or 1/4th, coast for 1/2, decelerate 1/4th as well.
Or maybe you could accelerate for a fixed amount of time, and then decelerate for a fixed amount of time, but wait until you arrive at the exact position before you start decelerating.